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

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

Issue 256403004: Move Mojo channel initialization closer to IPC::Channel setup (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: another ios fix 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 381 matching lines...) Expand 10 before | Expand all | Expand 10 after
531 // Setup the IPC channel. 534 // Setup the IPC channel.
532 const std::string channel_id = 535 const std::string channel_id =
533 IPC::Channel::GenerateVerifiedChannelID(std::string()); 536 IPC::Channel::GenerateVerifiedChannelID(std::string());
534 channel_.reset( 537 channel_.reset(
535 new IPC::ChannelProxy(channel_id, 538 new IPC::ChannelProxy(channel_id,
536 IPC::Channel::MODE_SERVER, 539 IPC::Channel::MODE_SERVER,
537 this, 540 this,
538 BrowserThread::GetMessageLoopProxyForThread( 541 BrowserThread::GetMessageLoopProxyForThread(
539 BrowserThread::IO).get())); 542 BrowserThread::IO).get()));
540 543
544 // Setup the Mojo channel.
545 mojo_application_host_.reset(new MojoApplicationHost());
546 mojo_application_host_->Init();
547
541 // Call the embedder first so that their IPC filters have priority. 548 // Call the embedder first so that their IPC filters have priority.
542 GetContentClient()->browser()->RenderProcessWillLaunch(this); 549 GetContentClient()->browser()->RenderProcessWillLaunch(this);
543 550
544 CreateMessageFilters(); 551 CreateMessageFilters();
545 552
546 if (run_renderer_in_process()) { 553 if (run_renderer_in_process()) {
547 DCHECK(g_renderer_main_thread_factory); 554 DCHECK(g_renderer_main_thread_factory);
548 // Crank up a thread and run the initialization there. With the way that 555 // Crank up a thread and run the initialization there. With the way that
549 // messages flow between the browser and renderer, this thread is required 556 // messages flow between the browser and renderer, this thread is required
550 // to prevent a deadlock in single-process mode. Since the primordial 557 // to prevent a deadlock in single-process mode. Since the primordial
(...skipping 1269 matching lines...) Expand 10 before | Expand all | Expand 10 after
1820 1827
1821 IDMap<IPC::Listener>::iterator iter(&listeners_); 1828 IDMap<IPC::Listener>::iterator iter(&listeners_);
1822 while (!iter.IsAtEnd()) { 1829 while (!iter.IsAtEnd()) {
1823 iter.GetCurrentValue()->OnMessageReceived( 1830 iter.GetCurrentValue()->OnMessageReceived(
1824 ViewHostMsg_RenderProcessGone(iter.GetCurrentKey(), 1831 ViewHostMsg_RenderProcessGone(iter.GetCurrentKey(),
1825 static_cast<int>(status), 1832 static_cast<int>(status),
1826 exit_code)); 1833 exit_code));
1827 iter.Advance(); 1834 iter.Advance();
1828 } 1835 }
1829 1836
1830 render_process_host_mojo_.reset(); 1837 mojo_application_host_.reset();
1831 1838
1832 // It's possible that one of the calls out to the observers might have caused 1839 // It's possible that one of the calls out to the observers might have caused
1833 // this object to be no longer needed. 1840 // this object to be no longer needed.
1834 if (delayed_cleanup_needed_) 1841 if (delayed_cleanup_needed_)
1835 Cleanup(); 1842 Cleanup();
1836 1843
1837 // This object is not deleted at this point and might be reused later. 1844 // This object is not deleted at this point and might be reused later.
1838 // TODO(darin): clean this up 1845 // TODO(darin): clean this up
1839 } 1846 }
1840 1847
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
1955 // with state that must be there before any JavaScript executes. 1962 // with state that must be there before any JavaScript executes.
1956 // 1963 //
1957 // The queued messages contain such things as "navigate". If this notification 1964 // The queued messages contain such things as "navigate". If this notification
1958 // was after, we can end up executing JavaScript before the initialization 1965 // was after, we can end up executing JavaScript before the initialization
1959 // happens. 1966 // happens.
1960 NotificationService::current()->Notify( 1967 NotificationService::current()->Notify(
1961 NOTIFICATION_RENDERER_PROCESS_CREATED, 1968 NOTIFICATION_RENDERER_PROCESS_CREATED,
1962 Source<RenderProcessHost>(this), 1969 Source<RenderProcessHost>(this),
1963 NotificationService::NoDetails()); 1970 NotificationService::NoDetails());
1964 1971
1972 // TODO(darin): This is blocked on security review. Un-commenting this will
1973 // allow Mojo calls from all renderers.
1974 #if 0
1975 // Let the Mojo system get setup on the child process side before any other
1976 // IPCs arrive. This way those may safely generate Mojo-related RPCs.
1977 mojo_application_host_->Activate(this, GetHandle());
1978 #endif
1979
1965 while (!queued_messages_.empty()) { 1980 while (!queued_messages_.empty()) {
1966 Send(queued_messages_.front()); 1981 Send(queued_messages_.front());
1967 queued_messages_.pop(); 1982 queued_messages_.pop();
1968 } 1983 }
1969 1984
1970 #if defined(ENABLE_WEBRTC) 1985 #if defined(ENABLE_WEBRTC)
1971 if (WebRTCInternals::GetInstance()->aec_dump_enabled()) 1986 if (WebRTCInternals::GetInstance()->aec_dump_enabled())
1972 EnableAecDump(WebRTCInternals::GetInstance()->aec_dump_file_path()); 1987 EnableAecDump(WebRTCInternals::GetInstance()->aec_dump_file_path());
1973 #endif 1988 #endif
1974
1975 if (render_process_host_mojo_.get())
1976 render_process_host_mojo_->OnProcessLaunched();
1977 } 1989 }
1978 1990
1979 scoped_refptr<AudioRendererHost> 1991 scoped_refptr<AudioRendererHost>
1980 RenderProcessHostImpl::audio_renderer_host() const { 1992 RenderProcessHostImpl::audio_renderer_host() const {
1981 return audio_renderer_host_; 1993 return audio_renderer_host_;
1982 } 1994 }
1983 1995
1984 void RenderProcessHostImpl::OnUserMetricsRecordAction( 1996 void RenderProcessHostImpl::OnUserMetricsRecordAction(
1985 const std::string& action) { 1997 const std::string& action) {
1986 RecordComputedAction(action); 1998 RecordComputedAction(action);
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
2040 } 2052 }
2041 2053
2042 void RenderProcessHostImpl::DecrementWorkerRefCount() { 2054 void RenderProcessHostImpl::DecrementWorkerRefCount() {
2043 DCHECK_CURRENTLY_ON(BrowserThread::UI); 2055 DCHECK_CURRENTLY_ON(BrowserThread::UI);
2044 DCHECK_GT(worker_ref_count_, 0); 2056 DCHECK_GT(worker_ref_count_, 0);
2045 --worker_ref_count_; 2057 --worker_ref_count_;
2046 if (worker_ref_count_ == 0) 2058 if (worker_ref_count_ == 0)
2047 Cleanup(); 2059 Cleanup();
2048 } 2060 }
2049 2061
2050 void RenderProcessHostImpl::SetWebUIHandle( 2062 void RenderProcessHostImpl::ConnectTo(
2051 int32 view_routing_id, 2063 const base::StringPiece& service_name,
2052 mojo::ScopedMessagePipeHandle handle) { 2064 mojo::ScopedMessagePipeHandle handle) {
2053 if (!render_process_host_mojo_) 2065 if (!mojo_application_host_->did_activate())
2054 render_process_host_mojo_.reset(new RenderProcessHostMojoImpl(this)); 2066 mojo_application_host_->Activate(this, GetHandle());
2055 render_process_host_mojo_->SetWebUIHandle(view_routing_id, handle.Pass()); 2067
2068 mojo::AllocationScope scope;
2069 mojo_application_host_->shell_client()->AcceptConnection(service_name,
2070 handle.Pass());
2056 } 2071 }
2057 2072
2058 } // namespace content 2073 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698