Index: chrome/browser/service/service_process_control.cc |
diff --git a/chrome/browser/service/service_process_control.cc b/chrome/browser/service/service_process_control.cc |
index 97e277bd7bcedf2f4aaf2cdc4c1163c165164185..d36447a1dfcefc5f57a7931cd70676a97e616107 100644 |
--- a/chrome/browser/service/service_process_control.cc |
+++ b/chrome/browser/service/service_process_control.cc |
@@ -91,21 +91,21 @@ ServiceProcessControl::ServiceProcessControl(Profile* profile, |
ServiceProcessControl::~ServiceProcessControl() { |
} |
-void ServiceProcessControl::Connect(Task* task) { |
- DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI)); |
+void ServiceProcessControl::ConnectInternal(Task* task) { |
+ // If the channel has already been established then we run the task |
+ // and return. |
if (channel_.get()) { |
- task->Run(); |
- delete task; |
+ if (task) { |
+ task->Run(); |
+ delete task; |
+ } |
return; |
} |
- // Saves the task. |
+ // Actually going to connect. |
+ LOG(INFO) << "Connecting to Service Process IPC Server"; |
connect_done_task_.reset(task); |
- ConnectInternal(); |
-} |
-void ServiceProcessControl::ConnectInternal() { |
- LOG(INFO) << "Connecting to Service Process IPC Server"; |
// Run the IPC channel on the shared IO thread. |
base::Thread* io_thread = g_browser_process->io_thread(); |
@@ -121,11 +121,10 @@ void ServiceProcessControl::ConnectInternal() { |
void ServiceProcessControl::Launch(Task* task) { |
DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI)); |
- if (channel_.get()) { |
- if (task) { |
- task->Run(); |
- delete task; |
- } |
+ |
+ // If the service process is already running then connects to it. |
+ if (CheckServiceProcessRunning(kServiceProcessCloudPrint)) { |
+ ConnectInternal(task); |
return; |
} |
@@ -164,12 +163,9 @@ void ServiceProcessControl::Launch(Task* task) { |
void ServiceProcessControl::OnProcessLaunched(Task* task) { |
DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI)); |
if (launcher_->launched()) { |
- // Now use the launch task as the connect task. |
- connect_done_task_.reset(task); |
- |
// After we have successfully created the service process we try to connect |
// to it. The launch task is transfered to a connect task. |
- ConnectInternal(); |
+ ConnectInternal(task); |
} else if (task) { |
// If we don't have process handle that means launching the service process |
// has failed. |