From e57d57b67290c8dfd701ac5021264a9ae1588b81 Mon Sep 17 00:00:00 2001 From: "hclam@chromium.org" Date: Wed, 18 Aug 2010 21:04:49 +0000 Subject: Start/stop service process when browser starts and stop Save the information that the setup of remoting has completed. After setup has been completed we start and stop service process when --enable-remoting presents when browser starts. Also save the information in the service process that host is registered and ready to be used. Again start chromoting host automatically once the host registration is done. Review URL: http://codereview.chromium.org/3185015 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@56600 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/browser/service/service_process_control.cc | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to '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 9b76dc7..5979084 100644 --- a/chrome/browser/service/service_process_control.cc +++ b/chrome/browser/service/service_process_control.cc @@ -109,6 +109,7 @@ void ServiceProcessControl::ConnectInternal() { base::Thread* io_thread = g_browser_process->io_thread(); // TODO(hclam): Determine the the channel id from profile and type. + // TODO(hclam): Handle error connecting to channel. const std::string channel_id = GetServiceProcessChannelName(type_); channel_.reset( new IPC::SyncChannel(channel_id, IPC::Channel::MODE_CLIENT, this, NULL, @@ -120,8 +121,10 @@ void ServiceProcessControl::ConnectInternal() { void ServiceProcessControl::Launch(Task* task) { DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI)); if (channel_.get()) { - task->Run(); - delete task; + if (task) { + task->Run(); + delete task; + } return; } @@ -162,7 +165,7 @@ void ServiceProcessControl::OnProcessLaunched(Task* 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(); - } else { + } else if (task) { // If we don't have process handle that means launching the service process // has failed. task->Run(); @@ -183,6 +186,8 @@ void ServiceProcessControl::OnMessageReceived(const IPC::Message& message) { void ServiceProcessControl::OnChannelConnected(int32 peer_pid) { DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI)); + if (!connect_done_task_.get()) + return; connect_done_task_->Run(); connect_done_task_.reset(); } @@ -190,6 +195,8 @@ void ServiceProcessControl::OnChannelConnected(int32 peer_pid) { void ServiceProcessControl::OnChannelError() { DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI)); channel_.reset(); + if (!connect_done_task_.get()) + return; connect_done_task_->Run(); connect_done_task_.reset(); } -- cgit v1.1