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 1340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1351 | 1351 |
1352 AddUIThreadInterface(registry.get(), base::Bind(&FieldTrialRecorder::Create)); | 1352 AddUIThreadInterface(registry.get(), base::Bind(&FieldTrialRecorder::Create)); |
1353 | 1353 |
1354 AddUIThreadInterface( | 1354 AddUIThreadInterface( |
1355 registry.get(), | 1355 registry.get(), |
1356 base::Bind( | 1356 base::Bind( |
1357 &memory_instrumentation::CoordinatorImpl::BindCoordinatorRequest, | 1357 &memory_instrumentation::CoordinatorImpl::BindCoordinatorRequest, |
1358 base::Unretained( | 1358 base::Unretained( |
1359 memory_instrumentation::CoordinatorImpl::GetInstance()))); | 1359 memory_instrumentation::CoordinatorImpl::GetInstance()))); |
1360 | 1360 |
1361 GetContentClient()->browser()->ExposeInterfacesToRenderer(registry.get(), | 1361 associated_interfaces_.reset(new AssociatedInterfaceRegistryImpl()); |
1362 this); | 1362 GetContentClient()->browser()->ExposeInterfacesToRenderer( |
| 1363 registry.get(), associated_interfaces_.get(), this); |
| 1364 static_cast<AssociatedInterfaceRegistry*>(associated_interfaces_.get()) |
| 1365 ->AddInterface(base::Bind(&RenderProcessHostImpl::BindRouteProvider, |
| 1366 base::Unretained(this))); |
1363 | 1367 |
1364 ServiceManagerConnection* service_manager_connection = | 1368 ServiceManagerConnection* service_manager_connection = |
1365 BrowserContext::GetServiceManagerConnectionFor(browser_context_); | 1369 BrowserContext::GetServiceManagerConnectionFor(browser_context_); |
1366 std::unique_ptr<ConnectionFilterImpl> connection_filter( | 1370 std::unique_ptr<ConnectionFilterImpl> connection_filter( |
1367 new ConnectionFilterImpl(child_connection_->child_identity(), | 1371 new ConnectionFilterImpl(child_connection_->child_identity(), |
1368 std::move(registry))); | 1372 std::move(registry))); |
1369 connection_filter_controller_ = connection_filter->controller(); | 1373 connection_filter_controller_ = connection_filter->controller(); |
1370 connection_filter_id_ = service_manager_connection->AddConnectionFilter( | 1374 connection_filter_id_ = service_manager_connection->AddConnectionFilter( |
1371 std::move(connection_filter)); | 1375 std::move(connection_filter)); |
1372 } | 1376 } |
1373 | 1377 |
| 1378 void RenderProcessHostImpl::BindRouteProvider( |
| 1379 mojom::RouteProviderAssociatedRequest request) { |
| 1380 if (route_provider_binding_.is_bound()) |
| 1381 return; |
| 1382 route_provider_binding_.Bind(std::move(request)); |
| 1383 } |
| 1384 |
1374 void RenderProcessHostImpl::GetRoute( | 1385 void RenderProcessHostImpl::GetRoute( |
1375 int32_t routing_id, | 1386 int32_t routing_id, |
1376 mojom::AssociatedInterfaceProviderAssociatedRequest request) { | 1387 mojom::AssociatedInterfaceProviderAssociatedRequest request) { |
1377 DCHECK(request.is_pending()); | 1388 DCHECK(request.is_pending()); |
1378 associated_interface_provider_bindings_.AddBinding( | 1389 associated_interface_provider_bindings_.AddBinding( |
1379 this, std::move(request), routing_id); | 1390 this, std::move(request), routing_id); |
1380 } | 1391 } |
1381 | 1392 |
1382 void RenderProcessHostImpl::GetAssociatedInterface( | 1393 void RenderProcessHostImpl::GetAssociatedInterface( |
1383 const std::string& name, | 1394 const std::string& name, |
(...skipping 729 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2113 Send(reply); | 2124 Send(reply); |
2114 } | 2125 } |
2115 return true; | 2126 return true; |
2116 } | 2127 } |
2117 return listener->OnMessageReceived(msg); | 2128 return listener->OnMessageReceived(msg); |
2118 } | 2129 } |
2119 | 2130 |
2120 void RenderProcessHostImpl::OnAssociatedInterfaceRequest( | 2131 void RenderProcessHostImpl::OnAssociatedInterfaceRequest( |
2121 const std::string& interface_name, | 2132 const std::string& interface_name, |
2122 mojo::ScopedInterfaceEndpointHandle handle) { | 2133 mojo::ScopedInterfaceEndpointHandle handle) { |
2123 if (interface_name == mojom::RouteProvider::Name_) { | 2134 if (associated_interfaces_ && |
2124 if (route_provider_binding_.is_bound()) | 2135 associated_interfaces_->CanBindRequest(interface_name)) { |
2125 return; | 2136 associated_interfaces_->BindRequest(interface_name, std::move(handle)); |
2126 mojom::RouteProviderAssociatedRequest request; | |
2127 request.Bind(std::move(handle)); | |
2128 route_provider_binding_.Bind(std::move(request)); | |
2129 } else { | 2137 } else { |
2130 LOG(ERROR) << "Request for unknown Channel-associated interface: " | 2138 LOG(ERROR) << "Request for unknown Channel-associated interface: " |
2131 << interface_name; | 2139 << interface_name; |
2132 } | 2140 } |
2133 } | 2141 } |
2134 | 2142 |
2135 void RenderProcessHostImpl::OnChannelConnected(int32_t peer_pid) { | 2143 void RenderProcessHostImpl::OnChannelConnected(int32_t peer_pid) { |
2136 channel_connected_ = true; | 2144 channel_connected_ = true; |
2137 if (IsReady()) { | 2145 if (IsReady()) { |
2138 DCHECK(!sent_render_process_ready_); | 2146 DCHECK(!sent_render_process_ready_); |
(...skipping 639 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2778 status = base::TERMINATION_STATUS_PROCESS_CRASHED; | 2786 status = base::TERMINATION_STATUS_PROCESS_CRASHED; |
2779 } | 2787 } |
2780 } | 2788 } |
2781 | 2789 |
2782 RendererClosedDetails details(status, exit_code); | 2790 RendererClosedDetails details(status, exit_code); |
2783 | 2791 |
2784 child_process_launcher_.reset(); | 2792 child_process_launcher_.reset(); |
2785 is_dead_ = true; | 2793 is_dead_ = true; |
2786 if (route_provider_binding_.is_bound()) | 2794 if (route_provider_binding_.is_bound()) |
2787 route_provider_binding_.Close(); | 2795 route_provider_binding_.Close(); |
| 2796 associated_interfaces_.reset(); |
2788 ResetChannelProxy(); | 2797 ResetChannelProxy(); |
2789 | 2798 |
2790 UpdateProcessPriority(); | 2799 UpdateProcessPriority(); |
2791 DCHECK(!is_process_backgrounded_); | 2800 DCHECK(!is_process_backgrounded_); |
2792 | 2801 |
2793 within_process_died_observer_ = true; | 2802 within_process_died_observer_ = true; |
2794 NotificationService::current()->Notify( | 2803 NotificationService::current()->Notify( |
2795 NOTIFICATION_RENDERER_PROCESS_CLOSED, Source<RenderProcessHost>(this), | 2804 NOTIFICATION_RENDERER_PROCESS_CLOSED, Source<RenderProcessHost>(this), |
2796 Details<RendererClosedDetails>(&details)); | 2805 Details<RendererClosedDetails>(&details)); |
2797 for (auto& observer : observers_) | 2806 for (auto& observer : observers_) |
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3121 LOG(ERROR) << "Terminating render process for bad Mojo message: " << error; | 3130 LOG(ERROR) << "Terminating render process for bad Mojo message: " << error; |
3122 | 3131 |
3123 // The ReceivedBadMessage call below will trigger a DumpWithoutCrashing. | 3132 // The ReceivedBadMessage call below will trigger a DumpWithoutCrashing. |
3124 // Capture the error message in a crash key value. | 3133 // Capture the error message in a crash key value. |
3125 base::debug::ScopedCrashKey error_key_value("mojo-message-error", error); | 3134 base::debug::ScopedCrashKey error_key_value("mojo-message-error", error); |
3126 bad_message::ReceivedBadMessage(render_process_id, | 3135 bad_message::ReceivedBadMessage(render_process_id, |
3127 bad_message::RPH_MOJO_PROCESS_ERROR); | 3136 bad_message::RPH_MOJO_PROCESS_ERROR); |
3128 } | 3137 } |
3129 | 3138 |
3130 } // namespace content | 3139 } // namespace content |
OLD | NEW |