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

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

Issue 285333003: Support exposing Mojo services between render frames, render threads, and their respective hosts. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address comments Created 6 years, 5 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 #include "content/browser/histogram_message_filter.h" 61 #include "content/browser/histogram_message_filter.h"
62 #include "content/browser/indexed_db/indexed_db_context_impl.h" 62 #include "content/browser/indexed_db/indexed_db_context_impl.h"
63 #include "content/browser/indexed_db/indexed_db_dispatcher_host.h" 63 #include "content/browser/indexed_db/indexed_db_dispatcher_host.h"
64 #include "content/browser/loader/resource_message_filter.h" 64 #include "content/browser/loader/resource_message_filter.h"
65 #include "content/browser/loader/resource_scheduler_filter.h" 65 #include "content/browser/loader/resource_scheduler_filter.h"
66 #include "content/browser/media/capture/audio_mirroring_manager.h" 66 #include "content/browser/media/capture/audio_mirroring_manager.h"
67 #include "content/browser/media/media_internals.h" 67 #include "content/browser/media/media_internals.h"
68 #include "content/browser/media/midi_host.h" 68 #include "content/browser/media/midi_host.h"
69 #include "content/browser/message_port_message_filter.h" 69 #include "content/browser/message_port_message_filter.h"
70 #include "content/browser/mime_registry_message_filter.h" 70 #include "content/browser/mime_registry_message_filter.h"
71 #include "content/browser/mojo/mojo_application_host.h"
72 #include "content/browser/plugin_service_impl.h" 71 #include "content/browser/plugin_service_impl.h"
73 #include "content/browser/profiler_message_filter.h" 72 #include "content/browser/profiler_message_filter.h"
74 #include "content/browser/push_messaging_message_filter.h" 73 #include "content/browser/push_messaging_message_filter.h"
75 #include "content/browser/quota_dispatcher_host.h" 74 #include "content/browser/quota_dispatcher_host.h"
76 #include "content/browser/renderer_host/clipboard_message_filter.h" 75 #include "content/browser/renderer_host/clipboard_message_filter.h"
77 #include "content/browser/renderer_host/database_message_filter.h" 76 #include "content/browser/renderer_host/database_message_filter.h"
78 #include "content/browser/renderer_host/file_utilities_message_filter.h" 77 #include "content/browser/renderer_host/file_utilities_message_filter.h"
79 #include "content/browser/renderer_host/gamepad_browser_message_filter.h" 78 #include "content/browser/renderer_host/gamepad_browser_message_filter.h"
80 #include "content/browser/renderer_host/gpu_message_filter.h" 79 #include "content/browser/renderer_host/gpu_message_filter.h"
81 #include "content/browser/renderer_host/media/audio_input_renderer_host.h" 80 #include "content/browser/renderer_host/media/audio_input_renderer_host.h"
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 #include "content/public/common/content_switches.h" 132 #include "content/public/common/content_switches.h"
134 #include "content/public/common/process_type.h" 133 #include "content/public/common/process_type.h"
135 #include "content/public/common/result_codes.h" 134 #include "content/public/common/result_codes.h"
136 #include "content/public/common/sandboxed_process_launcher_delegate.h" 135 #include "content/public/common/sandboxed_process_launcher_delegate.h"
137 #include "content/public/common/url_constants.h" 136 #include "content/public/common/url_constants.h"
138 #include "gpu/command_buffer/service/gpu_switches.h" 137 #include "gpu/command_buffer/service/gpu_switches.h"
139 #include "ipc/ipc_channel.h" 138 #include "ipc/ipc_channel.h"
140 #include "ipc/ipc_logging.h" 139 #include "ipc/ipc_logging.h"
141 #include "ipc/ipc_switches.h" 140 #include "ipc/ipc_switches.h"
142 #include "media/base/media_switches.h" 141 #include "media/base/media_switches.h"
143 #include "mojo/common/common_type_converters.h"
144 #include "net/url_request/url_request_context_getter.h" 142 #include "net/url_request/url_request_context_getter.h"
145 #include "ppapi/shared_impl/ppapi_switches.h" 143 #include "ppapi/shared_impl/ppapi_switches.h"
146 #include "third_party/skia/include/core/SkBitmap.h" 144 #include "third_party/skia/include/core/SkBitmap.h"
147 #include "ui/base/ui_base_switches.h" 145 #include "ui/base/ui_base_switches.h"
148 #include "ui/events/event_switches.h" 146 #include "ui/events/event_switches.h"
149 #include "ui/gfx/switches.h" 147 #include "ui/gfx/switches.h"
150 #include "ui/gl/gl_switches.h" 148 #include "ui/gl/gl_switches.h"
151 #include "ui/native_theme/native_theme_switches.h" 149 #include "ui/native_theme/native_theme_switches.h"
152 #include "webkit/browser/fileapi/sandbox_file_system_backend.h" 150 #include "webkit/browser/fileapi/sandbox_file_system_backend.h"
153 #include "webkit/common/resource_type.h" 151 #include "webkit/common/resource_type.h"
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
440 RenderProcessHostImpl::RenderProcessHostImpl( 438 RenderProcessHostImpl::RenderProcessHostImpl(
441 BrowserContext* browser_context, 439 BrowserContext* browser_context,
442 StoragePartitionImpl* storage_partition_impl, 440 StoragePartitionImpl* storage_partition_impl,
443 bool is_isolated_guest) 441 bool is_isolated_guest)
444 : fast_shutdown_started_(false), 442 : fast_shutdown_started_(false),
445 deleting_soon_(false), 443 deleting_soon_(false),
446 #ifndef NDEBUG 444 #ifndef NDEBUG
447 is_self_deleted_(false), 445 is_self_deleted_(false),
448 #endif 446 #endif
449 pending_views_(0), 447 pending_views_(0),
448 mojo_application_host_(new MojoApplicationHost),
450 mojo_activation_required_(false), 449 mojo_activation_required_(false),
451 visible_widgets_(0), 450 visible_widgets_(0),
452 backgrounded_(true), 451 backgrounded_(true),
453 is_initialized_(false), 452 is_initialized_(false),
454 id_(ChildProcessHostImpl::GenerateChildProcessUniqueId()), 453 id_(ChildProcessHostImpl::GenerateChildProcessUniqueId()),
455 browser_context_(browser_context), 454 browser_context_(browser_context),
456 storage_partition_impl_(storage_partition_impl), 455 storage_partition_impl_(storage_partition_impl),
457 sudden_termination_allowed_(true), 456 sudden_termination_allowed_(true),
458 ignore_input_events_(false), 457 ignore_input_events_(false),
459 is_isolated_guest_(is_isolated_guest), 458 is_isolated_guest_(is_isolated_guest),
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
589 // Setup the IPC channel. 588 // Setup the IPC channel.
590 const std::string channel_id = 589 const std::string channel_id =
591 IPC::Channel::GenerateVerifiedChannelID(std::string()); 590 IPC::Channel::GenerateVerifiedChannelID(std::string());
592 channel_ = IPC::ChannelProxy::Create( 591 channel_ = IPC::ChannelProxy::Create(
593 channel_id, 592 channel_id,
594 IPC::Channel::MODE_SERVER, 593 IPC::Channel::MODE_SERVER,
595 this, 594 this,
596 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO).get()); 595 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO).get());
597 596
598 // Setup the Mojo channel. 597 // Setup the Mojo channel.
599 mojo_application_host_.reset(new MojoApplicationHost());
600 mojo_application_host_->Init(); 598 mojo_application_host_->Init();
601 599
602 // Call the embedder first so that their IPC filters have priority. 600 // Call the embedder first so that their IPC filters have priority.
603 GetContentClient()->browser()->RenderProcessWillLaunch(this); 601 GetContentClient()->browser()->RenderProcessWillLaunch(this);
604 602
605 CreateMessageFilters(); 603 CreateMessageFilters();
606 604
607 if (run_renderer_in_process()) { 605 if (run_renderer_in_process()) {
608 DCHECK(g_renderer_main_thread_factory); 606 DCHECK(g_renderer_main_thread_factory);
609 // Crank up a thread and run the initialization there. With the way that 607 // Crank up a thread and run the initialization there. With the way that
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
900 898
901 void RenderProcessHostImpl::ResumeResponseDeferredAtStart( 899 void RenderProcessHostImpl::ResumeResponseDeferredAtStart(
902 const GlobalRequestID& request_id) { 900 const GlobalRequestID& request_id) {
903 widget_helper_->ResumeResponseDeferredAtStart(request_id); 901 widget_helper_->ResumeResponseDeferredAtStart(request_id);
904 } 902 }
905 903
906 void RenderProcessHostImpl::NotifyTimezoneChange() { 904 void RenderProcessHostImpl::NotifyTimezoneChange() {
907 Send(new ViewMsg_TimezoneChange()); 905 Send(new ViewMsg_TimezoneChange());
908 } 906 }
909 907
908 ServiceRegistry* RenderProcessHostImpl::GetServiceRegistry() {
909 if (!mojo_application_host_)
910 return NULL;
911 return mojo_application_host_->service_registry();
912 }
913
910 void RenderProcessHostImpl::AddRoute( 914 void RenderProcessHostImpl::AddRoute(
911 int32 routing_id, 915 int32 routing_id,
912 IPC::Listener* listener) { 916 IPC::Listener* listener) {
913 listeners_.AddWithID(listener, routing_id); 917 listeners_.AddWithID(listener, routing_id);
914 } 918 }
915 919
916 void RenderProcessHostImpl::RemoveRoute(int32 routing_id) { 920 void RenderProcessHostImpl::RemoveRoute(int32 routing_id) {
917 DCHECK(listeners_.Lookup(routing_id) != NULL); 921 DCHECK(listeners_.Lookup(routing_id) != NULL);
918 listeners_.Remove(routing_id); 922 listeners_.Remove(routing_id);
919 923
(...skipping 1008 matching lines...) Expand 10 before | Expand all | Expand 10 after
1928 1932
1929 IDMap<IPC::Listener>::iterator iter(&listeners_); 1933 IDMap<IPC::Listener>::iterator iter(&listeners_);
1930 while (!iter.IsAtEnd()) { 1934 while (!iter.IsAtEnd()) {
1931 iter.GetCurrentValue()->OnMessageReceived( 1935 iter.GetCurrentValue()->OnMessageReceived(
1932 ViewHostMsg_RenderProcessGone(iter.GetCurrentKey(), 1936 ViewHostMsg_RenderProcessGone(iter.GetCurrentKey(),
1933 static_cast<int>(status), 1937 static_cast<int>(status),
1934 exit_code)); 1938 exit_code));
1935 iter.Advance(); 1939 iter.Advance();
1936 } 1940 }
1937 1941
1938 mojo_application_host_.reset(); 1942 mojo_application_host_.reset(new MojoApplicationHost);
1943 mojo_activation_required_ = false;
1939 1944
1940 // It's possible that one of the calls out to the observers might have caused 1945 // It's possible that one of the calls out to the observers might have caused
1941 // this object to be no longer needed. 1946 // this object to be no longer needed.
1942 if (delayed_cleanup_needed_) 1947 if (delayed_cleanup_needed_)
1943 Cleanup(); 1948 Cleanup();
1944 1949
1945 // This object is not deleted at this point and might be reused later. 1950 // This object is not deleted at this point and might be reused later.
1946 // TODO(darin): clean this up 1951 // TODO(darin): clean this up
1947 } 1952 }
1948 1953
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
2248 } 2253 }
2249 2254
2250 void RenderProcessHostImpl::DecrementWorkerRefCount() { 2255 void RenderProcessHostImpl::DecrementWorkerRefCount() {
2251 DCHECK_CURRENTLY_ON(BrowserThread::UI); 2256 DCHECK_CURRENTLY_ON(BrowserThread::UI);
2252 DCHECK_GT(worker_ref_count_, 0); 2257 DCHECK_GT(worker_ref_count_, 0);
2253 --worker_ref_count_; 2258 --worker_ref_count_;
2254 if (worker_ref_count_ == 0) 2259 if (worker_ref_count_ == 0)
2255 Cleanup(); 2260 Cleanup();
2256 } 2261 }
2257 2262
2258 void RenderProcessHostImpl::ConnectTo( 2263 void RenderProcessHostImpl::EnsureMojoActivated() {
2259 const base::StringPiece& service_name,
2260 mojo::ScopedMessagePipeHandle handle) {
2261 mojo_activation_required_ = true; 2264 mojo_activation_required_ = true;
2262 MaybeActivateMojo(); 2265 MaybeActivateMojo();
2263
2264 mojo_application_host_->service_provider()->ConnectToService(
2265 mojo::String::From(service_name),
2266 std::string(),
2267 handle.Pass(),
2268 mojo::String());
2269 } 2266 }
2270 2267
2271 void RenderProcessHostImpl::OnAllocateGpuMemoryBuffer(uint32 width, 2268 void RenderProcessHostImpl::OnAllocateGpuMemoryBuffer(uint32 width,
2272 uint32 height, 2269 uint32 height,
2273 uint32 internalformat, 2270 uint32 internalformat,
2274 uint32 usage, 2271 uint32 usage,
2275 IPC::Message* reply) { 2272 IPC::Message* reply) {
2276 DCHECK_CURRENTLY_ON(BrowserThread::UI); 2273 DCHECK_CURRENTLY_ON(BrowserThread::UI);
2277 if (!GpuMemoryBufferImpl::IsFormatValid(internalformat) || 2274 if (!GpuMemoryBufferImpl::IsFormatValid(internalformat) ||
2278 !GpuMemoryBufferImpl::IsUsageValid(usage)) { 2275 !GpuMemoryBufferImpl::IsUsageValid(usage)) {
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
2363 void RenderProcessHostImpl::GpuMemoryBufferAllocated( 2360 void RenderProcessHostImpl::GpuMemoryBufferAllocated(
2364 IPC::Message* reply, 2361 IPC::Message* reply,
2365 const gfx::GpuMemoryBufferHandle& handle) { 2362 const gfx::GpuMemoryBufferHandle& handle) {
2366 DCHECK_CURRENTLY_ON(BrowserThread::UI); 2363 DCHECK_CURRENTLY_ON(BrowserThread::UI);
2367 ChildProcessHostMsg_SyncAllocateGpuMemoryBuffer::WriteReplyParams(reply, 2364 ChildProcessHostMsg_SyncAllocateGpuMemoryBuffer::WriteReplyParams(reply,
2368 handle); 2365 handle);
2369 Send(reply); 2366 Send(reply);
2370 } 2367 }
2371 2368
2372 } // namespace content 2369 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_process_host_impl.h ('k') | content/browser/renderer_host/render_view_host_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698