diff options
author | jhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-29 17:44:55 +0000 |
---|---|---|
committer | jhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-29 17:44:55 +0000 |
commit | 5376eb752424af2ee0c9fa264bd2ed43326ecc7f (patch) | |
tree | 8254e803d49d0dd43da12ccbdd05a9bd6c7f9214 /chrome/browser/service | |
parent | acdf14f8f129528180621d94d4226149a4c0ac16 (diff) | |
download | chromium_src-5376eb752424af2ee0c9fa264bd2ed43326ecc7f.zip chromium_src-5376eb752424af2ee0c9fa264bd2ed43326ecc7f.tar.gz chromium_src-5376eb752424af2ee0c9fa264bd2ed43326ecc7f.tar.bz2 |
base::Bind: Finish conversion in ServiceProcessControl.
BUG=none
TEST=none
R=csilv@chromium.org
Review URL: http://codereview.chromium.org/8403023
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@107878 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/service')
-rw-r--r-- | chrome/browser/service/service_process_control.cc | 41 | ||||
-rw-r--r-- | chrome/browser/service/service_process_control.h | 10 | ||||
-rw-r--r-- | chrome/browser/service/service_process_control_mac.mm | 3 |
3 files changed, 29 insertions, 25 deletions
diff --git a/chrome/browser/service/service_process_control.cc b/chrome/browser/service/service_process_control.cc index cde6166..b3945dd 100644 --- a/chrome/browser/service/service_process_control.cc +++ b/chrome/browser/service/service_process_control.cc @@ -4,6 +4,8 @@ #include "chrome/browser/service/service_process_control.h" +#include "base/bind.h" +#include "base/bind_helpers.h" #include "base/command_line.h" #include "base/file_path.h" #include "base/process_util.h" @@ -144,8 +146,8 @@ void ServiceProcessControl::Launch(const base::Closure& success_task, // And then start the process asynchronously. launcher_ = new Launcher(this, cmd_line); - launcher_->Run( - NewRunnableMethod(this, &ServiceProcessControl::OnProcessLaunched)); + launcher_->Run(base::Bind(&ServiceProcessControl::OnProcessLaunched, + base::Unretained(this))); } void ServiceProcessControl::Disconnect() { @@ -260,29 +262,30 @@ ServiceProcessControl::Launcher::Launcher(ServiceProcessControl* process, // Execute the command line to start the process asynchronously. // After the command is executed, |task| is called with the process handle on // the UI thread. -void ServiceProcessControl::Launcher::Run(Task* task) { +void ServiceProcessControl::Launcher::Run(const base::Closure& task) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - notify_task_.reset(task); + notify_task_ = task; BrowserThread::PostTask(BrowserThread::PROCESS_LAUNCHER, FROM_HERE, - NewRunnableMethod(this, &Launcher::DoRun)); + base::Bind(&Launcher::DoRun, this)); } ServiceProcessControl::Launcher::~Launcher() {} void ServiceProcessControl::Launcher::Notify() { - DCHECK(notify_task_.get()); - notify_task_->Run(); - notify_task_.reset(); + DCHECK_EQ(false, notify_task_.is_null()); + notify_task_.Run(); + notify_task_.Reset(); } #if !defined(OS_MACOSX) void ServiceProcessControl::Launcher::DoDetectLaunched() { - DCHECK(notify_task_.get()); + DCHECK_EQ(false, notify_task_.is_null()); + const uint32 kMaxLaunchDetectRetries = 10; launched_ = CheckServiceProcessReady(); if (launched_ || (retry_count_ >= kMaxLaunchDetectRetries)) { - BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, - NewRunnableMethod(this, &Launcher::Notify)); + BrowserThread::PostTask( + BrowserThread::UI, FROM_HERE, base::Bind(&Launcher::Notify, this)); return; } retry_count_++; @@ -290,24 +293,24 @@ void ServiceProcessControl::Launcher::DoDetectLaunched() { // If the service process is not launched yet then check again in 2 seconds. const int kDetectLaunchRetry = 2000; MessageLoop::current()->PostDelayedTask( - FROM_HERE, - NewRunnableMethod(this, &Launcher::DoDetectLaunched), + FROM_HERE, base::Bind(&Launcher::DoDetectLaunched, this), kDetectLaunchRetry); } void ServiceProcessControl::Launcher::DoRun() { - DCHECK(notify_task_.get()); + DCHECK_EQ(false, notify_task_.is_null()); + base::LaunchOptions options; #if defined(OS_WIN) options.start_hidden = true; #endif if (base::LaunchProcess(*cmd_line_, options, NULL)) { - BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, - NewRunnableMethod(this, - &Launcher::DoDetectLaunched)); + BrowserThread::PostTask( + BrowserThread::IO, FROM_HERE, + base::Bind(&Launcher::DoDetectLaunched, this)); } else { - BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, - NewRunnableMethod(this, &Launcher::Notify)); + BrowserThread::PostTask( + BrowserThread::UI, FROM_HERE, base::Bind(&Launcher::Notify, this)); } } #endif // !OS_MACOSX diff --git a/chrome/browser/service/service_process_control.h b/chrome/browser/service/service_process_control.h index df04acb..483d78c 100644 --- a/chrome/browser/service/service_process_control.h +++ b/chrome/browser/service/service_process_control.h @@ -101,10 +101,10 @@ class ServiceProcessControl : public IPC::Channel::Sender, : public base::RefCountedThreadSafe<ServiceProcessControl::Launcher> { public: Launcher(ServiceProcessControl* process, CommandLine* cmd_line); - // Execute the command line to start the process asynchronously. - // After the comamnd is executed |task| is called with the process handle on - // the UI thread. - void Run(Task* task); + // Execute the command line to start the process asynchronously. After the + // command is executed |task| is called with the process handle on the UI + // thread. + void Run(const base::Closure& task); bool launched() const { return launched_; } @@ -120,7 +120,7 @@ class ServiceProcessControl : public IPC::Channel::Sender, void Notify(); ServiceProcessControl* process_; scoped_ptr<CommandLine> cmd_line_; - scoped_ptr<Task> notify_task_; + base::Closure notify_task_; bool launched_; uint32 retry_count_; }; diff --git a/chrome/browser/service/service_process_control_mac.mm b/chrome/browser/service/service_process_control_mac.mm index d11acaa..684c82f 100644 --- a/chrome/browser/service/service_process_control_mac.mm +++ b/chrome/browser/service/service_process_control_mac.mm @@ -4,6 +4,7 @@ #include "chrome/browser/service/service_process_control.h" +#include "base/bind.h" #include "base/command_line.h" #include "base/mac/scoped_cftyperef.h" #include "chrome/common/service_process_util_posix.h" @@ -21,5 +22,5 @@ void ServiceProcessControl::Launcher::DoRun() { launched_ = true; } BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, - NewRunnableMethod(this, &Launcher::Notify)); + base::Bind(&Launcher::Notify, this)); } |