Index: 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 57dd7b7d7652d6b6aa4763430f649d20c71d2dd4..97e277bd7bcedf2f4aaf2cdc4c1163c165164185 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); |
} |