Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Represents the browser side of the browser <--> renderer communication | 5 // Represents the browser side of the browser <--> renderer communication |
| 6 // channel. There will be one RenderProcessHost per renderer process. | 6 // channel. There will be one RenderProcessHost per renderer process. |
| 7 | 7 |
| 8 #include "content/browser/renderer_host/render_process_host_impl.h" | 8 #include "content/browser/renderer_host/render_process_host_impl.h" |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 1465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1476 base::ProcessHandle RenderProcessHostImpl::GetHandle() const { | 1476 base::ProcessHandle RenderProcessHostImpl::GetHandle() const { |
| 1477 if (run_renderer_in_process()) | 1477 if (run_renderer_in_process()) |
| 1478 return base::GetCurrentProcessHandle(); | 1478 return base::GetCurrentProcessHandle(); |
| 1479 | 1479 |
| 1480 if (!child_process_launcher_.get() || child_process_launcher_->IsStarting()) | 1480 if (!child_process_launcher_.get() || child_process_launcher_->IsStarting()) |
| 1481 return base::kNullProcessHandle; | 1481 return base::kNullProcessHandle; |
| 1482 | 1482 |
| 1483 return child_process_launcher_->GetProcess().Handle(); | 1483 return child_process_launcher_->GetProcess().Handle(); |
| 1484 } | 1484 } |
| 1485 | 1485 |
| 1486 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.
| |
| 1487 return GetHandle() && channel_ && | |
| 1488 (channel_->GetPeerPID() != base::kNullProcessId); | |
| 1489 } | |
| 1490 | |
| 1486 bool RenderProcessHostImpl::Shutdown(int exit_code, bool wait) { | 1491 bool RenderProcessHostImpl::Shutdown(int exit_code, bool wait) { |
| 1487 if (run_renderer_in_process()) | 1492 if (run_renderer_in_process()) |
| 1488 return false; // Single process mode never shuts down the renderer. | 1493 return false; // Single process mode never shuts down the renderer. |
| 1489 | 1494 |
| 1490 #if defined(OS_ANDROID) | 1495 #if defined(OS_ANDROID) |
| 1491 // Android requires a different approach for killing. | 1496 // Android requires a different approach for killing. |
| 1492 StopChildProcess(GetHandle()); | 1497 StopChildProcess(GetHandle()); |
| 1493 return true; | 1498 return true; |
| 1494 #else | 1499 #else |
| 1495 if (!child_process_launcher_.get() || child_process_launcher_->IsStarting()) | 1500 if (!child_process_launcher_.get() || child_process_launcher_->IsStarting()) |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1595 IPC::Message* reply = IPC::SyncMessage::GenerateReply(&msg); | 1600 IPC::Message* reply = IPC::SyncMessage::GenerateReply(&msg); |
| 1596 reply->set_reply_error(); | 1601 reply->set_reply_error(); |
| 1597 Send(reply); | 1602 Send(reply); |
| 1598 } | 1603 } |
| 1599 return true; | 1604 return true; |
| 1600 } | 1605 } |
| 1601 return listener->OnMessageReceived(msg); | 1606 return listener->OnMessageReceived(msg); |
| 1602 } | 1607 } |
| 1603 | 1608 |
| 1604 void RenderProcessHostImpl::OnChannelConnected(int32 peer_pid) { | 1609 void RenderProcessHostImpl::OnChannelConnected(int32 peer_pid) { |
| 1610 if (IsReady()) { | |
| 1611 // Send RenderProcessReady only if we already received the process handle. | |
| 1612 FOR_EACH_OBSERVER(RenderProcessHostObserver, | |
| 1613 observers_, | |
| 1614 RenderProcessReady(this)); | |
| 1615 } | |
| 1616 | |
| 1605 #if defined(IPC_MESSAGE_LOG_ENABLED) | 1617 #if defined(IPC_MESSAGE_LOG_ENABLED) |
| 1606 Send(new ChildProcessMsg_SetIPCLoggingEnabled( | 1618 Send(new ChildProcessMsg_SetIPCLoggingEnabled( |
| 1607 IPC::Logging::GetInstance()->Enabled())); | 1619 IPC::Logging::GetInstance()->Enabled())); |
| 1608 #endif | 1620 #endif |
| 1609 | 1621 |
| 1610 tracked_objects::ThreadData::Status status = | 1622 tracked_objects::ThreadData::Status status = |
| 1611 tracked_objects::ThreadData::status(); | 1623 tracked_objects::ThreadData::status(); |
| 1612 Send(new ChildProcessMsg_SetProfilerStatus(status)); | 1624 Send(new ChildProcessMsg_SetProfilerStatus(status)); |
| 1613 | 1625 |
| 1614 #if defined(OS_MACOSX) && !defined(OS_IOS) | 1626 #if defined(OS_MACOSX) && !defined(OS_IOS) |
| (...skipping 782 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2397 // is fixed. | 2409 // is fixed. |
| 2398 tracked_objects::ScopedTracker tracking_profile6( | 2410 tracked_objects::ScopedTracker tracking_profile6( |
| 2399 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 2411 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 2400 "465841 " | 2412 "465841 " |
| 2401 "RenderProcessHostImpl::OnProcessLaunched::SendQueuedMessages")); | 2413 "RenderProcessHostImpl::OnProcessLaunched::SendQueuedMessages")); |
| 2402 while (!queued_messages_.empty()) { | 2414 while (!queued_messages_.empty()) { |
| 2403 Send(queued_messages_.front()); | 2415 Send(queued_messages_.front()); |
| 2404 queued_messages_.pop(); | 2416 queued_messages_.pop(); |
| 2405 } | 2417 } |
| 2406 | 2418 |
| 2419 if (IsReady()) { | |
| 2420 // Send RenderProcessReady only if the channel is already connected. | |
| 2421 FOR_EACH_OBSERVER(RenderProcessHostObserver, | |
| 2422 observers_, | |
| 2423 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
| |
| 2424 } | |
|
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
| |
| 2425 | |
|
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
| |
| 2407 #if defined(ENABLE_WEBRTC) | 2426 #if defined(ENABLE_WEBRTC) |
| 2408 // TODO(erikchen): Remove ScopedTracker below once http://crbug.com/465841 | 2427 // TODO(erikchen): Remove ScopedTracker below once http://crbug.com/465841 |
| 2409 // is fixed. | 2428 // is fixed. |
| 2410 tracked_objects::ScopedTracker tracking_profile7( | 2429 tracked_objects::ScopedTracker tracking_profile7( |
| 2411 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 2430 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 2412 "465841 RenderProcessHostImpl::OnProcessLaunched::EnableAec")); | 2431 "465841 RenderProcessHostImpl::OnProcessLaunched::EnableAec")); |
| 2413 if (WebRTCInternals::GetInstance()->IsAudioDebugRecordingsEnabled()) { | 2432 if (WebRTCInternals::GetInstance()->IsAudioDebugRecordingsEnabled()) { |
| 2414 EnableAudioDebugRecordings( | 2433 EnableAudioDebugRecordings( |
| 2415 WebRTCInternals::GetInstance()->GetAudioDebugRecordingsFilePath()); | 2434 WebRTCInternals::GetInstance()->GetAudioDebugRecordingsFilePath()); |
| 2416 } | 2435 } |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2562 void RenderProcessHostImpl::GetAudioOutputControllers( | 2581 void RenderProcessHostImpl::GetAudioOutputControllers( |
| 2563 const GetAudioOutputControllersCallback& callback) const { | 2582 const GetAudioOutputControllersCallback& callback) const { |
| 2564 audio_renderer_host()->GetOutputControllers(callback); | 2583 audio_renderer_host()->GetOutputControllers(callback); |
| 2565 } | 2584 } |
| 2566 | 2585 |
| 2567 BluetoothDispatcherHost* RenderProcessHostImpl::GetBluetoothDispatcherHost() { | 2586 BluetoothDispatcherHost* RenderProcessHostImpl::GetBluetoothDispatcherHost() { |
| 2568 return bluetooth_dispatcher_host_.get(); | 2587 return bluetooth_dispatcher_host_.get(); |
| 2569 } | 2588 } |
| 2570 | 2589 |
| 2571 } // namespace content | 2590 } // namespace content |
| OLD | NEW |