diff options
| author | Ben Murdoch <benm@google.com> | 2010-11-18 18:32:45 +0000 |
|---|---|---|
| committer | Ben Murdoch <benm@google.com> | 2010-11-18 18:38:07 +0000 |
| commit | 513209b27ff55e2841eac0e4120199c23acce758 (patch) | |
| tree | aeba30bb08c5f47c57003544e378a377c297eee6 /chrome/browser/service/service_process_control.cc | |
| parent | 164f7496de0fbee436b385a79ead9e3cb81a50c1 (diff) | |
| download | external_chromium-513209b27ff55e2841eac0e4120199c23acce758.zip external_chromium-513209b27ff55e2841eac0e4120199c23acce758.tar.gz external_chromium-513209b27ff55e2841eac0e4120199c23acce758.tar.bz2 | |
Merge Chromium at r65505: Initial merge by git.
Change-Id: I31d8f1d8cd33caaf7f47ffa7350aef42d5fbdb45
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_; }; |
