Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(31)

Side by Side Diff: content/browser/renderer_host/render_process_host_impl.cc

Issue 2653973002: Remove associated interface registration from ChannelProxy (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 1175 matching lines...) Expand 10 before | Expand all | Expand 10 after
1186 synchronous_compositor_filter_ = 1186 synchronous_compositor_filter_ =
1187 new SynchronousCompositorBrowserFilter(GetID()); 1187 new SynchronousCompositorBrowserFilter(GetID());
1188 AddFilter(synchronous_compositor_filter_.get()); 1188 AddFilter(synchronous_compositor_filter_.get());
1189 #endif 1189 #endif
1190 } 1190 }
1191 1191
1192 void RenderProcessHostImpl::RegisterMojoInterfaces() { 1192 void RenderProcessHostImpl::RegisterMojoInterfaces() {
1193 auto registry = base::MakeUnique<service_manager::InterfaceRegistry>( 1193 auto registry = base::MakeUnique<service_manager::InterfaceRegistry>(
1194 service_manager::mojom::kServiceManager_ConnectorSpec); 1194 service_manager::mojom::kServiceManager_ConnectorSpec);
1195 1195
1196 channel_->AddAssociatedInterface(
1197 base::Bind(&RenderProcessHostImpl::OnRouteProviderRequest,
1198 base::Unretained(this)));
1199
1200 channel_->AddAssociatedInterfaceForIOThread( 1196 channel_->AddAssociatedInterfaceForIOThread(
1201 base::Bind(&IndexedDBDispatcherHost::AddBinding, indexed_db_factory_)); 1197 base::Bind(&IndexedDBDispatcherHost::AddBinding, indexed_db_factory_));
1202 1198
1203 #if defined(OS_ANDROID) 1199 #if defined(OS_ANDROID)
1204 AddUIThreadInterface(registry.get(), 1200 AddUIThreadInterface(registry.get(),
1205 GetGlobalJavaInterfaces() 1201 GetGlobalJavaInterfaces()
1206 ->CreateInterfaceFactory<device::BatteryMonitor>()); 1202 ->CreateInterfaceFactory<device::BatteryMonitor>());
1207 AddUIThreadInterface( 1203 AddUIThreadInterface(
1208 registry.get(), GetGlobalJavaInterfaces() 1204 registry.get(), GetGlobalJavaInterfaces()
1209 ->CreateInterfaceFactory< 1205 ->CreateInterfaceFactory<
(...skipping 848 matching lines...) Expand 10 before | Expand all | Expand 10 after
2058 // hang waiting for a reply. 2054 // hang waiting for a reply.
2059 IPC::Message* reply = IPC::SyncMessage::GenerateReply(&msg); 2055 IPC::Message* reply = IPC::SyncMessage::GenerateReply(&msg);
2060 reply->set_reply_error(); 2056 reply->set_reply_error();
2061 Send(reply); 2057 Send(reply);
2062 } 2058 }
2063 return true; 2059 return true;
2064 } 2060 }
2065 return listener->OnMessageReceived(msg); 2061 return listener->OnMessageReceived(msg);
2066 } 2062 }
2067 2063
2064 void RenderProcessHostImpl::OnAssociatedInterfaceRequest(
2065 const std::string& interface_name,
2066 mojo::ScopedInterfaceEndpointHandle handle) {
2067 if (interface_name == mojom::RouteProvider::Name_) {
2068 if (route_provider_binding_.is_bound())
2069 return;
2070 mojom::RouteProviderAssociatedRequest request;
2071 request.Bind(std::move(handle));
2072 route_provider_binding_.Bind(std::move(request));
2073 } else {
2074 LOG(ERROR) << "Request for unknown Channel-associated interface: "
2075 << interface_name;
2076 }
2077 }
2078
2068 void RenderProcessHostImpl::OnChannelConnected(int32_t peer_pid) { 2079 void RenderProcessHostImpl::OnChannelConnected(int32_t peer_pid) {
2069 channel_connected_ = true; 2080 channel_connected_ = true;
2070 if (IsReady()) { 2081 if (IsReady()) {
2071 DCHECK(!sent_render_process_ready_); 2082 DCHECK(!sent_render_process_ready_);
2072 sent_render_process_ready_ = true; 2083 sent_render_process_ready_ = true;
2073 // Send RenderProcessReady only if we already received the process handle. 2084 // Send RenderProcessReady only if we already received the process handle.
2074 for (auto& observer : observers_) 2085 for (auto& observer : observers_)
2075 observer.RenderProcessReady(this); 2086 observer.RenderProcessReady(this);
2076 } 2087 }
2077 2088
(...skipping 568 matching lines...) Expand 10 before | Expand all | Expand 10 after
2646 metrics_allocator_.reset(new base::SharedPersistentMemoryAllocator( 2657 metrics_allocator_.reset(new base::SharedPersistentMemoryAllocator(
2647 std::move(shm), GetID(), "RendererMetrics", /*readonly=*/false)); 2658 std::move(shm), GetID(), "RendererMetrics", /*readonly=*/false));
2648 } 2659 }
2649 2660
2650 base::SharedMemoryHandle shm_handle; 2661 base::SharedMemoryHandle shm_handle;
2651 metrics_allocator_->shared_memory()->ShareToProcess(destination, &shm_handle); 2662 metrics_allocator_->shared_memory()->ShareToProcess(destination, &shm_handle);
2652 Send(new ChildProcessMsg_SetHistogramMemory( 2663 Send(new ChildProcessMsg_SetHistogramMemory(
2653 shm_handle, metrics_allocator_->shared_memory()->mapped_size())); 2664 shm_handle, metrics_allocator_->shared_memory()->mapped_size()));
2654 } 2665 }
2655 2666
2656 void RenderProcessHostImpl::OnRouteProviderRequest(
2657 mojom::RouteProviderAssociatedRequest request) {
2658 if (route_provider_binding_.is_bound())
2659 return;
2660 route_provider_binding_.Bind(std::move(request));
2661 }
2662
2663 void RenderProcessHostImpl::ProcessDied(bool already_dead, 2667 void RenderProcessHostImpl::ProcessDied(bool already_dead,
2664 RendererClosedDetails* known_details) { 2668 RendererClosedDetails* known_details) {
2665 // Our child process has died. If we didn't expect it, it's a crash. 2669 // Our child process has died. If we didn't expect it, it's a crash.
2666 // In any case, we need to let everyone know it's gone. 2670 // In any case, we need to let everyone know it's gone.
2667 // The OnChannelError notification can fire multiple times due to nested sync 2671 // The OnChannelError notification can fire multiple times due to nested sync
2668 // calls to a renderer. If we don't have a valid channel here it means we 2672 // calls to a renderer. If we don't have a valid channel here it means we
2669 // already handled the error. 2673 // already handled the error.
2670 2674
2671 // It should not be possible for us to be called re-entrantly. 2675 // It should not be possible for us to be called re-entrantly.
2672 DCHECK(!within_process_died_observer_); 2676 DCHECK(!within_process_died_observer_);
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after
3041 LOG(ERROR) << "Terminating render process for bad Mojo message: " << error; 3045 LOG(ERROR) << "Terminating render process for bad Mojo message: " << error;
3042 3046
3043 // The ReceivedBadMessage call below will trigger a DumpWithoutCrashing. 3047 // The ReceivedBadMessage call below will trigger a DumpWithoutCrashing.
3044 // Capture the error message in a crash key value. 3048 // Capture the error message in a crash key value.
3045 base::debug::ScopedCrashKey error_key_value("mojo-message-error", error); 3049 base::debug::ScopedCrashKey error_key_value("mojo-message-error", error);
3046 bad_message::ReceivedBadMessage(render_process_id, 3050 bad_message::ReceivedBadMessage(render_process_id,
3047 bad_message::RPH_MOJO_PROCESS_ERROR); 3051 bad_message::RPH_MOJO_PROCESS_ERROR);
3048 } 3052 }
3049 3053
3050 } // namespace content 3054 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_process_host_impl.h ('k') | content/child/child_thread_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698