1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "mojo/runner/scoped_user_data_dir.h"
7 #include "base/command_line.h"
8 #include "base/logging.h"
9 #include "mojo/runner/switches.h"
14 ScopedUserDataDir::ScopedUserDataDir() {
15 base::CommandLine
* command_line
= base::CommandLine::ForCurrentProcess();
16 if (!command_line
->HasSwitch(switches::kUseTemporaryUserDataDir
))
19 if (command_line
->HasSwitch(switches::kUserDataDir
)) {
20 // User should not specify a --user-data-dir manually when using
21 // --use-temporary-user-data-dir. The point of the flag is to let the
22 // mojo runner process manage the lifetime of the user data dir.
23 LOG(ERROR
) << "Ignoring request to --use-temporary-user-data-dir because "
24 << "--user-data-dir was also specified.";
28 if (!temp_dir_
.CreateUniqueTempDir()) {
29 LOG(ERROR
) << "Failed to create a temporary user data dir.";
33 command_line
->AppendSwitchPath(switches::kUserDataDir
, temp_dir_
.path());
36 ScopedUserDataDir::~ScopedUserDataDir() {