| 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 22 matching lines...) Expand all Loading... |
| 33 #include "base/strings/string_number_conversions.h" | 33 #include "base/strings/string_number_conversions.h" |
| 34 #include "base/strings/string_util.h" | 34 #include "base/strings/string_util.h" |
| 35 #include "base/supports_user_data.h" | 35 #include "base/supports_user_data.h" |
| 36 #include "base/sys_info.h" | 36 #include "base/sys_info.h" |
| 37 #include "base/threading/thread.h" | 37 #include "base/threading/thread.h" |
| 38 #include "base/threading/thread_restrictions.h" | 38 #include "base/threading/thread_restrictions.h" |
| 39 #include "base/tracked_objects.h" | 39 #include "base/tracked_objects.h" |
| 40 #include "cc/base/switches.h" | 40 #include "cc/base/switches.h" |
| 41 #include "content/browser/appcache/appcache_dispatcher_host.h" | 41 #include "content/browser/appcache/appcache_dispatcher_host.h" |
| 42 #include "content/browser/appcache/chrome_appcache_service.h" | 42 #include "content/browser/appcache/chrome_appcache_service.h" |
| 43 #include "content/browser/battery_status/battery_status_message_filter.h" | |
| 44 #include "content/browser/browser_child_process_host_impl.h" | 43 #include "content/browser/browser_child_process_host_impl.h" |
| 45 #include "content/browser/browser_main.h" | 44 #include "content/browser/browser_main.h" |
| 46 #include "content/browser/browser_main_loop.h" | 45 #include "content/browser/browser_main_loop.h" |
| 47 #include "content/browser/browser_plugin/browser_plugin_message_filter.h" | 46 #include "content/browser/browser_plugin/browser_plugin_message_filter.h" |
| 48 #include "content/browser/child_process_security_policy_impl.h" | 47 #include "content/browser/child_process_security_policy_impl.h" |
| 49 #include "content/browser/device_sensors/device_light_message_filter.h" | 48 #include "content/browser/device_sensors/device_light_message_filter.h" |
| 50 #include "content/browser/device_sensors/device_motion_message_filter.h" | 49 #include "content/browser/device_sensors/device_motion_message_filter.h" |
| 51 #include "content/browser/device_sensors/device_orientation_message_filter.h" | 50 #include "content/browser/device_sensors/device_orientation_message_filter.h" |
| 52 #include "content/browser/dom_storage/dom_storage_context_wrapper.h" | 51 #include "content/browser/dom_storage/dom_storage_context_wrapper.h" |
| 53 #include "content/browser/dom_storage/dom_storage_message_filter.h" | 52 #include "content/browser/dom_storage/dom_storage_message_filter.h" |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 #include "content/public/browser/resource_context.h" | 124 #include "content/public/browser/resource_context.h" |
| 126 #include "content/public/browser/user_metrics.h" | 125 #include "content/public/browser/user_metrics.h" |
| 127 #include "content/public/browser/worker_service.h" | 126 #include "content/public/browser/worker_service.h" |
| 128 #include "content/public/common/content_constants.h" | 127 #include "content/public/common/content_constants.h" |
| 129 #include "content/public/common/content_switches.h" | 128 #include "content/public/common/content_switches.h" |
| 130 #include "content/public/common/process_type.h" | 129 #include "content/public/common/process_type.h" |
| 131 #include "content/public/common/resource_type.h" | 130 #include "content/public/common/resource_type.h" |
| 132 #include "content/public/common/result_codes.h" | 131 #include "content/public/common/result_codes.h" |
| 133 #include "content/public/common/sandboxed_process_launcher_delegate.h" | 132 #include "content/public/common/sandboxed_process_launcher_delegate.h" |
| 134 #include "content/public/common/url_constants.h" | 133 #include "content/public/common/url_constants.h" |
| 134 #include "device/battery/battery_monitor_impl.h" |
| 135 #include "gpu/command_buffer/client/gpu_switches.h" | 135 #include "gpu/command_buffer/client/gpu_switches.h" |
| 136 #include "gpu/command_buffer/service/gpu_switches.h" | 136 #include "gpu/command_buffer/service/gpu_switches.h" |
| 137 #include "ipc/ipc_channel.h" | 137 #include "ipc/ipc_channel.h" |
| 138 #include "ipc/ipc_logging.h" | 138 #include "ipc/ipc_logging.h" |
| 139 #include "ipc/ipc_switches.h" | 139 #include "ipc/ipc_switches.h" |
| 140 #include "ipc/mojo/ipc_channel_mojo.h" | 140 #include "ipc/mojo/ipc_channel_mojo.h" |
| 141 #include "ipc/mojo/ipc_channel_mojo_host.h" | 141 #include "ipc/mojo/ipc_channel_mojo_host.h" |
| 142 #include "media/base/media_switches.h" | 142 #include "media/base/media_switches.h" |
| 143 #include "net/url_request/url_request_context_getter.h" | 143 #include "net/url_request/url_request_context_getter.h" |
| 144 #include "ppapi/shared_impl/ppapi_switches.h" | 144 #include "ppapi/shared_impl/ppapi_switches.h" |
| (...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 580 IPC::Channel::GenerateVerifiedChannelID(std::string()); | 580 IPC::Channel::GenerateVerifiedChannelID(std::string()); |
| 581 channel_ = CreateChannelProxy(channel_id); | 581 channel_ = CreateChannelProxy(channel_id); |
| 582 | 582 |
| 583 // Setup the Mojo channel. | 583 // Setup the Mojo channel. |
| 584 mojo_application_host_->Init(); | 584 mojo_application_host_->Init(); |
| 585 | 585 |
| 586 // Call the embedder first so that their IPC filters have priority. | 586 // Call the embedder first so that their IPC filters have priority. |
| 587 GetContentClient()->browser()->RenderProcessWillLaunch(this); | 587 GetContentClient()->browser()->RenderProcessWillLaunch(this); |
| 588 | 588 |
| 589 CreateMessageFilters(); | 589 CreateMessageFilters(); |
| 590 RegisterMojoServices(); |
| 590 | 591 |
| 591 if (run_renderer_in_process()) { | 592 if (run_renderer_in_process()) { |
| 592 DCHECK(g_renderer_main_thread_factory); | 593 DCHECK(g_renderer_main_thread_factory); |
| 593 // Crank up a thread and run the initialization there. With the way that | 594 // Crank up a thread and run the initialization there. With the way that |
| 594 // messages flow between the browser and renderer, this thread is required | 595 // messages flow between the browser and renderer, this thread is required |
| 595 // to prevent a deadlock in single-process mode. Since the primordial | 596 // to prevent a deadlock in single-process mode. Since the primordial |
| 596 // thread in the renderer process runs the WebKit code and can sometimes | 597 // thread in the renderer process runs the WebKit code and can sometimes |
| 597 // make blocking calls to the UI thread (i.e. this thread), they need to run | 598 // make blocking calls to the UI thread (i.e. this thread), they need to run |
| 598 // on separate threads. | 599 // on separate threads. |
| 599 in_process_renderer_.reset(g_renderer_main_thread_factory(channel_id)); | 600 in_process_renderer_.reset(g_renderer_main_thread_factory(channel_id)); |
| (...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 866 AddFilter(new ProfilerMessageFilter(PROCESS_TYPE_RENDERER)); | 867 AddFilter(new ProfilerMessageFilter(PROCESS_TYPE_RENDERER)); |
| 867 AddFilter(new HistogramMessageFilter()); | 868 AddFilter(new HistogramMessageFilter()); |
| 868 #if defined(USE_TCMALLOC) && (defined(OS_LINUX) || defined(OS_ANDROID)) | 869 #if defined(USE_TCMALLOC) && (defined(OS_LINUX) || defined(OS_ANDROID)) |
| 869 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 870 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 870 switches::kEnableMemoryBenchmarking)) | 871 switches::kEnableMemoryBenchmarking)) |
| 871 AddFilter(new MemoryBenchmarkMessageFilter()); | 872 AddFilter(new MemoryBenchmarkMessageFilter()); |
| 872 #endif | 873 #endif |
| 873 AddFilter(new VibrationMessageFilter()); | 874 AddFilter(new VibrationMessageFilter()); |
| 874 AddFilter(new PushMessagingMessageFilter( | 875 AddFilter(new PushMessagingMessageFilter( |
| 875 GetID(), storage_partition_impl_->GetServiceWorkerContext())); | 876 GetID(), storage_partition_impl_->GetServiceWorkerContext())); |
| 876 AddFilter(new BatteryStatusMessageFilter()); | |
| 877 #if defined(OS_ANDROID) | 877 #if defined(OS_ANDROID) |
| 878 AddFilter(new ScreenOrientationMessageFilterAndroid()); | 878 AddFilter(new ScreenOrientationMessageFilterAndroid()); |
| 879 #endif | 879 #endif |
| 880 AddFilter(new GeofencingDispatcherHost(browser_context_)); | 880 AddFilter(new GeofencingDispatcherHost(browser_context_)); |
| 881 } | 881 } |
| 882 | 882 |
| 883 void RenderProcessHostImpl::RegisterMojoServices() { |
| 884 mojo_application_host_->service_registry()->AddService( |
| 885 base::Bind(&device::BatteryMonitorImpl::Create)); |
| 886 } |
| 887 |
| 883 int RenderProcessHostImpl::GetNextRoutingID() { | 888 int RenderProcessHostImpl::GetNextRoutingID() { |
| 884 return widget_helper_->GetNextRoutingID(); | 889 return widget_helper_->GetNextRoutingID(); |
| 885 } | 890 } |
| 886 | 891 |
| 887 | |
| 888 void RenderProcessHostImpl::ResumeDeferredNavigation( | 892 void RenderProcessHostImpl::ResumeDeferredNavigation( |
| 889 const GlobalRequestID& request_id) { | 893 const GlobalRequestID& request_id) { |
| 890 widget_helper_->ResumeDeferredNavigation(request_id); | 894 widget_helper_->ResumeDeferredNavigation(request_id); |
| 891 } | 895 } |
| 892 | 896 |
| 893 void RenderProcessHostImpl::ResumeResponseDeferredAtStart( | 897 void RenderProcessHostImpl::ResumeResponseDeferredAtStart( |
| 894 const GlobalRequestID& request_id) { | 898 const GlobalRequestID& request_id) { |
| 895 widget_helper_->ResumeResponseDeferredAtStart(request_id); | 899 widget_helper_->ResumeResponseDeferredAtStart(request_id); |
| 896 } | 900 } |
| 897 | 901 |
| (...skipping 1337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2235 | 2239 |
| 2236 void RenderProcessHostImpl::DecrementWorkerRefCount() { | 2240 void RenderProcessHostImpl::DecrementWorkerRefCount() { |
| 2237 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 2241 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 2238 DCHECK_GT(worker_ref_count_, 0); | 2242 DCHECK_GT(worker_ref_count_, 0); |
| 2239 --worker_ref_count_; | 2243 --worker_ref_count_; |
| 2240 if (worker_ref_count_ == 0) | 2244 if (worker_ref_count_ == 0) |
| 2241 Cleanup(); | 2245 Cleanup(); |
| 2242 } | 2246 } |
| 2243 | 2247 |
| 2244 } // namespace content | 2248 } // namespace content |
| OLD | NEW |