Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(331)

Side by Side Diff: chrome/service/cloud_print/cloud_print_proxy.cc

Issue 1010923002: If possible, use the PathService instead of the --user-data-dir flag directly (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/service/cloud_print/cloud_print_proxy.h" 5 #include "chrome/service/cloud_print/cloud_print_proxy.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
10 #include "base/path_service.h" 10 #include "base/path_service.h"
11 #include "base/process/kill.h" 11 #include "base/process/kill.h"
12 #include "base/process/launch.h" 12 #include "base/process/launch.h"
13 #include "base/values.h" 13 #include "base/values.h"
14 #include "chrome/common/chrome_paths.h"
14 #include "chrome/common/chrome_switches.h" 15 #include "chrome/common/chrome_switches.h"
15 #include "chrome/common/cloud_print/cloud_print_constants.h" 16 #include "chrome/common/cloud_print/cloud_print_constants.h"
16 #include "chrome/common/cloud_print/cloud_print_proxy_info.h" 17 #include "chrome/common/cloud_print/cloud_print_proxy_info.h"
17 #include "chrome/common/pref_names.h" 18 #include "chrome/common/pref_names.h"
18 #include "chrome/service/cloud_print/print_system.h" 19 #include "chrome/service/cloud_print/print_system.h"
19 #include "chrome/service/service_process.h" 20 #include "chrome/service/service_process.h"
20 #include "chrome/service/service_process_prefs.h" 21 #include "chrome/service/service_process_prefs.h"
21 #include "google_apis/gaia/gaia_oauth_client.h" 22 #include "google_apis/gaia/gaia_oauth_client.h"
22 #include "google_apis/google_api_keys.h" 23 #include "google_apis/google_api_keys.h"
23 #include "url/gurl.h" 24 #include "url/gurl.h"
24 25
25 namespace { 26 namespace {
26 27
27 void LaunchBrowserProcessWithSwitch(const std::string& switch_string) { 28 void LaunchBrowserProcessWithSwitch(const std::string& switch_string) {
28 DCHECK(g_service_process->io_thread()->message_loop_proxy()-> 29 DCHECK(g_service_process->io_thread()->message_loop_proxy()->
29 BelongsToCurrentThread()); 30 BelongsToCurrentThread());
30 base::FilePath exe_path; 31 base::FilePath exe_path;
31 PathService::Get(base::FILE_EXE, &exe_path); 32 PathService::Get(base::FILE_EXE, &exe_path);
32 if (exe_path.empty()) { 33 if (exe_path.empty()) {
33 NOTREACHED() << "Unable to get browser process binary name."; 34 NOTREACHED() << "Unable to get browser process binary name.";
34 } 35 }
35 base::CommandLine cmd_line(exe_path); 36 base::CommandLine cmd_line(exe_path);
36 37
37 const base::CommandLine& process_command_line = 38 base::FilePath user_data_dir;
grt (UTC plus 2) 2015/03/26 18:36:22 i think this is okay as-is since the launched proc
noms (inactive) 2015/03/30 14:06:32 Done.
38 *base::CommandLine::ForCurrentProcess(); 39 PathService::Get(chrome::DIR_USER_DATA, &user_data_dir);
39 base::FilePath user_data_dir =
40 process_command_line.GetSwitchValuePath(switches::kUserDataDir);
41 if (!user_data_dir.empty()) 40 if (!user_data_dir.empty())
42 cmd_line.AppendSwitchPath(switches::kUserDataDir, user_data_dir); 41 cmd_line.AppendSwitchPath(switches::kUserDataDir, user_data_dir);
43 cmd_line.AppendSwitch(switch_string); 42 cmd_line.AppendSwitch(switch_string);
44 43
45 #if defined(OS_POSIX) && !defined(OS_MACOSX) 44 #if defined(OS_POSIX) && !defined(OS_MACOSX)
46 base::Process process = base::LaunchProcess(cmd_line, base::LaunchOptions()); 45 base::Process process = base::LaunchProcess(cmd_line, base::LaunchOptions());
47 if (process.IsValid()) 46 if (process.IsValid())
48 base::EnsureProcessGetsReaped(process.Pid()); 47 base::EnsureProcessGetsReaped(process.Pid());
49 #else 48 #else
50 base::LaunchOptions launch_options; 49 base::LaunchOptions launch_options;
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 } 286 }
288 287
289 void CloudPrintProxy::ShutdownBackend() { 288 void CloudPrintProxy::ShutdownBackend() {
290 DCHECK(CalledOnValidThread()); 289 DCHECK(CalledOnValidThread());
291 if (backend_.get()) 290 if (backend_.get())
292 backend_->Shutdown(); 291 backend_->Shutdown();
293 backend_.reset(); 292 backend_.reset();
294 } 293 }
295 294
296 } // namespace cloud_print 295 } // namespace cloud_print
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698