diff options
Diffstat (limited to 'chrome/browser/service/service_process_control.cc')
| -rw-r--r-- | chrome/browser/service/service_process_control.cc | 33 |
1 files changed, 23 insertions, 10 deletions
diff --git a/chrome/browser/service/service_process_control.cc b/chrome/browser/service/service_process_control.cc index 534cc5a..74efc36 100644 --- a/chrome/browser/service/service_process_control.cc +++ b/chrome/browser/service/service_process_control.cc @@ -9,6 +9,7 @@ #include "base/process_util.h" #include "base/stl_util-inl.h" #include "base/thread.h" +#include "base/thread_restrictions.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/browser_thread.h" #include "chrome/browser/io_thread.h" @@ -38,27 +39,37 @@ class ServiceProcessControl::Launcher void Run(Task* task) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); + notify_task_.reset(task); BrowserThread::PostTask(BrowserThread::PROCESS_LAUNCHER, FROM_HERE, - NewRunnableMethod(this, &Launcher::DoRun, task)); + NewRunnableMethod(this, &Launcher::DoRun)); } bool launched() const { return launched_; } private: - void DoRun(Task* task) { + void DoRun() { + DCHECK(notify_task_.get()); base::LaunchApp(*cmd_line_.get(), false, true, NULL); BrowserThread::PostTask( BrowserThread::IO, FROM_HERE, - NewRunnableMethod(this, &Launcher::DoDetectLaunched, task)); + NewRunnableMethod(this, &Launcher::DoDetectLaunched)); } - void DoDetectLaunched(Task* task) { + void DoDetectLaunched() { + DCHECK(notify_task_.get()); const uint32 kMaxLaunchDetectRetries = 10; - launched_ = CheckServiceProcessReady(); + { + // We should not be doing blocking disk IO from this thread! + // Temporarily allowed until we fix + // http://code.google.com/p/chromium/issues/detail?id=60207 + base::ThreadRestrictions::ScopedAllowIO allow_io; + launched_ = CheckServiceProcessReady(); + } + if (launched_ || (retry_count_ >= kMaxLaunchDetectRetries)) { BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, - NewRunnableMethod(this, &Launcher::Notify, task)); + NewRunnableMethod(this, &Launcher::Notify)); return; } retry_count_++; @@ -66,17 +77,19 @@ class ServiceProcessControl::Launcher const int kDetectLaunchRetry = 2000; MessageLoop::current()->PostDelayedTask( FROM_HERE, - NewRunnableMethod(this, &Launcher::DoDetectLaunched, task), + NewRunnableMethod(this, &Launcher::DoDetectLaunched), kDetectLaunchRetry); } - void Notify(Task* task) { - task->Run(); - delete task; + void Notify() { + DCHECK(notify_task_.get()); + notify_task_->Run(); + notify_task_.reset(); } ServiceProcessControl* process_; scoped_ptr<CommandLine> cmd_line_; + scoped_ptr<Task> notify_task_; bool launched_; uint32 retry_count_; }; |
