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

Unified Diff: chrome/browser/service/service_process_control.cc

Issue 3306001: Don't launch service process if it's already running (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: removed code Created 10 years, 4 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 side-by-side diff with in-line comments
Download patch
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.
« no previous file with comments | « chrome/browser/service/service_process_control.h ('k') | chrome/browser/service/service_process_control_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698