| 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 1172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1183 synchronous_compositor_filter_ = | 1183 synchronous_compositor_filter_ = |
| 1184 new SynchronousCompositorBrowserFilter(GetID()); | 1184 new SynchronousCompositorBrowserFilter(GetID()); |
| 1185 AddFilter(synchronous_compositor_filter_.get()); | 1185 AddFilter(synchronous_compositor_filter_.get()); |
| 1186 #endif | 1186 #endif |
| 1187 } | 1187 } |
| 1188 | 1188 |
| 1189 void RenderProcessHostImpl::RegisterMojoInterfaces() { | 1189 void RenderProcessHostImpl::RegisterMojoInterfaces() { |
| 1190 auto registry = base::MakeUnique<service_manager::InterfaceRegistry>( | 1190 auto registry = base::MakeUnique<service_manager::InterfaceRegistry>( |
| 1191 service_manager::mojom::kServiceManager_ConnectorSpec); | 1191 service_manager::mojom::kServiceManager_ConnectorSpec); |
| 1192 | 1192 |
| 1193 channel_->AddAssociatedInterface( | |
| 1194 base::Bind(&RenderProcessHostImpl::OnRouteProviderRequest, | |
| 1195 base::Unretained(this))); | |
| 1196 | |
| 1197 channel_->AddAssociatedInterfaceForIOThread( | 1193 channel_->AddAssociatedInterfaceForIOThread( |
| 1198 base::Bind(&IndexedDBDispatcherHost::AddBinding, indexed_db_factory_)); | 1194 base::Bind(&IndexedDBDispatcherHost::AddBinding, indexed_db_factory_)); |
| 1199 | 1195 |
| 1200 #if defined(OS_ANDROID) | 1196 #if defined(OS_ANDROID) |
| 1201 AddUIThreadInterface(registry.get(), | 1197 AddUIThreadInterface(registry.get(), |
| 1202 GetGlobalJavaInterfaces() | 1198 GetGlobalJavaInterfaces() |
| 1203 ->CreateInterfaceFactory<device::BatteryMonitor>()); | 1199 ->CreateInterfaceFactory<device::BatteryMonitor>()); |
| 1204 #else | 1200 #else |
| 1205 AddUIThreadInterface( | 1201 AddUIThreadInterface( |
| 1206 registry.get(), base::Bind(&device::BatteryMonitorImpl::Create)); | 1202 registry.get(), base::Bind(&device::BatteryMonitorImpl::Create)); |
| (...skipping 836 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2043 // hang waiting for a reply. | 2039 // hang waiting for a reply. |
| 2044 IPC::Message* reply = IPC::SyncMessage::GenerateReply(&msg); | 2040 IPC::Message* reply = IPC::SyncMessage::GenerateReply(&msg); |
| 2045 reply->set_reply_error(); | 2041 reply->set_reply_error(); |
| 2046 Send(reply); | 2042 Send(reply); |
| 2047 } | 2043 } |
| 2048 return true; | 2044 return true; |
| 2049 } | 2045 } |
| 2050 return listener->OnMessageReceived(msg); | 2046 return listener->OnMessageReceived(msg); |
| 2051 } | 2047 } |
| 2052 | 2048 |
| 2049 void RenderProcessHostImpl::OnAssociatedInterfaceRequest( |
| 2050 const std::string& interface_name, |
| 2051 mojo::ScopedInterfaceEndpointHandle handle) { |
| 2052 if (interface_name == mojom::RouteProvider::Name_) { |
| 2053 if (route_provider_binding_.is_bound()) |
| 2054 return; |
| 2055 mojom::RouteProviderAssociatedRequest request; |
| 2056 request.Bind(std::move(handle)); |
| 2057 route_provider_binding_.Bind(std::move(request)); |
| 2058 } else { |
| 2059 LOG(ERROR) << "Request for unknown Channel-associated interface: " |
| 2060 << interface_name; |
| 2061 } |
| 2062 } |
| 2063 |
| 2053 void RenderProcessHostImpl::OnChannelConnected(int32_t peer_pid) { | 2064 void RenderProcessHostImpl::OnChannelConnected(int32_t peer_pid) { |
| 2054 channel_connected_ = true; | 2065 channel_connected_ = true; |
| 2055 if (IsReady()) { | 2066 if (IsReady()) { |
| 2056 DCHECK(!sent_render_process_ready_); | 2067 DCHECK(!sent_render_process_ready_); |
| 2057 sent_render_process_ready_ = true; | 2068 sent_render_process_ready_ = true; |
| 2058 // Send RenderProcessReady only if we already received the process handle. | 2069 // Send RenderProcessReady only if we already received the process handle. |
| 2059 for (auto& observer : observers_) | 2070 for (auto& observer : observers_) |
| 2060 observer.RenderProcessReady(this); | 2071 observer.RenderProcessReady(this); |
| 2061 } | 2072 } |
| 2062 | 2073 |
| (...skipping 568 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2631 metrics_allocator_.reset(new base::SharedPersistentMemoryAllocator( | 2642 metrics_allocator_.reset(new base::SharedPersistentMemoryAllocator( |
| 2632 std::move(shm), GetID(), "RendererMetrics", /*readonly=*/false)); | 2643 std::move(shm), GetID(), "RendererMetrics", /*readonly=*/false)); |
| 2633 } | 2644 } |
| 2634 | 2645 |
| 2635 base::SharedMemoryHandle shm_handle; | 2646 base::SharedMemoryHandle shm_handle; |
| 2636 metrics_allocator_->shared_memory()->ShareToProcess(destination, &shm_handle); | 2647 metrics_allocator_->shared_memory()->ShareToProcess(destination, &shm_handle); |
| 2637 Send(new ChildProcessMsg_SetHistogramMemory( | 2648 Send(new ChildProcessMsg_SetHistogramMemory( |
| 2638 shm_handle, metrics_allocator_->shared_memory()->mapped_size())); | 2649 shm_handle, metrics_allocator_->shared_memory()->mapped_size())); |
| 2639 } | 2650 } |
| 2640 | 2651 |
| 2641 void RenderProcessHostImpl::OnRouteProviderRequest( | |
| 2642 mojom::RouteProviderAssociatedRequest request) { | |
| 2643 if (route_provider_binding_.is_bound()) | |
| 2644 return; | |
| 2645 route_provider_binding_.Bind(std::move(request)); | |
| 2646 } | |
| 2647 | |
| 2648 void RenderProcessHostImpl::ProcessDied(bool already_dead, | 2652 void RenderProcessHostImpl::ProcessDied(bool already_dead, |
| 2649 RendererClosedDetails* known_details) { | 2653 RendererClosedDetails* known_details) { |
| 2650 // Our child process has died. If we didn't expect it, it's a crash. | 2654 // Our child process has died. If we didn't expect it, it's a crash. |
| 2651 // In any case, we need to let everyone know it's gone. | 2655 // In any case, we need to let everyone know it's gone. |
| 2652 // The OnChannelError notification can fire multiple times due to nested sync | 2656 // The OnChannelError notification can fire multiple times due to nested sync |
| 2653 // calls to a renderer. If we don't have a valid channel here it means we | 2657 // calls to a renderer. If we don't have a valid channel here it means we |
| 2654 // already handled the error. | 2658 // already handled the error. |
| 2655 | 2659 |
| 2656 // It should not be possible for us to be called re-entrantly. | 2660 // It should not be possible for us to be called re-entrantly. |
| 2657 DCHECK(!within_process_died_observer_); | 2661 DCHECK(!within_process_died_observer_); |
| (...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3026 LOG(ERROR) << "Terminating render process for bad Mojo message: " << error; | 3030 LOG(ERROR) << "Terminating render process for bad Mojo message: " << error; |
| 3027 | 3031 |
| 3028 // The ReceivedBadMessage call below will trigger a DumpWithoutCrashing. | 3032 // The ReceivedBadMessage call below will trigger a DumpWithoutCrashing. |
| 3029 // Capture the error message in a crash key value. | 3033 // Capture the error message in a crash key value. |
| 3030 base::debug::ScopedCrashKey error_key_value("mojo-message-error", error); | 3034 base::debug::ScopedCrashKey error_key_value("mojo-message-error", error); |
| 3031 bad_message::ReceivedBadMessage(render_process_id, | 3035 bad_message::ReceivedBadMessage(render_process_id, |
| 3032 bad_message::RPH_MOJO_PROCESS_ERROR); | 3036 bad_message::RPH_MOJO_PROCESS_ERROR); |
| 3033 } | 3037 } |
| 3034 | 3038 |
| 3035 } // namespace content | 3039 } // namespace content |
| OLD | NEW |