| 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 1303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1314 | 1314 |
| 1315 AddUIThreadInterface(registry.get(), base::Bind(&FieldTrialRecorder::Create)); | 1315 AddUIThreadInterface(registry.get(), base::Bind(&FieldTrialRecorder::Create)); |
| 1316 | 1316 |
| 1317 AddUIThreadInterface( | 1317 AddUIThreadInterface( |
| 1318 registry.get(), | 1318 registry.get(), |
| 1319 base::Bind( | 1319 base::Bind( |
| 1320 &memory_instrumentation::CoordinatorImpl::BindCoordinatorRequest, | 1320 &memory_instrumentation::CoordinatorImpl::BindCoordinatorRequest, |
| 1321 base::Unretained( | 1321 base::Unretained( |
| 1322 memory_instrumentation::CoordinatorImpl::GetInstance()))); | 1322 memory_instrumentation::CoordinatorImpl::GetInstance()))); |
| 1323 | 1323 |
| 1324 GetContentClient()->browser()->ExposeInterfacesToRenderer(registry.get(), | 1324 associated_interfaces_.reset(new AssociatedInterfaceRegistryImpl()); |
| 1325 this); | 1325 GetContentClient()->browser()->ExposeInterfacesToRenderer( |
| 1326 registry.get(), associated_interfaces_.get(), this); |
| 1327 static_cast<AssociatedInterfaceRegistry*>(associated_interfaces_.get()) |
| 1328 ->AddInterface(base::Bind(&RenderProcessHostImpl::BindRouteProvider, |
| 1329 base::Unretained(this))); |
| 1326 | 1330 |
| 1327 ServiceManagerConnection* service_manager_connection = | 1331 ServiceManagerConnection* service_manager_connection = |
| 1328 BrowserContext::GetServiceManagerConnectionFor(browser_context_); | 1332 BrowserContext::GetServiceManagerConnectionFor(browser_context_); |
| 1329 std::unique_ptr<ConnectionFilterImpl> connection_filter( | 1333 std::unique_ptr<ConnectionFilterImpl> connection_filter( |
| 1330 new ConnectionFilterImpl(child_connection_->child_identity(), | 1334 new ConnectionFilterImpl(child_connection_->child_identity(), |
| 1331 std::move(registry))); | 1335 std::move(registry))); |
| 1332 connection_filter_controller_ = connection_filter->controller(); | 1336 connection_filter_controller_ = connection_filter->controller(); |
| 1333 connection_filter_id_ = service_manager_connection->AddConnectionFilter( | 1337 connection_filter_id_ = service_manager_connection->AddConnectionFilter( |
| 1334 std::move(connection_filter)); | 1338 std::move(connection_filter)); |
| 1335 } | 1339 } |
| 1336 | 1340 |
| 1341 void RenderProcessHostImpl::BindRouteProvider( |
| 1342 mojom::RouteProviderAssociatedRequest request) { |
| 1343 if (route_provider_binding_.is_bound()) |
| 1344 return; |
| 1345 route_provider_binding_.Bind(std::move(request)); |
| 1346 } |
| 1347 |
| 1337 void RenderProcessHostImpl::GetRoute( | 1348 void RenderProcessHostImpl::GetRoute( |
| 1338 int32_t routing_id, | 1349 int32_t routing_id, |
| 1339 mojom::AssociatedInterfaceProviderAssociatedRequest request) { | 1350 mojom::AssociatedInterfaceProviderAssociatedRequest request) { |
| 1340 DCHECK(request.is_pending()); | 1351 DCHECK(request.is_pending()); |
| 1341 associated_interface_provider_bindings_.AddBinding( | 1352 associated_interface_provider_bindings_.AddBinding( |
| 1342 this, std::move(request), routing_id); | 1353 this, std::move(request), routing_id); |
| 1343 } | 1354 } |
| 1344 | 1355 |
| 1345 void RenderProcessHostImpl::GetAssociatedInterface( | 1356 void RenderProcessHostImpl::GetAssociatedInterface( |
| 1346 const std::string& name, | 1357 const std::string& name, |
| (...skipping 725 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2072 Send(reply); | 2083 Send(reply); |
| 2073 } | 2084 } |
| 2074 return true; | 2085 return true; |
| 2075 } | 2086 } |
| 2076 return listener->OnMessageReceived(msg); | 2087 return listener->OnMessageReceived(msg); |
| 2077 } | 2088 } |
| 2078 | 2089 |
| 2079 void RenderProcessHostImpl::OnAssociatedInterfaceRequest( | 2090 void RenderProcessHostImpl::OnAssociatedInterfaceRequest( |
| 2080 const std::string& interface_name, | 2091 const std::string& interface_name, |
| 2081 mojo::ScopedInterfaceEndpointHandle handle) { | 2092 mojo::ScopedInterfaceEndpointHandle handle) { |
| 2082 if (interface_name == mojom::RouteProvider::Name_) { | 2093 if (associated_interfaces_->CanBindRequest(interface_name)) { |
| 2083 if (route_provider_binding_.is_bound()) | 2094 associated_interfaces_->BindRequest(interface_name, std::move(handle)); |
| 2084 return; | |
| 2085 mojom::RouteProviderAssociatedRequest request; | |
| 2086 request.Bind(std::move(handle)); | |
| 2087 route_provider_binding_.Bind(std::move(request)); | |
| 2088 } else { | 2095 } else { |
| 2089 LOG(ERROR) << "Request for unknown Channel-associated interface: " | 2096 LOG(ERROR) << "Request for unknown Channel-associated interface: " |
| 2090 << interface_name; | 2097 << interface_name; |
| 2091 } | 2098 } |
| 2092 } | 2099 } |
| 2093 | 2100 |
| 2094 void RenderProcessHostImpl::OnChannelConnected(int32_t peer_pid) { | 2101 void RenderProcessHostImpl::OnChannelConnected(int32_t peer_pid) { |
| 2095 channel_connected_ = true; | 2102 channel_connected_ = true; |
| 2096 if (IsReady()) { | 2103 if (IsReady()) { |
| 2097 DCHECK(!sent_render_process_ready_); | 2104 DCHECK(!sent_render_process_ready_); |
| (...skipping 987 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3085 LOG(ERROR) << "Terminating render process for bad Mojo message: " << error; | 3092 LOG(ERROR) << "Terminating render process for bad Mojo message: " << error; |
| 3086 | 3093 |
| 3087 // The ReceivedBadMessage call below will trigger a DumpWithoutCrashing. | 3094 // The ReceivedBadMessage call below will trigger a DumpWithoutCrashing. |
| 3088 // Capture the error message in a crash key value. | 3095 // Capture the error message in a crash key value. |
| 3089 base::debug::ScopedCrashKey error_key_value("mojo-message-error", error); | 3096 base::debug::ScopedCrashKey error_key_value("mojo-message-error", error); |
| 3090 bad_message::ReceivedBadMessage(render_process_id, | 3097 bad_message::ReceivedBadMessage(render_process_id, |
| 3091 bad_message::RPH_MOJO_PROCESS_ERROR); | 3098 bad_message::RPH_MOJO_PROCESS_ERROR); |
| 3092 } | 3099 } |
| 3093 | 3100 |
| 3094 } // namespace content | 3101 } // namespace content |
| OLD | NEW |