OLD | NEW |
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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 #include "content/browser/histogram_message_filter.h" | 60 #include "content/browser/histogram_message_filter.h" |
61 #include "content/browser/indexed_db/indexed_db_context_impl.h" | 61 #include "content/browser/indexed_db/indexed_db_context_impl.h" |
62 #include "content/browser/indexed_db/indexed_db_dispatcher_host.h" | 62 #include "content/browser/indexed_db/indexed_db_dispatcher_host.h" |
63 #include "content/browser/loader/resource_message_filter.h" | 63 #include "content/browser/loader/resource_message_filter.h" |
64 #include "content/browser/loader/resource_scheduler_filter.h" | 64 #include "content/browser/loader/resource_scheduler_filter.h" |
65 #include "content/browser/media/capture/audio_mirroring_manager.h" | 65 #include "content/browser/media/capture/audio_mirroring_manager.h" |
66 #include "content/browser/media/media_internals.h" | 66 #include "content/browser/media/media_internals.h" |
67 #include "content/browser/media/midi_host.h" | 67 #include "content/browser/media/midi_host.h" |
68 #include "content/browser/message_port_message_filter.h" | 68 #include "content/browser/message_port_message_filter.h" |
69 #include "content/browser/mime_registry_message_filter.h" | 69 #include "content/browser/mime_registry_message_filter.h" |
70 #include "content/browser/mojo/mojo_application_host.h" | |
71 #include "content/browser/plugin_service_impl.h" | 70 #include "content/browser/plugin_service_impl.h" |
72 #include "content/browser/profiler_message_filter.h" | 71 #include "content/browser/profiler_message_filter.h" |
73 #include "content/browser/push_messaging_message_filter.h" | 72 #include "content/browser/push_messaging_message_filter.h" |
74 #include "content/browser/quota_dispatcher_host.h" | 73 #include "content/browser/quota_dispatcher_host.h" |
75 #include "content/browser/renderer_host/clipboard_message_filter.h" | 74 #include "content/browser/renderer_host/clipboard_message_filter.h" |
76 #include "content/browser/renderer_host/database_message_filter.h" | 75 #include "content/browser/renderer_host/database_message_filter.h" |
77 #include "content/browser/renderer_host/file_utilities_message_filter.h" | 76 #include "content/browser/renderer_host/file_utilities_message_filter.h" |
78 #include "content/browser/renderer_host/gamepad_browser_message_filter.h" | 77 #include "content/browser/renderer_host/gamepad_browser_message_filter.h" |
79 #include "content/browser/renderer_host/gpu_message_filter.h" | 78 #include "content/browser/renderer_host/gpu_message_filter.h" |
80 #include "content/browser/renderer_host/media/audio_input_renderer_host.h" | 79 #include "content/browser/renderer_host/media/audio_input_renderer_host.h" |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 #include "content/public/common/content_switches.h" | 131 #include "content/public/common/content_switches.h" |
133 #include "content/public/common/process_type.h" | 132 #include "content/public/common/process_type.h" |
134 #include "content/public/common/result_codes.h" | 133 #include "content/public/common/result_codes.h" |
135 #include "content/public/common/sandboxed_process_launcher_delegate.h" | 134 #include "content/public/common/sandboxed_process_launcher_delegate.h" |
136 #include "content/public/common/url_constants.h" | 135 #include "content/public/common/url_constants.h" |
137 #include "gpu/command_buffer/service/gpu_switches.h" | 136 #include "gpu/command_buffer/service/gpu_switches.h" |
138 #include "ipc/ipc_channel.h" | 137 #include "ipc/ipc_channel.h" |
139 #include "ipc/ipc_logging.h" | 138 #include "ipc/ipc_logging.h" |
140 #include "ipc/ipc_switches.h" | 139 #include "ipc/ipc_switches.h" |
141 #include "media/base/media_switches.h" | 140 #include "media/base/media_switches.h" |
142 #include "mojo/common/common_type_converters.h" | |
143 #include "net/url_request/url_request_context_getter.h" | 141 #include "net/url_request/url_request_context_getter.h" |
144 #include "ppapi/shared_impl/ppapi_switches.h" | 142 #include "ppapi/shared_impl/ppapi_switches.h" |
145 #include "third_party/skia/include/core/SkBitmap.h" | 143 #include "third_party/skia/include/core/SkBitmap.h" |
146 #include "ui/base/ui_base_switches.h" | 144 #include "ui/base/ui_base_switches.h" |
147 #include "ui/events/event_switches.h" | 145 #include "ui/events/event_switches.h" |
148 #include "ui/gfx/switches.h" | 146 #include "ui/gfx/switches.h" |
149 #include "ui/gl/gl_switches.h" | 147 #include "ui/gl/gl_switches.h" |
150 #include "ui/native_theme/native_theme_switches.h" | 148 #include "ui/native_theme/native_theme_switches.h" |
151 #include "webkit/browser/fileapi/sandbox_file_system_backend.h" | 149 #include "webkit/browser/fileapi/sandbox_file_system_backend.h" |
152 #include "webkit/common/resource_type.h" | 150 #include "webkit/common/resource_type.h" |
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
438 RenderProcessHostImpl::RenderProcessHostImpl( | 436 RenderProcessHostImpl::RenderProcessHostImpl( |
439 BrowserContext* browser_context, | 437 BrowserContext* browser_context, |
440 StoragePartitionImpl* storage_partition_impl, | 438 StoragePartitionImpl* storage_partition_impl, |
441 bool is_isolated_guest) | 439 bool is_isolated_guest) |
442 : fast_shutdown_started_(false), | 440 : fast_shutdown_started_(false), |
443 deleting_soon_(false), | 441 deleting_soon_(false), |
444 #ifndef NDEBUG | 442 #ifndef NDEBUG |
445 is_self_deleted_(false), | 443 is_self_deleted_(false), |
446 #endif | 444 #endif |
447 pending_views_(0), | 445 pending_views_(0), |
| 446 mojo_application_host_(new MojoApplicationHost), |
448 mojo_activation_required_(false), | 447 mojo_activation_required_(false), |
449 visible_widgets_(0), | 448 visible_widgets_(0), |
450 backgrounded_(true), | 449 backgrounded_(true), |
451 is_initialized_(false), | 450 is_initialized_(false), |
452 id_(ChildProcessHostImpl::GenerateChildProcessUniqueId()), | 451 id_(ChildProcessHostImpl::GenerateChildProcessUniqueId()), |
453 browser_context_(browser_context), | 452 browser_context_(browser_context), |
454 storage_partition_impl_(storage_partition_impl), | 453 storage_partition_impl_(storage_partition_impl), |
455 sudden_termination_allowed_(true), | 454 sudden_termination_allowed_(true), |
456 ignore_input_events_(false), | 455 ignore_input_events_(false), |
457 is_isolated_guest_(is_isolated_guest), | 456 is_isolated_guest_(is_isolated_guest), |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
587 // Setup the IPC channel. | 586 // Setup the IPC channel. |
588 const std::string channel_id = | 587 const std::string channel_id = |
589 IPC::Channel::GenerateVerifiedChannelID(std::string()); | 588 IPC::Channel::GenerateVerifiedChannelID(std::string()); |
590 channel_ = IPC::ChannelProxy::Create( | 589 channel_ = IPC::ChannelProxy::Create( |
591 channel_id, | 590 channel_id, |
592 IPC::Channel::MODE_SERVER, | 591 IPC::Channel::MODE_SERVER, |
593 this, | 592 this, |
594 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO).get()); | 593 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO).get()); |
595 | 594 |
596 // Setup the Mojo channel. | 595 // Setup the Mojo channel. |
597 mojo_application_host_.reset(new MojoApplicationHost()); | |
598 mojo_application_host_->Init(); | 596 mojo_application_host_->Init(); |
599 | 597 |
600 // Call the embedder first so that their IPC filters have priority. | 598 // Call the embedder first so that their IPC filters have priority. |
601 GetContentClient()->browser()->RenderProcessWillLaunch(this); | 599 GetContentClient()->browser()->RenderProcessWillLaunch(this); |
602 | 600 |
603 CreateMessageFilters(); | 601 CreateMessageFilters(); |
604 | 602 |
605 if (run_renderer_in_process()) { | 603 if (run_renderer_in_process()) { |
606 DCHECK(g_renderer_main_thread_factory); | 604 DCHECK(g_renderer_main_thread_factory); |
607 // Crank up a thread and run the initialization there. With the way that | 605 // Crank up a thread and run the initialization there. With the way that |
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
893 | 891 |
894 void RenderProcessHostImpl::ResumeDeferredNavigation( | 892 void RenderProcessHostImpl::ResumeDeferredNavigation( |
895 const GlobalRequestID& request_id) { | 893 const GlobalRequestID& request_id) { |
896 widget_helper_->ResumeDeferredNavigation(request_id); | 894 widget_helper_->ResumeDeferredNavigation(request_id); |
897 } | 895 } |
898 | 896 |
899 void RenderProcessHostImpl::NotifyTimezoneChange() { | 897 void RenderProcessHostImpl::NotifyTimezoneChange() { |
900 Send(new ViewMsg_TimezoneChange()); | 898 Send(new ViewMsg_TimezoneChange()); |
901 } | 899 } |
902 | 900 |
| 901 ServiceRegistry* RenderProcessHostImpl::GetServiceRegistry() { |
| 902 if (!mojo_application_host_) |
| 903 return NULL; |
| 904 return mojo_application_host_->service_registry(); |
| 905 } |
| 906 |
903 void RenderProcessHostImpl::AddRoute( | 907 void RenderProcessHostImpl::AddRoute( |
904 int32 routing_id, | 908 int32 routing_id, |
905 IPC::Listener* listener) { | 909 IPC::Listener* listener) { |
906 listeners_.AddWithID(listener, routing_id); | 910 listeners_.AddWithID(listener, routing_id); |
907 } | 911 } |
908 | 912 |
909 void RenderProcessHostImpl::RemoveRoute(int32 routing_id) { | 913 void RenderProcessHostImpl::RemoveRoute(int32 routing_id) { |
910 DCHECK(listeners_.Lookup(routing_id) != NULL); | 914 DCHECK(listeners_.Lookup(routing_id) != NULL); |
911 listeners_.Remove(routing_id); | 915 listeners_.Remove(routing_id); |
912 | 916 |
(...skipping 1004 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1917 | 1921 |
1918 IDMap<IPC::Listener>::iterator iter(&listeners_); | 1922 IDMap<IPC::Listener>::iterator iter(&listeners_); |
1919 while (!iter.IsAtEnd()) { | 1923 while (!iter.IsAtEnd()) { |
1920 iter.GetCurrentValue()->OnMessageReceived( | 1924 iter.GetCurrentValue()->OnMessageReceived( |
1921 ViewHostMsg_RenderProcessGone(iter.GetCurrentKey(), | 1925 ViewHostMsg_RenderProcessGone(iter.GetCurrentKey(), |
1922 static_cast<int>(status), | 1926 static_cast<int>(status), |
1923 exit_code)); | 1927 exit_code)); |
1924 iter.Advance(); | 1928 iter.Advance(); |
1925 } | 1929 } |
1926 | 1930 |
1927 mojo_application_host_.reset(); | 1931 mojo_application_host_.reset(new MojoApplicationHost); |
1928 | 1932 |
1929 // It's possible that one of the calls out to the observers might have caused | 1933 // It's possible that one of the calls out to the observers might have caused |
1930 // this object to be no longer needed. | 1934 // this object to be no longer needed. |
1931 if (delayed_cleanup_needed_) | 1935 if (delayed_cleanup_needed_) |
1932 Cleanup(); | 1936 Cleanup(); |
1933 | 1937 |
1934 // This object is not deleted at this point and might be reused later. | 1938 // This object is not deleted at this point and might be reused later. |
1935 // TODO(darin): clean this up | 1939 // TODO(darin): clean this up |
1936 } | 1940 } |
1937 | 1941 |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2174 } | 2178 } |
2175 | 2179 |
2176 void RenderProcessHostImpl::DecrementWorkerRefCount() { | 2180 void RenderProcessHostImpl::DecrementWorkerRefCount() { |
2177 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 2181 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
2178 DCHECK_GT(worker_ref_count_, 0); | 2182 DCHECK_GT(worker_ref_count_, 0); |
2179 --worker_ref_count_; | 2183 --worker_ref_count_; |
2180 if (worker_ref_count_ == 0) | 2184 if (worker_ref_count_ == 0) |
2181 Cleanup(); | 2185 Cleanup(); |
2182 } | 2186 } |
2183 | 2187 |
2184 void RenderProcessHostImpl::ConnectTo( | 2188 void RenderProcessHostImpl::ActivateMojo() { |
2185 const base::StringPiece& service_name, | |
2186 mojo::ScopedMessagePipeHandle handle) { | |
2187 mojo_activation_required_ = true; | 2189 mojo_activation_required_ = true; |
2188 MaybeActivateMojo(); | 2190 MaybeActivateMojo(); |
2189 | |
2190 mojo_application_host_->service_provider()->ConnectToService( | |
2191 mojo::String::From(service_name), | |
2192 std::string(), | |
2193 handle.Pass(), | |
2194 mojo::String()); | |
2195 } | 2191 } |
2196 | 2192 |
2197 void RenderProcessHostImpl::OnAllocateGpuMemoryBuffer(uint32 width, | 2193 void RenderProcessHostImpl::OnAllocateGpuMemoryBuffer(uint32 width, |
2198 uint32 height, | 2194 uint32 height, |
2199 uint32 internalformat, | 2195 uint32 internalformat, |
2200 uint32 usage, | 2196 uint32 usage, |
2201 IPC::Message* reply) { | 2197 IPC::Message* reply) { |
2202 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 2198 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
2203 if (!GpuMemoryBufferImpl::IsFormatValid(internalformat) || | 2199 if (!GpuMemoryBufferImpl::IsFormatValid(internalformat) || |
2204 !GpuMemoryBufferImpl::IsUsageValid(usage)) { | 2200 !GpuMemoryBufferImpl::IsUsageValid(usage)) { |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2289 void RenderProcessHostImpl::GpuMemoryBufferAllocated( | 2285 void RenderProcessHostImpl::GpuMemoryBufferAllocated( |
2290 IPC::Message* reply, | 2286 IPC::Message* reply, |
2291 const gfx::GpuMemoryBufferHandle& handle) { | 2287 const gfx::GpuMemoryBufferHandle& handle) { |
2292 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 2288 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
2293 ChildProcessHostMsg_SyncAllocateGpuMemoryBuffer::WriteReplyParams(reply, | 2289 ChildProcessHostMsg_SyncAllocateGpuMemoryBuffer::WriteReplyParams(reply, |
2294 handle); | 2290 handle); |
2295 Send(reply); | 2291 Send(reply); |
2296 } | 2292 } |
2297 | 2293 |
2298 } // namespace content | 2294 } // namespace content |
OLD | NEW |