Chromium Code Reviews| Index: content/browser/renderer_host/render_process_host_impl.cc |
| diff --git a/content/browser/renderer_host/render_process_host_impl.cc b/content/browser/renderer_host/render_process_host_impl.cc |
| index 2c00dff52930b46a7a7747b3508974658d066e34..aad0cd4e760693aa44baa5bf68f5d40822828d81 100644 |
| --- a/content/browser/renderer_host/render_process_host_impl.cc |
| +++ b/content/browser/renderer_host/render_process_host_impl.cc |
| @@ -1483,6 +1483,11 @@ base::ProcessHandle RenderProcessHostImpl::GetHandle() const { |
| return child_process_launcher_->GetProcess().Handle(); |
| } |
| +bool RenderProcessHostImpl::IsReady() const { |
|
ncarter (slow)
2015/09/29 18:28:40
It might be worthwhile to add a comment here to po
piman
2015/09/29 23:54:27
Done.
|
| + return GetHandle() && channel_ && |
| + (channel_->GetPeerPID() != base::kNullProcessId); |
| +} |
| + |
| bool RenderProcessHostImpl::Shutdown(int exit_code, bool wait) { |
| if (run_renderer_in_process()) |
| return false; // Single process mode never shuts down the renderer. |
| @@ -1602,6 +1607,13 @@ bool RenderProcessHostImpl::OnMessageReceived(const IPC::Message& msg) { |
| } |
| void RenderProcessHostImpl::OnChannelConnected(int32 peer_pid) { |
| + if (IsReady()) { |
| + // Send RenderProcessReady only if we already received the process handle. |
| + FOR_EACH_OBSERVER(RenderProcessHostObserver, |
| + observers_, |
| + RenderProcessReady(this)); |
| + } |
| + |
| #if defined(IPC_MESSAGE_LOG_ENABLED) |
| Send(new ChildProcessMsg_SetIPCLoggingEnabled( |
| IPC::Logging::GetInstance()->Enabled())); |
| @@ -2404,6 +2416,13 @@ void RenderProcessHostImpl::OnProcessLaunched() { |
| queued_messages_.pop(); |
| } |
| + if (IsReady()) { |
| + // Send RenderProcessReady only if the channel is already connected. |
| + FOR_EACH_OBSERVER(RenderProcessHostObserver, |
| + observers_, |
| + RenderProcessReady(this)); |
|
ncarter (slow)
2015/09/29 18:28:40
The intent here, right, is to call RenderProcessRe
piman
2015/09/29 23:54:27
Right, the contract is, RenderProcessReady is only
ncarter (slow)
2015/09/30 20:30:33
I think I had it somewhat backwards, but the behav
|
| + } |
|
ncarter (slow)
2015/09/29 18:28:40
I like how this operates, but I'm wondering if we
piman
2015/09/29 23:54:27
I added a DCHECK. I'm fairly confident that we cal
ncarter (slow)
2015/09/30 20:30:33
Great. I'm confident that it's correct now, but I
|
| + |
|
ncarter (slow)
2015/09/29 18:28:40
FYI: an alternative approach discussed in bug 4849
piman
2015/09/29 23:54:27
I believe GetHandle and channel_->GetPeerPid retur
ncarter (slow)
2015/09/30 20:30:33
You definitely can go pid->handle on Windows, but
|
| #if defined(ENABLE_WEBRTC) |
| // TODO(erikchen): Remove ScopedTracker below once http://crbug.com/465841 |
| // is fixed. |