| OLD | NEW |
| 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/browser/service_process/service_process_control.h" | 5 #include "chrome/browser/service_process/service_process_control.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 if (CheckServiceProcessReady()) { | 107 if (CheckServiceProcessReady()) { |
| 108 ConnectInternal(); | 108 ConnectInternal(); |
| 109 return; | 109 return; |
| 110 } | 110 } |
| 111 | 111 |
| 112 UMA_HISTOGRAM_ENUMERATION("CloudPrint.ServiceEvents", SERVICE_EVENT_LAUNCH, | 112 UMA_HISTOGRAM_ENUMERATION("CloudPrint.ServiceEvents", SERVICE_EVENT_LAUNCH, |
| 113 SERVICE_EVENT_MAX); | 113 SERVICE_EVENT_MAX); |
| 114 | 114 |
| 115 scoped_ptr<base::CommandLine> cmd_line(CreateServiceProcessCommandLine()); | 115 scoped_ptr<base::CommandLine> cmd_line(CreateServiceProcessCommandLine()); |
| 116 // And then start the process asynchronously. | 116 // And then start the process asynchronously. |
| 117 launcher_ = new Launcher(this, cmd_line.Pass()); | 117 launcher_ = new Launcher(cmd_line.Pass()); |
| 118 launcher_->Run(base::Bind(&ServiceProcessControl::OnProcessLaunched, | 118 launcher_->Run(base::Bind(&ServiceProcessControl::OnProcessLaunched, |
| 119 base::Unretained(this))); | 119 base::Unretained(this))); |
| 120 } | 120 } |
| 121 | 121 |
| 122 void ServiceProcessControl::Disconnect() { | 122 void ServiceProcessControl::Disconnect() { |
| 123 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 123 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 124 channel_.reset(); | 124 channel_.reset(); |
| 125 } | 125 } |
| 126 | 126 |
| 127 void ServiceProcessControl::OnProcessLaunched() { | 127 void ServiceProcessControl::OnProcessLaunched() { |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 311 channel_.reset(); | 311 channel_.reset(); |
| 312 return ret; | 312 return ret; |
| 313 } | 313 } |
| 314 | 314 |
| 315 // static | 315 // static |
| 316 ServiceProcessControl* ServiceProcessControl::GetInstance() { | 316 ServiceProcessControl* ServiceProcessControl::GetInstance() { |
| 317 return Singleton<ServiceProcessControl>::get(); | 317 return Singleton<ServiceProcessControl>::get(); |
| 318 } | 318 } |
| 319 | 319 |
| 320 ServiceProcessControl::Launcher::Launcher( | 320 ServiceProcessControl::Launcher::Launcher( |
| 321 ServiceProcessControl* process, | |
| 322 scoped_ptr<base::CommandLine> cmd_line) | 321 scoped_ptr<base::CommandLine> cmd_line) |
| 323 : process_control_(process), | 322 : cmd_line_(cmd_line.Pass()), |
| 324 cmd_line_(cmd_line.Pass()), | |
| 325 launched_(false), | 323 launched_(false), |
| 326 retry_count_(0) { | 324 retry_count_(0) { |
| 327 } | 325 } |
| 328 | 326 |
| 329 // Execute the command line to start the process asynchronously. | 327 // Execute the command line to start the process asynchronously. |
| 330 // After the command is executed, |task| is called with the process handle on | 328 // After the command is executed, |task| is called with the process handle on |
| 331 // the UI thread. | 329 // the UI thread. |
| 332 void ServiceProcessControl::Launcher::Run(const base::Closure& task) { | 330 void ServiceProcessControl::Launcher::Run(const base::Closure& task) { |
| 333 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 331 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 334 notify_task_ = task; | 332 notify_task_ = task; |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 381 if (process_.IsValid()) { | 379 if (process_.IsValid()) { |
| 382 BrowserThread::PostTask( | 380 BrowserThread::PostTask( |
| 383 BrowserThread::IO, FROM_HERE, | 381 BrowserThread::IO, FROM_HERE, |
| 384 base::Bind(&Launcher::DoDetectLaunched, this)); | 382 base::Bind(&Launcher::DoDetectLaunched, this)); |
| 385 } else { | 383 } else { |
| 386 BrowserThread::PostTask( | 384 BrowserThread::PostTask( |
| 387 BrowserThread::UI, FROM_HERE, base::Bind(&Launcher::Notify, this)); | 385 BrowserThread::UI, FROM_HERE, base::Bind(&Launcher::Notify, this)); |
| 388 } | 386 } |
| 389 } | 387 } |
| 390 #endif // !OS_MACOSX | 388 #endif // !OS_MACOSX |
| OLD | NEW |