Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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. | |
| 4 | |
| 5 #include "mojo/runner/scoped_user_data_dir.h" | |
| 6 | |
| 7 #include "base/command_line.h" | |
| 8 #include "base/logging.h" | |
| 9 #include "mojo/runner/switches.h" | |
| 10 | |
| 11 namespace mojo { | |
| 12 namespace runner { | |
| 13 | |
| 14 ScopedUserDataDir::ScopedUserDataDir() { | |
| 15 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | |
| 16 if (command_line->HasSwitch(switches::kUseTemporaryUserDataDir)) { | |
|
jam
2015/06/25 15:28:23
nit: early return here would remove indentation
| |
| 17 if (command_line->HasSwitch(switches::kUserDataDir)) { | |
|
jam
2015/06/25 15:28:23
nit: just CHECK(!command_line->HasSwitch(switches:
Elliot Glaysher
2015/06/25 22:46:48
Disagree. Errors that users can trigger should hav
| |
| 18 // User should not specify a --user-data-dir manually when using | |
| 19 // --use-temporary-user-data-dir. The point of the flag is to let the | |
| 20 // mojo runner process manage the lifetime of the user data dir. | |
| 21 LOG(ERROR) << "Can not have both --user-data-dir and " | |
| 22 << "--use-temporary-user-data-dir in the same process."; | |
| 23 return; | |
| 24 } | |
| 25 | |
| 26 if (!temp_dir_.CreateUniqueTempDir()) { | |
| 27 LOG(ERROR) << "Failed to create a temporary user data dir."; | |
| 28 return; | |
| 29 } | |
| 30 | |
| 31 command_line->AppendSwitchPath(switches::kUserDataDir, temp_dir_.path()); | |
| 32 } | |
| 33 } | |
| 34 | |
| 35 ScopedUserDataDir::~ScopedUserDataDir() { | |
| 36 } | |
| 37 | |
| 38 } // namespace runner | |
| 39 } // namespace mojo | |
| OLD | NEW |