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 1301 matching lines...) Loading... | |
1312 | 1312 |
1313 AddUIThreadInterface(registry.get(), base::Bind(&FieldTrialRecorder::Create)); | 1313 AddUIThreadInterface(registry.get(), base::Bind(&FieldTrialRecorder::Create)); |
1314 | 1314 |
1315 AddUIThreadInterface( | 1315 AddUIThreadInterface( |
1316 registry.get(), | 1316 registry.get(), |
1317 base::Bind( | 1317 base::Bind( |
1318 &memory_instrumentation::CoordinatorImpl::BindCoordinatorRequest, | 1318 &memory_instrumentation::CoordinatorImpl::BindCoordinatorRequest, |
1319 base::Unretained( | 1319 base::Unretained( |
1320 memory_instrumentation::CoordinatorImpl::GetInstance()))); | 1320 memory_instrumentation::CoordinatorImpl::GetInstance()))); |
1321 | 1321 |
1322 GetContentClient()->browser()->ExposeInterfacesToRenderer(registry.get(), | 1322 associated_interfaces_.reset(new AssociatedInterfaceRegistryImpl()); |
1323 this); | 1323 GetContentClient()->browser()->ExposeInterfacesToRenderer( |
1324 registry.get(), associated_interfaces_.get(), this); | |
1325 static_cast<AssociatedInterfaceRegistry*>(associated_interfaces_.get()) | |
1326 ->AddInterface(base::Bind(&RenderProcessHostImpl::BindRouteProvider, | |
1327 base::Unretained(this))); | |
1324 | 1328 |
1325 ServiceManagerConnection* service_manager_connection = | 1329 ServiceManagerConnection* service_manager_connection = |
1326 BrowserContext::GetServiceManagerConnectionFor(browser_context_); | 1330 BrowserContext::GetServiceManagerConnectionFor(browser_context_); |
1327 std::unique_ptr<ConnectionFilterImpl> connection_filter( | 1331 std::unique_ptr<ConnectionFilterImpl> connection_filter( |
1328 new ConnectionFilterImpl(child_connection_->child_identity(), | 1332 new ConnectionFilterImpl(child_connection_->child_identity(), |
1329 std::move(registry))); | 1333 std::move(registry))); |
1330 connection_filter_controller_ = connection_filter->controller(); | 1334 connection_filter_controller_ = connection_filter->controller(); |
1331 connection_filter_id_ = service_manager_connection->AddConnectionFilter( | 1335 connection_filter_id_ = service_manager_connection->AddConnectionFilter( |
1332 std::move(connection_filter)); | 1336 std::move(connection_filter)); |
1333 } | 1337 } |
1334 | 1338 |
1339 void RenderProcessHostImpl::BindRouteProvider( | |
1340 mojom::RouteProviderAssociatedRequest request) { | |
1341 if (route_provider_binding_.is_bound()) | |
1342 return; | |
1343 route_provider_binding_.Bind(std::move(request)); | |
1344 } | |
1345 | |
1335 void RenderProcessHostImpl::GetRoute( | 1346 void RenderProcessHostImpl::GetRoute( |
1336 int32_t routing_id, | 1347 int32_t routing_id, |
1337 mojom::AssociatedInterfaceProviderAssociatedRequest request) { | 1348 mojom::AssociatedInterfaceProviderAssociatedRequest request) { |
1338 DCHECK(request.is_pending()); | 1349 DCHECK(request.is_pending()); |
1339 associated_interface_provider_bindings_.AddBinding( | 1350 associated_interface_provider_bindings_.AddBinding( |
1340 this, std::move(request), routing_id); | 1351 this, std::move(request), routing_id); |
1341 } | 1352 } |
1342 | 1353 |
1343 void RenderProcessHostImpl::GetAssociatedInterface( | 1354 void RenderProcessHostImpl::GetAssociatedInterface( |
1344 const std::string& name, | 1355 const std::string& name, |
(...skipping 723 matching lines...) Loading... | |
2068 Send(reply); | 2079 Send(reply); |
2069 } | 2080 } |
2070 return true; | 2081 return true; |
2071 } | 2082 } |
2072 return listener->OnMessageReceived(msg); | 2083 return listener->OnMessageReceived(msg); |
2073 } | 2084 } |
2074 | 2085 |
2075 void RenderProcessHostImpl::OnAssociatedInterfaceRequest( | 2086 void RenderProcessHostImpl::OnAssociatedInterfaceRequest( |
2076 const std::string& interface_name, | 2087 const std::string& interface_name, |
2077 mojo::ScopedInterfaceEndpointHandle handle) { | 2088 mojo::ScopedInterfaceEndpointHandle handle) { |
2078 if (interface_name == mojom::RouteProvider::Name_) { | 2089 if (associated_interfaces_->CanBindRequest(interface_name)) { |
2079 if (route_provider_binding_.is_bound()) | 2090 associated_interfaces_->BindRequest(interface_name, std::move(handle)); |
2080 return; | |
2081 mojom::RouteProviderAssociatedRequest request; | |
2082 request.Bind(std::move(handle)); | |
2083 route_provider_binding_.Bind(std::move(request)); | |
2084 } else { | 2091 } else { |
2085 LOG(ERROR) << "Request for unknown Channel-associated interface: " | 2092 LOG(ERROR) << "Request for unknown Channel-associated interface: " |
2086 << interface_name; | 2093 << interface_name; |
2087 } | 2094 } |
2088 } | 2095 } |
2089 | 2096 |
2090 void RenderProcessHostImpl::OnChannelConnected(int32_t peer_pid) { | 2097 void RenderProcessHostImpl::OnChannelConnected(int32_t peer_pid) { |
2091 channel_connected_ = true; | 2098 channel_connected_ = true; |
2092 if (IsReady()) { | 2099 if (IsReady()) { |
2093 DCHECK(!sent_render_process_ready_); | 2100 DCHECK(!sent_render_process_ready_); |
(...skipping 638 matching lines...) Loading... | |
2732 // logic. | 2739 // logic. |
2733 status = base::TERMINATION_STATUS_PROCESS_CRASHED; | 2740 status = base::TERMINATION_STATUS_PROCESS_CRASHED; |
2734 } | 2741 } |
2735 } | 2742 } |
2736 | 2743 |
2737 RendererClosedDetails details(status, exit_code); | 2744 RendererClosedDetails details(status, exit_code); |
2738 | 2745 |
2739 child_process_launcher_.reset(); | 2746 child_process_launcher_.reset(); |
2740 is_dead_ = true; | 2747 is_dead_ = true; |
2741 if (route_provider_binding_.is_bound()) | 2748 if (route_provider_binding_.is_bound()) |
2742 route_provider_binding_.Close(); | 2749 route_provider_binding_.Close(); |
ncarter (slow)
2017/04/27 20:43:53
Does associated_interfaces_ need to be reset here?
nigeltao1
2017/04/28 00:33:25
I think so. Done.
rockot: (1) WDYT? (2) PTAL at t
| |
2743 ResetChannelProxy(); | 2750 ResetChannelProxy(); |
2744 | 2751 |
2745 UpdateProcessPriority(); | 2752 UpdateProcessPriority(); |
2746 DCHECK(!is_process_backgrounded_); | 2753 DCHECK(!is_process_backgrounded_); |
2747 | 2754 |
2748 within_process_died_observer_ = true; | 2755 within_process_died_observer_ = true; |
2749 NotificationService::current()->Notify( | 2756 NotificationService::current()->Notify( |
2750 NOTIFICATION_RENDERER_PROCESS_CLOSED, Source<RenderProcessHost>(this), | 2757 NOTIFICATION_RENDERER_PROCESS_CLOSED, Source<RenderProcessHost>(this), |
2751 Details<RendererClosedDetails>(&details)); | 2758 Details<RendererClosedDetails>(&details)); |
2752 for (auto& observer : observers_) | 2759 for (auto& observer : observers_) |
(...skipping 323 matching lines...) Loading... | |
3076 LOG(ERROR) << "Terminating render process for bad Mojo message: " << error; | 3083 LOG(ERROR) << "Terminating render process for bad Mojo message: " << error; |
3077 | 3084 |
3078 // The ReceivedBadMessage call below will trigger a DumpWithoutCrashing. | 3085 // The ReceivedBadMessage call below will trigger a DumpWithoutCrashing. |
3079 // Capture the error message in a crash key value. | 3086 // Capture the error message in a crash key value. |
3080 base::debug::ScopedCrashKey error_key_value("mojo-message-error", error); | 3087 base::debug::ScopedCrashKey error_key_value("mojo-message-error", error); |
3081 bad_message::ReceivedBadMessage(render_process_id, | 3088 bad_message::ReceivedBadMessage(render_process_id, |
3082 bad_message::RPH_MOJO_PROCESS_ERROR); | 3089 bad_message::RPH_MOJO_PROCESS_ERROR); |
3083 } | 3090 } |
3084 | 3091 |
3085 } // namespace content | 3092 } // namespace content |
OLD | NEW |