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

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

Issue 236813002: Move Mojo channel initialization closer to IPC::Channel setup (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: more missing deps Created 6 years, 8 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 | Annotate | Revision Log
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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 #include "content/browser/histogram_message_filter.h" 57 #include "content/browser/histogram_message_filter.h"
58 #include "content/browser/indexed_db/indexed_db_context_impl.h" 58 #include "content/browser/indexed_db/indexed_db_context_impl.h"
59 #include "content/browser/indexed_db/indexed_db_dispatcher_host.h" 59 #include "content/browser/indexed_db/indexed_db_dispatcher_host.h"
60 #include "content/browser/loader/resource_message_filter.h" 60 #include "content/browser/loader/resource_message_filter.h"
61 #include "content/browser/loader/resource_scheduler_filter.h" 61 #include "content/browser/loader/resource_scheduler_filter.h"
62 #include "content/browser/media/android/browser_demuxer_android.h" 62 #include "content/browser/media/android/browser_demuxer_android.h"
63 #include "content/browser/media/capture/audio_mirroring_manager.h" 63 #include "content/browser/media/capture/audio_mirroring_manager.h"
64 #include "content/browser/media/media_internals.h" 64 #include "content/browser/media/media_internals.h"
65 #include "content/browser/message_port_message_filter.h" 65 #include "content/browser/message_port_message_filter.h"
66 #include "content/browser/mime_registry_message_filter.h" 66 #include "content/browser/mime_registry_message_filter.h"
67 #include "content/browser/mojo/mojo_application_host.h"
67 #include "content/browser/plugin_service_impl.h" 68 #include "content/browser/plugin_service_impl.h"
68 #include "content/browser/profiler_message_filter.h" 69 #include "content/browser/profiler_message_filter.h"
69 #include "content/browser/push_messaging_message_filter.h" 70 #include "content/browser/push_messaging_message_filter.h"
70 #include "content/browser/quota_dispatcher_host.h" 71 #include "content/browser/quota_dispatcher_host.h"
71 #include "content/browser/renderer_host/clipboard_message_filter.h" 72 #include "content/browser/renderer_host/clipboard_message_filter.h"
72 #include "content/browser/renderer_host/database_message_filter.h" 73 #include "content/browser/renderer_host/database_message_filter.h"
73 #include "content/browser/renderer_host/file_utilities_message_filter.h" 74 #include "content/browser/renderer_host/file_utilities_message_filter.h"
74 #include "content/browser/renderer_host/gamepad_browser_message_filter.h" 75 #include "content/browser/renderer_host/gamepad_browser_message_filter.h"
75 #include "content/browser/renderer_host/gpu_message_filter.h" 76 #include "content/browser/renderer_host/gpu_message_filter.h"
76 #include "content/browser/renderer_host/media/audio_input_renderer_host.h" 77 #include "content/browser/renderer_host/media/audio_input_renderer_host.h"
77 #include "content/browser/renderer_host/media/audio_renderer_host.h" 78 #include "content/browser/renderer_host/media/audio_renderer_host.h"
78 #include "content/browser/renderer_host/media/device_request_message_filter.h" 79 #include "content/browser/renderer_host/media/device_request_message_filter.h"
79 #include "content/browser/renderer_host/media/media_stream_dispatcher_host.h" 80 #include "content/browser/renderer_host/media/media_stream_dispatcher_host.h"
80 #include "content/browser/renderer_host/media/midi_dispatcher_host.h" 81 #include "content/browser/renderer_host/media/midi_dispatcher_host.h"
81 #include "content/browser/renderer_host/media/midi_host.h" 82 #include "content/browser/renderer_host/media/midi_host.h"
82 #include "content/browser/renderer_host/media/peer_connection_tracker_host.h" 83 #include "content/browser/renderer_host/media/peer_connection_tracker_host.h"
83 #include "content/browser/renderer_host/media/video_capture_host.h" 84 #include "content/browser/renderer_host/media/video_capture_host.h"
84 #include "content/browser/renderer_host/memory_benchmark_message_filter.h" 85 #include "content/browser/renderer_host/memory_benchmark_message_filter.h"
85 #include "content/browser/renderer_host/p2p/socket_dispatcher_host.h" 86 #include "content/browser/renderer_host/p2p/socket_dispatcher_host.h"
86 #include "content/browser/renderer_host/pepper/pepper_message_filter.h" 87 #include "content/browser/renderer_host/pepper/pepper_message_filter.h"
87 #include "content/browser/renderer_host/pepper/pepper_renderer_connection.h" 88 #include "content/browser/renderer_host/pepper/pepper_renderer_connection.h"
88 #include "content/browser/renderer_host/render_message_filter.h" 89 #include "content/browser/renderer_host/render_message_filter.h"
89 #include "content/browser/renderer_host/render_process_host_mojo_impl.h"
90 #include "content/browser/renderer_host/render_view_host_delegate.h" 90 #include "content/browser/renderer_host/render_view_host_delegate.h"
91 #include "content/browser/renderer_host/render_view_host_impl.h" 91 #include "content/browser/renderer_host/render_view_host_impl.h"
92 #include "content/browser/renderer_host/render_widget_helper.h" 92 #include "content/browser/renderer_host/render_widget_helper.h"
93 #include "content/browser/renderer_host/render_widget_host_impl.h" 93 #include "content/browser/renderer_host/render_widget_host_impl.h"
94 #include "content/browser/renderer_host/socket_stream_dispatcher_host.h" 94 #include "content/browser/renderer_host/socket_stream_dispatcher_host.h"
95 #include "content/browser/renderer_host/text_input_client_message_filter.h" 95 #include "content/browser/renderer_host/text_input_client_message_filter.h"
96 #include "content/browser/renderer_host/websocket_dispatcher_host.h" 96 #include "content/browser/renderer_host/websocket_dispatcher_host.h"
97 #include "content/browser/resolve_proxy_msg_helper.h" 97 #include "content/browser/resolve_proxy_msg_helper.h"
98 #include "content/browser/screen_orientation/screen_orientation_dispatcher_host. h" 98 #include "content/browser/screen_orientation/screen_orientation_dispatcher_host. h"
99 #include "content/browser/service_worker/service_worker_context_wrapper.h" 99 #include "content/browser/service_worker/service_worker_context_wrapper.h"
100 #include "content/browser/service_worker/service_worker_dispatcher_host.h" 100 #include "content/browser/service_worker/service_worker_dispatcher_host.h"
101 #include "content/browser/shared_worker/shared_worker_message_filter.h" 101 #include "content/browser/shared_worker/shared_worker_message_filter.h"
102 #include "content/browser/speech/input_tag_speech_dispatcher_host.h" 102 #include "content/browser/speech/input_tag_speech_dispatcher_host.h"
103 #include "content/browser/speech/speech_recognition_dispatcher_host.h" 103 #include "content/browser/speech/speech_recognition_dispatcher_host.h"
104 #include "content/browser/storage_partition_impl.h" 104 #include "content/browser/storage_partition_impl.h"
105 #include "content/browser/streams/stream_context.h" 105 #include "content/browser/streams/stream_context.h"
106 #include "content/browser/tracing/trace_message_filter.h" 106 #include "content/browser/tracing/trace_message_filter.h"
107 #include "content/browser/vibration/vibration_message_filter.h" 107 #include "content/browser/vibration/vibration_message_filter.h"
108 #include "content/browser/webui/web_ui_controller_factory_registry.h" 108 #include "content/browser/webui/web_ui_controller_factory_registry.h"
109 #include "content/browser/worker_host/worker_message_filter.h" 109 #include "content/browser/worker_host/worker_message_filter.h"
110 #include "content/browser/worker_host/worker_storage_partition.h" 110 #include "content/browser/worker_host/worker_storage_partition.h"
111 #include "content/common/child_process_host_impl.h" 111 #include "content/common/child_process_host_impl.h"
112 #include "content/common/child_process_messages.h" 112 #include "content/common/child_process_messages.h"
113 #include "content/common/content_switches_internal.h" 113 #include "content/common/content_switches_internal.h"
114 #include "content/common/gpu/gpu_messages.h" 114 #include "content/common/gpu/gpu_messages.h"
115 #include "content/common/mojo/mojo_messages.h"
115 #include "content/common/resource_messages.h" 116 #include "content/common/resource_messages.h"
116 #include "content/common/view_messages.h" 117 #include "content/common/view_messages.h"
117 #include "content/port/browser/render_widget_host_view_frame_subscriber.h" 118 #include "content/port/browser/render_widget_host_view_frame_subscriber.h"
118 #include "content/public/browser/browser_context.h" 119 #include "content/public/browser/browser_context.h"
119 #include "content/public/browser/content_browser_client.h" 120 #include "content/public/browser/content_browser_client.h"
120 #include "content/public/browser/notification_service.h" 121 #include "content/public/browser/notification_service.h"
121 #include "content/public/browser/notification_types.h" 122 #include "content/public/browser/notification_types.h"
122 #include "content/public/browser/render_process_host_factory.h" 123 #include "content/public/browser/render_process_host_factory.h"
123 #include "content/public/browser/render_process_host_observer.h" 124 #include "content/public/browser/render_process_host_observer.h"
124 #include "content/public/browser/render_widget_host.h" 125 #include "content/public/browser/render_widget_host.h"
125 #include "content/public/browser/render_widget_host_iterator.h" 126 #include "content/public/browser/render_widget_host_iterator.h"
126 #include "content/public/browser/resource_context.h" 127 #include "content/public/browser/resource_context.h"
127 #include "content/public/browser/user_metrics.h" 128 #include "content/public/browser/user_metrics.h"
128 #include "content/public/browser/worker_service.h" 129 #include "content/public/browser/worker_service.h"
129 #include "content/public/common/content_constants.h" 130 #include "content/public/common/content_constants.h"
130 #include "content/public/common/content_switches.h" 131 #include "content/public/common/content_switches.h"
131 #include "content/public/common/process_type.h" 132 #include "content/public/common/process_type.h"
132 #include "content/public/common/result_codes.h" 133 #include "content/public/common/result_codes.h"
133 #include "content/public/common/sandboxed_process_launcher_delegate.h" 134 #include "content/public/common/sandboxed_process_launcher_delegate.h"
134 #include "content/public/common/url_constants.h" 135 #include "content/public/common/url_constants.h"
135 #include "gpu/command_buffer/service/gpu_switches.h" 136 #include "gpu/command_buffer/service/gpu_switches.h"
136 #include "ipc/ipc_channel.h" 137 #include "ipc/ipc_channel.h"
137 #include "ipc/ipc_logging.h" 138 #include "ipc/ipc_logging.h"
138 #include "ipc/ipc_switches.h" 139 #include "ipc/ipc_switches.h"
139 #include "media/base/media_switches.h" 140 #include "media/base/media_switches.h"
141 #include "mojo/common/common_type_converters.h"
142 #include "mojo/public/cpp/bindings/allocation_scope.h"
140 #include "net/url_request/url_request_context_getter.h" 143 #include "net/url_request/url_request_context_getter.h"
141 #include "ppapi/shared_impl/ppapi_switches.h" 144 #include "ppapi/shared_impl/ppapi_switches.h"
142 #include "third_party/skia/include/core/SkBitmap.h" 145 #include "third_party/skia/include/core/SkBitmap.h"
143 #include "ui/base/ui_base_switches.h" 146 #include "ui/base/ui_base_switches.h"
144 #include "ui/events/event_switches.h" 147 #include "ui/events/event_switches.h"
145 #include "ui/gfx/switches.h" 148 #include "ui/gfx/switches.h"
146 #include "ui/gl/gl_switches.h" 149 #include "ui/gl/gl_switches.h"
147 #include "ui/native_theme/native_theme_switches.h" 150 #include "ui/native_theme/native_theme_switches.h"
148 #include "webkit/browser/fileapi/sandbox_file_system_backend.h" 151 #include "webkit/browser/fileapi/sandbox_file_system_backend.h"
149 #include "webkit/common/resource_type.h" 152 #include "webkit/common/resource_type.h"
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after
536 // Setup the IPC channel. 539 // Setup the IPC channel.
537 const std::string channel_id = 540 const std::string channel_id =
538 IPC::Channel::GenerateVerifiedChannelID(std::string()); 541 IPC::Channel::GenerateVerifiedChannelID(std::string());
539 channel_.reset( 542 channel_.reset(
540 new IPC::ChannelProxy(channel_id, 543 new IPC::ChannelProxy(channel_id,
541 IPC::Channel::MODE_SERVER, 544 IPC::Channel::MODE_SERVER,
542 this, 545 this,
543 BrowserThread::GetMessageLoopProxyForThread( 546 BrowserThread::GetMessageLoopProxyForThread(
544 BrowserThread::IO).get())); 547 BrowserThread::IO).get()));
545 548
549 // Setup the Mojo channel.
550 mojo_application_host_.reset(new MojoApplicationHost());
551 mojo_application_host_->Init();
552
546 // Call the embedder first so that their IPC filters have priority. 553 // Call the embedder first so that their IPC filters have priority.
547 GetContentClient()->browser()->RenderProcessWillLaunch(this); 554 GetContentClient()->browser()->RenderProcessWillLaunch(this);
548 555
549 CreateMessageFilters(); 556 CreateMessageFilters();
550 557
551 if (run_renderer_in_process()) { 558 if (run_renderer_in_process()) {
552 DCHECK(g_renderer_main_thread_factory); 559 DCHECK(g_renderer_main_thread_factory);
553 // Crank up a thread and run the initialization there. With the way that 560 // Crank up a thread and run the initialization there. With the way that
554 // messages flow between the browser and renderer, this thread is required 561 // messages flow between the browser and renderer, this thread is required
555 // to prevent a deadlock in single-process mode. Since the primordial 562 // to prevent a deadlock in single-process mode. Since the primordial
(...skipping 1334 matching lines...) Expand 10 before | Expand all | Expand 10 after
1890 while (!iter.IsAtEnd()) { 1897 while (!iter.IsAtEnd()) {
1891 iter.GetCurrentValue()->OnMessageReceived( 1898 iter.GetCurrentValue()->OnMessageReceived(
1892 ViewHostMsg_RenderProcessGone(iter.GetCurrentKey(), 1899 ViewHostMsg_RenderProcessGone(iter.GetCurrentKey(),
1893 static_cast<int>(status), 1900 static_cast<int>(status),
1894 exit_code)); 1901 exit_code));
1895 iter.Advance(); 1902 iter.Advance();
1896 } 1903 }
1897 1904
1898 ClearTransportDIBCache(); 1905 ClearTransportDIBCache();
1899 1906
1900 render_process_host_mojo_.reset(); 1907 mojo_application_host_.reset();
1901 1908
1902 // It's possible that one of the calls out to the observers might have caused 1909 // It's possible that one of the calls out to the observers might have caused
1903 // this object to be no longer needed. 1910 // this object to be no longer needed.
1904 if (delayed_cleanup_needed_) 1911 if (delayed_cleanup_needed_)
1905 Cleanup(); 1912 Cleanup();
1906 1913
1907 // This object is not deleted at this point and might be reused later. 1914 // This object is not deleted at this point and might be reused later.
1908 // TODO(darin): clean this up 1915 // TODO(darin): clean this up
1909 } 1916 }
1910 1917
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
2025 // with state that must be there before any JavaScript executes. 2032 // with state that must be there before any JavaScript executes.
2026 // 2033 //
2027 // The queued messages contain such things as "navigate". If this notification 2034 // The queued messages contain such things as "navigate". If this notification
2028 // was after, we can end up executing JavaScript before the initialization 2035 // was after, we can end up executing JavaScript before the initialization
2029 // happens. 2036 // happens.
2030 NotificationService::current()->Notify( 2037 NotificationService::current()->Notify(
2031 NOTIFICATION_RENDERER_PROCESS_CREATED, 2038 NOTIFICATION_RENDERER_PROCESS_CREATED,
2032 Source<RenderProcessHost>(this), 2039 Source<RenderProcessHost>(this),
2033 NotificationService::NoDetails()); 2040 NotificationService::NoDetails());
2034 2041
2042 // TODO(darin): This is blocked on security review. Un-commenting this will
2043 // allow Mojo calls from all renderers.
2044 #if 0
2045 // Let the Mojo system get setup on the child process side before any other
2046 // IPCs arrive. This way those may safely generate Mojo-related RPCs.
2047 mojo_application_host_->Activate(this, GetHandle());
2048 #endif
2049
2035 while (!queued_messages_.empty()) { 2050 while (!queued_messages_.empty()) {
2036 Send(queued_messages_.front()); 2051 Send(queued_messages_.front());
2037 queued_messages_.pop(); 2052 queued_messages_.pop();
2038 } 2053 }
2039 2054
2040 #if defined(ENABLE_WEBRTC) 2055 #if defined(ENABLE_WEBRTC)
2041 if (WebRTCInternals::GetInstance()->aec_dump_enabled()) 2056 if (WebRTCInternals::GetInstance()->aec_dump_enabled())
2042 EnableAecDump(WebRTCInternals::GetInstance()->aec_dump_file_path()); 2057 EnableAecDump(WebRTCInternals::GetInstance()->aec_dump_file_path());
2043 #endif 2058 #endif
2044
2045 if (render_process_host_mojo_.get())
2046 render_process_host_mojo_->OnProcessLaunched();
2047 } 2059 }
2048 2060
2049 scoped_refptr<AudioRendererHost> 2061 scoped_refptr<AudioRendererHost>
2050 RenderProcessHostImpl::audio_renderer_host() const { 2062 RenderProcessHostImpl::audio_renderer_host() const {
2051 return audio_renderer_host_; 2063 return audio_renderer_host_;
2052 } 2064 }
2053 2065
2054 void RenderProcessHostImpl::OnUserMetricsRecordAction( 2066 void RenderProcessHostImpl::OnUserMetricsRecordAction(
2055 const std::string& action) { 2067 const std::string& action) {
2056 RecordComputedAction(action); 2068 RecordComputedAction(action);
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
2110 } 2122 }
2111 2123
2112 void RenderProcessHostImpl::DecrementWorkerRefCount() { 2124 void RenderProcessHostImpl::DecrementWorkerRefCount() {
2113 DCHECK_CURRENTLY_ON(BrowserThread::UI); 2125 DCHECK_CURRENTLY_ON(BrowserThread::UI);
2114 DCHECK_GT(worker_ref_count_, 0); 2126 DCHECK_GT(worker_ref_count_, 0);
2115 --worker_ref_count_; 2127 --worker_ref_count_;
2116 if (worker_ref_count_ == 0) 2128 if (worker_ref_count_ == 0)
2117 Cleanup(); 2129 Cleanup();
2118 } 2130 }
2119 2131
2120 void RenderProcessHostImpl::SetWebUIHandle( 2132 void RenderProcessHostImpl::ConnectTo(
2121 int32 view_routing_id, 2133 const base::StringPiece& service_name,
2122 mojo::ScopedMessagePipeHandle handle) { 2134 mojo::ScopedMessagePipeHandle handle) {
2123 if (!render_process_host_mojo_) 2135 if (!mojo_application_host_->did_activate())
2124 render_process_host_mojo_.reset(new RenderProcessHostMojoImpl(this)); 2136 mojo_application_host_->Activate(this, GetHandle());
2125 render_process_host_mojo_->SetWebUIHandle(view_routing_id, handle.Pass()); 2137
2138 mojo::AllocationScope scope;
2139 mojo_application_host_->shell_client()->AcceptConnection(service_name,
2140 handle.Pass());
2126 } 2141 }
2127 2142
2128 } // namespace content 2143 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698