| 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" |
| 43 #include "content/browser/browser_child_process_host_impl.h" | 44 #include "content/browser/browser_child_process_host_impl.h" |
| 44 #include "content/browser/browser_main.h" | 45 #include "content/browser/browser_main.h" |
| 45 #include "content/browser/browser_main_loop.h" | 46 #include "content/browser/browser_main_loop.h" |
| 46 #include "content/browser/browser_plugin/browser_plugin_message_filter.h" | 47 #include "content/browser/browser_plugin/browser_plugin_message_filter.h" |
| 47 #include "content/browser/child_process_security_policy_impl.h" | 48 #include "content/browser/child_process_security_policy_impl.h" |
| 48 #include "content/browser/device_sensors/device_light_message_filter.h" | 49 #include "content/browser/device_sensors/device_light_message_filter.h" |
| 49 #include "content/browser/device_sensors/device_motion_message_filter.h" | 50 #include "content/browser/device_sensors/device_motion_message_filter.h" |
| 50 #include "content/browser/device_sensors/device_orientation_message_filter.h" | 51 #include "content/browser/device_sensors/device_orientation_message_filter.h" |
| 51 #include "content/browser/dom_storage/dom_storage_context_wrapper.h" | 52 #include "content/browser/dom_storage/dom_storage_context_wrapper.h" |
| 52 #include "content/browser/dom_storage/dom_storage_message_filter.h" | 53 #include "content/browser/dom_storage/dom_storage_message_filter.h" |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 #include "content/public/browser/resource_context.h" | 124 #include "content/public/browser/resource_context.h" |
| 124 #include "content/public/browser/user_metrics.h" | 125 #include "content/public/browser/user_metrics.h" |
| 125 #include "content/public/browser/worker_service.h" | 126 #include "content/public/browser/worker_service.h" |
| 126 #include "content/public/common/content_constants.h" | 127 #include "content/public/common/content_constants.h" |
| 127 #include "content/public/common/content_switches.h" | 128 #include "content/public/common/content_switches.h" |
| 128 #include "content/public/common/process_type.h" | 129 #include "content/public/common/process_type.h" |
| 129 #include "content/public/common/resource_type.h" | 130 #include "content/public/common/resource_type.h" |
| 130 #include "content/public/common/result_codes.h" | 131 #include "content/public/common/result_codes.h" |
| 131 #include "content/public/common/sandboxed_process_launcher_delegate.h" | 132 #include "content/public/common/sandboxed_process_launcher_delegate.h" |
| 132 #include "content/public/common/url_constants.h" | 133 #include "content/public/common/url_constants.h" |
| 133 #include "device/battery/battery_monitor_impl.h" | |
| 134 #include "gpu/command_buffer/client/gpu_switches.h" | 134 #include "gpu/command_buffer/client/gpu_switches.h" |
| 135 #include "gpu/command_buffer/service/gpu_switches.h" | 135 #include "gpu/command_buffer/service/gpu_switches.h" |
| 136 #include "ipc/ipc_channel.h" | 136 #include "ipc/ipc_channel.h" |
| 137 #include "ipc/ipc_logging.h" | 137 #include "ipc/ipc_logging.h" |
| 138 #include "ipc/ipc_switches.h" | 138 #include "ipc/ipc_switches.h" |
| 139 #include "ipc/mojo/ipc_channel_mojo.h" | 139 #include "ipc/mojo/ipc_channel_mojo.h" |
| 140 #include "ipc/mojo/ipc_channel_mojo_host.h" | 140 #include "ipc/mojo/ipc_channel_mojo_host.h" |
| 141 #include "media/base/media_switches.h" | 141 #include "media/base/media_switches.h" |
| 142 #include "net/url_request/url_request_context_getter.h" | 142 #include "net/url_request/url_request_context_getter.h" |
| 143 #include "ppapi/shared_impl/ppapi_switches.h" | 143 #include "ppapi/shared_impl/ppapi_switches.h" |
| (...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 578 IPC::Channel::GenerateVerifiedChannelID(std::string()); | 578 IPC::Channel::GenerateVerifiedChannelID(std::string()); |
| 579 channel_ = CreateChannelProxy(channel_id); | 579 channel_ = CreateChannelProxy(channel_id); |
| 580 | 580 |
| 581 // Setup the Mojo channel. | 581 // Setup the Mojo channel. |
| 582 mojo_application_host_->Init(); | 582 mojo_application_host_->Init(); |
| 583 | 583 |
| 584 // Call the embedder first so that their IPC filters have priority. | 584 // Call the embedder first so that their IPC filters have priority. |
| 585 GetContentClient()->browser()->RenderProcessWillLaunch(this); | 585 GetContentClient()->browser()->RenderProcessWillLaunch(this); |
| 586 | 586 |
| 587 CreateMessageFilters(); | 587 CreateMessageFilters(); |
| 588 RegisterMojoServices(); | |
| 589 | 588 |
| 590 if (run_renderer_in_process()) { | 589 if (run_renderer_in_process()) { |
| 591 DCHECK(g_renderer_main_thread_factory); | 590 DCHECK(g_renderer_main_thread_factory); |
| 592 // Crank up a thread and run the initialization there. With the way that | 591 // Crank up a thread and run the initialization there. With the way that |
| 593 // messages flow between the browser and renderer, this thread is required | 592 // messages flow between the browser and renderer, this thread is required |
| 594 // to prevent a deadlock in single-process mode. Since the primordial | 593 // to prevent a deadlock in single-process mode. Since the primordial |
| 595 // thread in the renderer process runs the WebKit code and can sometimes | 594 // thread in the renderer process runs the WebKit code and can sometimes |
| 596 // make blocking calls to the UI thread (i.e. this thread), they need to run | 595 // make blocking calls to the UI thread (i.e. this thread), they need to run |
| 597 // on separate threads. | 596 // on separate threads. |
| 598 in_process_renderer_.reset(g_renderer_main_thread_factory(channel_id)); | 597 in_process_renderer_.reset(g_renderer_main_thread_factory(channel_id)); |
| (...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 855 AddFilter(new ProfilerMessageFilter(PROCESS_TYPE_RENDERER)); | 854 AddFilter(new ProfilerMessageFilter(PROCESS_TYPE_RENDERER)); |
| 856 AddFilter(new HistogramMessageFilter()); | 855 AddFilter(new HistogramMessageFilter()); |
| 857 #if defined(USE_TCMALLOC) && (defined(OS_LINUX) || defined(OS_ANDROID)) | 856 #if defined(USE_TCMALLOC) && (defined(OS_LINUX) || defined(OS_ANDROID)) |
| 858 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 857 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 859 switches::kEnableMemoryBenchmarking)) | 858 switches::kEnableMemoryBenchmarking)) |
| 860 AddFilter(new MemoryBenchmarkMessageFilter()); | 859 AddFilter(new MemoryBenchmarkMessageFilter()); |
| 861 #endif | 860 #endif |
| 862 AddFilter(new VibrationMessageFilter()); | 861 AddFilter(new VibrationMessageFilter()); |
| 863 AddFilter(new PushMessagingMessageFilter( | 862 AddFilter(new PushMessagingMessageFilter( |
| 864 GetID(), storage_partition_impl_->GetServiceWorkerContext())); | 863 GetID(), storage_partition_impl_->GetServiceWorkerContext())); |
| 864 AddFilter(new BatteryStatusMessageFilter()); |
| 865 #if defined(OS_ANDROID) | 865 #if defined(OS_ANDROID) |
| 866 AddFilter(new ScreenOrientationMessageFilterAndroid()); | 866 AddFilter(new ScreenOrientationMessageFilterAndroid()); |
| 867 #endif | 867 #endif |
| 868 AddFilter(new GeofencingDispatcherHost( | 868 AddFilter(new GeofencingDispatcherHost( |
| 869 storage_partition_impl_->GetGeofencingManager())); | 869 storage_partition_impl_->GetGeofencingManager())); |
| 870 } | 870 } |
| 871 | 871 |
| 872 void RenderProcessHostImpl::RegisterMojoServices() { | |
| 873 mojo_application_host_->service_registry()->AddService( | |
| 874 base::Bind(&device::BatteryMonitorImpl::Create)); | |
| 875 } | |
| 876 | |
| 877 int RenderProcessHostImpl::GetNextRoutingID() { | 872 int RenderProcessHostImpl::GetNextRoutingID() { |
| 878 return widget_helper_->GetNextRoutingID(); | 873 return widget_helper_->GetNextRoutingID(); |
| 879 } | 874 } |
| 880 | 875 |
| 876 |
| 881 void RenderProcessHostImpl::ResumeDeferredNavigation( | 877 void RenderProcessHostImpl::ResumeDeferredNavigation( |
| 882 const GlobalRequestID& request_id) { | 878 const GlobalRequestID& request_id) { |
| 883 widget_helper_->ResumeDeferredNavigation(request_id); | 879 widget_helper_->ResumeDeferredNavigation(request_id); |
| 884 } | 880 } |
| 885 | 881 |
| 886 void RenderProcessHostImpl::ResumeResponseDeferredAtStart( | 882 void RenderProcessHostImpl::ResumeResponseDeferredAtStart( |
| 887 const GlobalRequestID& request_id) { | 883 const GlobalRequestID& request_id) { |
| 888 widget_helper_->ResumeResponseDeferredAtStart(request_id); | 884 widget_helper_->ResumeResponseDeferredAtStart(request_id); |
| 889 } | 885 } |
| 890 | 886 |
| (...skipping 1341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2232 | 2228 |
| 2233 void RenderProcessHostImpl::DecrementWorkerRefCount() { | 2229 void RenderProcessHostImpl::DecrementWorkerRefCount() { |
| 2234 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 2230 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 2235 DCHECK_GT(worker_ref_count_, 0); | 2231 DCHECK_GT(worker_ref_count_, 0); |
| 2236 --worker_ref_count_; | 2232 --worker_ref_count_; |
| 2237 if (worker_ref_count_ == 0) | 2233 if (worker_ref_count_ == 0) |
| 2238 Cleanup(); | 2234 Cleanup(); |
| 2239 } | 2235 } |
| 2240 | 2236 |
| 2241 } // namespace content | 2237 } // namespace content |
| OLD | NEW |