diff options
author | hclam@chromium.org <hclam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-23 23:20:57 +0000 |
---|---|---|
committer | hclam@chromium.org <hclam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-23 23:20:57 +0000 |
commit | e96bf0c56566457022d20682ee278cd135d7c681 (patch) | |
tree | 16aae1f02aa4ca3948343ffb75f6010f9d1da125 /chrome/browser/service | |
parent | 4232100ca0d42e558e75a728b69abca4b28499bf (diff) | |
download | chromium_src-e96bf0c56566457022d20682ee278cd135d7c681.zip chromium_src-e96bf0c56566457022d20682ee278cd135d7c681.tar.gz chromium_src-e96bf0c56566457022d20682ee278cd135d7c681.tar.bz2 |
Resubmit r56600 - 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.
BUG=50244, 50242, 50243, 50249
Review URL: http://codereview.chromium.org/3153029
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@57120 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/service')
-rw-r--r-- | chrome/browser/service/service_process_control.cc | 19 | ||||
-rw-r--r-- | chrome/browser/service/service_process_control_manager.cc | 6 |
2 files changed, 22 insertions, 3 deletions
diff --git a/chrome/browser/service/service_process_control.cc b/chrome/browser/service/service_process_control.cc index 57dd7b7..97e277b 100644 --- a/chrome/browser/service/service_process_control.cc +++ b/chrome/browser/service/service_process_control.cc @@ -110,6 +110,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, @@ -121,8 +122,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; } @@ -148,6 +151,10 @@ void ServiceProcessControl::Launch(Task* task) { if (!logging_level.empty()) cmd_line->AppendSwitchASCII(switches::kLoggingLevel, logging_level); + if (browser_command_line.HasSwitch(switches::kWaitForDebuggerChildren)) { + cmd_line->AppendSwitch(switches::kWaitForDebugger); + } + // And then start the process asynchronously. launcher_ = new Launcher(this, cmd_line); launcher_->Run( @@ -163,7 +170,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(); @@ -184,6 +191,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(); } @@ -191,12 +200,16 @@ 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(); } bool ServiceProcessControl::Send(IPC::Message* message) { DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI)); + if (!channel_.get()) + return false; return channel_->Send(message); } diff --git a/chrome/browser/service/service_process_control_manager.cc b/chrome/browser/service/service_process_control_manager.cc index 821de9a..6c946b4 100644 --- a/chrome/browser/service/service_process_control_manager.cc +++ b/chrome/browser/service/service_process_control_manager.cc @@ -36,6 +36,12 @@ ServiceProcessControl* ServiceProcessControlManager::GetProcessControl( } void ServiceProcessControlManager::Shutdown() { + // TODO(hclam): Normally we should just delete the list but for simplicity + // we also shutdown the service processes. + for (ServiceProcessControlList::iterator i = process_control_list_.begin(); + i != process_control_list_.end(); ++i) { + (*i)->Shutdown(); + } STLDeleteElements(&process_control_list_); } |