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 1358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1369 | 1369 |
| 1370 AddUIThreadInterface(registry.get(), base::Bind(&FieldTrialRecorder::Create)); | 1370 AddUIThreadInterface(registry.get(), base::Bind(&FieldTrialRecorder::Create)); |
| 1371 | 1371 |
| 1372 AddUIThreadInterface( | 1372 AddUIThreadInterface( |
| 1373 registry.get(), | 1373 registry.get(), |
| 1374 base::Bind( | 1374 base::Bind( |
| 1375 &memory_instrumentation::CoordinatorImpl::BindCoordinatorRequest, | 1375 &memory_instrumentation::CoordinatorImpl::BindCoordinatorRequest, |
| 1376 base::Unretained( | 1376 base::Unretained( |
| 1377 memory_instrumentation::CoordinatorImpl::GetInstance()))); | 1377 memory_instrumentation::CoordinatorImpl::GetInstance()))); |
| 1378 | 1378 |
| 1379 GetContentClient()->browser()->ExposeInterfacesToRenderer(registry.get(), | 1379 associated_interfaces_.reset(new AssociatedInterfaceRegistryImpl()); |
| 1380 this); | 1380 GetContentClient()->browser()->ExposeInterfacesToRenderer( |
| 1381 registry.get(), associated_interfaces_.get(), this); | |
| 1382 static_cast<AssociatedInterfaceRegistry*>(associated_interfaces_.get()) | |
| 1383 ->AddInterface(base::Bind(&RenderProcessHostImpl::BindRouteProvider, | |
| 1384 base::Unretained(this))); | |
| 1381 | 1385 |
| 1382 ServiceManagerConnection* service_manager_connection = | 1386 ServiceManagerConnection* service_manager_connection = |
| 1383 BrowserContext::GetServiceManagerConnectionFor(browser_context_); | 1387 BrowserContext::GetServiceManagerConnectionFor(browser_context_); |
| 1384 std::unique_ptr<ConnectionFilterImpl> connection_filter( | 1388 std::unique_ptr<ConnectionFilterImpl> connection_filter( |
| 1385 new ConnectionFilterImpl(child_connection_->child_identity(), | 1389 new ConnectionFilterImpl(child_connection_->child_identity(), |
| 1386 std::move(registry))); | 1390 std::move(registry))); |
| 1387 connection_filter_controller_ = connection_filter->controller(); | 1391 connection_filter_controller_ = connection_filter->controller(); |
| 1388 connection_filter_id_ = service_manager_connection->AddConnectionFilter( | 1392 connection_filter_id_ = service_manager_connection->AddConnectionFilter( |
| 1389 std::move(connection_filter)); | 1393 std::move(connection_filter)); |
| 1390 } | 1394 } |
| 1391 | 1395 |
| 1396 void RenderProcessHostImpl::BindRouteProvider( | |
| 1397 mojom::RouteProviderAssociatedRequest request) { | |
| 1398 if (route_provider_binding_.is_bound()) | |
| 1399 return; | |
| 1400 route_provider_binding_.Bind(std::move(request)); | |
| 1401 } | |
| 1402 | |
| 1392 void RenderProcessHostImpl::GetRoute( | 1403 void RenderProcessHostImpl::GetRoute( |
| 1393 int32_t routing_id, | 1404 int32_t routing_id, |
| 1394 mojom::AssociatedInterfaceProviderAssociatedRequest request) { | 1405 mojom::AssociatedInterfaceProviderAssociatedRequest request) { |
| 1395 DCHECK(request.is_pending()); | 1406 DCHECK(request.is_pending()); |
| 1396 associated_interface_provider_bindings_.AddBinding( | 1407 associated_interface_provider_bindings_.AddBinding( |
| 1397 this, std::move(request), routing_id); | 1408 this, std::move(request), routing_id); |
| 1398 } | 1409 } |
| 1399 | 1410 |
| 1400 void RenderProcessHostImpl::GetAssociatedInterface( | 1411 void RenderProcessHostImpl::GetAssociatedInterface( |
| 1401 const std::string& name, | 1412 const std::string& name, |
| (...skipping 729 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2131 Send(reply); | 2142 Send(reply); |
| 2132 } | 2143 } |
| 2133 return true; | 2144 return true; |
| 2134 } | 2145 } |
| 2135 return listener->OnMessageReceived(msg); | 2146 return listener->OnMessageReceived(msg); |
| 2136 } | 2147 } |
| 2137 | 2148 |
| 2138 void RenderProcessHostImpl::OnAssociatedInterfaceRequest( | 2149 void RenderProcessHostImpl::OnAssociatedInterfaceRequest( |
| 2139 const std::string& interface_name, | 2150 const std::string& interface_name, |
| 2140 mojo::ScopedInterfaceEndpointHandle handle) { | 2151 mojo::ScopedInterfaceEndpointHandle handle) { |
| 2141 if (interface_name == mojom::RouteProvider::Name_) { | 2152 if ((associated_interfaces_) && |
|
Ken Rockot(use gerrit already)
2017/04/28 19:20:10
nit: please remove the redundant parenthesis from
nigeltao1
2017/04/29 07:07:57
Done.
| |
| 2142 if (route_provider_binding_.is_bound()) | 2153 (associated_interfaces_->CanBindRequest(interface_name))) { |
| 2143 return; | 2154 associated_interfaces_->BindRequest(interface_name, std::move(handle)); |
| 2144 mojom::RouteProviderAssociatedRequest request; | |
| 2145 request.Bind(std::move(handle)); | |
| 2146 route_provider_binding_.Bind(std::move(request)); | |
| 2147 } else { | 2155 } else { |
| 2148 LOG(ERROR) << "Request for unknown Channel-associated interface: " | 2156 LOG(ERROR) << "Request for unknown Channel-associated interface: " |
| 2149 << interface_name; | 2157 << interface_name; |
| 2150 } | 2158 } |
| 2151 } | 2159 } |
| 2152 | 2160 |
| 2153 void RenderProcessHostImpl::OnChannelConnected(int32_t peer_pid) { | 2161 void RenderProcessHostImpl::OnChannelConnected(int32_t peer_pid) { |
| 2154 channel_connected_ = true; | 2162 channel_connected_ = true; |
| 2155 if (IsReady()) { | 2163 if (IsReady()) { |
| 2156 DCHECK(!sent_render_process_ready_); | 2164 DCHECK(!sent_render_process_ready_); |
| (...skipping 639 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2796 status = base::TERMINATION_STATUS_PROCESS_CRASHED; | 2804 status = base::TERMINATION_STATUS_PROCESS_CRASHED; |
| 2797 } | 2805 } |
| 2798 } | 2806 } |
| 2799 | 2807 |
| 2800 RendererClosedDetails details(status, exit_code); | 2808 RendererClosedDetails details(status, exit_code); |
| 2801 | 2809 |
| 2802 child_process_launcher_.reset(); | 2810 child_process_launcher_.reset(); |
| 2803 is_dead_ = true; | 2811 is_dead_ = true; |
| 2804 if (route_provider_binding_.is_bound()) | 2812 if (route_provider_binding_.is_bound()) |
| 2805 route_provider_binding_.Close(); | 2813 route_provider_binding_.Close(); |
| 2814 associated_interfaces_.reset(NULL); | |
|
Ken Rockot(use gerrit already)
2017/04/28 19:20:10
nit: please use nullptr instead of NULL in new cod
nigeltao1
2017/04/29 07:07:57
Done.
| |
| 2806 ResetChannelProxy(); | 2815 ResetChannelProxy(); |
| 2807 | 2816 |
| 2808 UpdateProcessPriority(); | 2817 UpdateProcessPriority(); |
| 2809 DCHECK(!is_process_backgrounded_); | 2818 DCHECK(!is_process_backgrounded_); |
| 2810 | 2819 |
| 2811 within_process_died_observer_ = true; | 2820 within_process_died_observer_ = true; |
| 2812 NotificationService::current()->Notify( | 2821 NotificationService::current()->Notify( |
| 2813 NOTIFICATION_RENDERER_PROCESS_CLOSED, Source<RenderProcessHost>(this), | 2822 NOTIFICATION_RENDERER_PROCESS_CLOSED, Source<RenderProcessHost>(this), |
| 2814 Details<RendererClosedDetails>(&details)); | 2823 Details<RendererClosedDetails>(&details)); |
| 2815 for (auto& observer : observers_) | 2824 for (auto& observer : observers_) |
| (...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3139 LOG(ERROR) << "Terminating render process for bad Mojo message: " << error; | 3148 LOG(ERROR) << "Terminating render process for bad Mojo message: " << error; |
| 3140 | 3149 |
| 3141 // The ReceivedBadMessage call below will trigger a DumpWithoutCrashing. | 3150 // The ReceivedBadMessage call below will trigger a DumpWithoutCrashing. |
| 3142 // Capture the error message in a crash key value. | 3151 // Capture the error message in a crash key value. |
| 3143 base::debug::ScopedCrashKey error_key_value("mojo-message-error", error); | 3152 base::debug::ScopedCrashKey error_key_value("mojo-message-error", error); |
| 3144 bad_message::ReceivedBadMessage(render_process_id, | 3153 bad_message::ReceivedBadMessage(render_process_id, |
| 3145 bad_message::RPH_MOJO_PROCESS_ERROR); | 3154 bad_message::RPH_MOJO_PROCESS_ERROR); |
| 3146 } | 3155 } |
| 3147 | 3156 |
| 3148 } // namespace content | 3157 } // namespace content |
| OLD | NEW |