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

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

Issue 685703002: Reland "Replace Chrome IPC with Mojo IPC for querying BatteryStatus service" (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address Tim's comments. Created 6 years, 1 month 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
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 22 matching lines...) Expand all
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
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 434 matching lines...) Expand 10 before | Expand all | Expand 10 after
579 IPC::Channel::GenerateVerifiedChannelID(std::string()); 579 IPC::Channel::GenerateVerifiedChannelID(std::string());
580 channel_ = CreateChannelProxy(channel_id); 580 channel_ = CreateChannelProxy(channel_id);
581 581
582 // Setup the Mojo channel. 582 // Setup the Mojo channel.
583 mojo_application_host_->Init(); 583 mojo_application_host_->Init();
584 584
585 // Call the embedder first so that their IPC filters have priority. 585 // Call the embedder first so that their IPC filters have priority.
586 GetContentClient()->browser()->RenderProcessWillLaunch(this); 586 GetContentClient()->browser()->RenderProcessWillLaunch(this);
587 587
588 CreateMessageFilters(); 588 CreateMessageFilters();
589 RegisterMojoServices();
589 590
590 if (run_renderer_in_process()) { 591 if (run_renderer_in_process()) {
591 DCHECK(g_renderer_main_thread_factory); 592 DCHECK(g_renderer_main_thread_factory);
592 // Crank up a thread and run the initialization there. With the way that 593 // 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 594 // messages flow between the browser and renderer, this thread is required
594 // to prevent a deadlock in single-process mode. Since the primordial 595 // to prevent a deadlock in single-process mode. Since the primordial
595 // thread in the renderer process runs the WebKit code and can sometimes 596 // 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 597 // make blocking calls to the UI thread (i.e. this thread), they need to run
597 // on separate threads. 598 // on separate threads.
598 in_process_renderer_.reset(g_renderer_main_thread_factory(channel_id)); 599 in_process_renderer_.reset(g_renderer_main_thread_factory(channel_id));
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
858 AddFilter(new ProfilerMessageFilter(PROCESS_TYPE_RENDERER)); 859 AddFilter(new ProfilerMessageFilter(PROCESS_TYPE_RENDERER));
859 AddFilter(new HistogramMessageFilter()); 860 AddFilter(new HistogramMessageFilter());
860 #if defined(USE_TCMALLOC) && (defined(OS_LINUX) || defined(OS_ANDROID)) 861 #if defined(USE_TCMALLOC) && (defined(OS_LINUX) || defined(OS_ANDROID))
861 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 862 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
862 switches::kEnableMemoryBenchmarking)) 863 switches::kEnableMemoryBenchmarking))
863 AddFilter(new MemoryBenchmarkMessageFilter()); 864 AddFilter(new MemoryBenchmarkMessageFilter());
864 #endif 865 #endif
865 AddFilter(new VibrationMessageFilter()); 866 AddFilter(new VibrationMessageFilter());
866 AddFilter(new PushMessagingMessageFilter( 867 AddFilter(new PushMessagingMessageFilter(
867 GetID(), storage_partition_impl_->GetServiceWorkerContext())); 868 GetID(), storage_partition_impl_->GetServiceWorkerContext()));
868 AddFilter(new BatteryStatusMessageFilter());
869 #if defined(OS_ANDROID) 869 #if defined(OS_ANDROID)
870 AddFilter(new ScreenOrientationMessageFilterAndroid()); 870 AddFilter(new ScreenOrientationMessageFilterAndroid());
871 #endif 871 #endif
872 AddFilter(new GeofencingDispatcherHost( 872 AddFilter(new GeofencingDispatcherHost(
873 storage_partition_impl_->GetGeofencingManager())); 873 storage_partition_impl_->GetGeofencingManager()));
874 } 874 }
875 875
876 void RenderProcessHostImpl::RegisterMojoServices() {
877 mojo_application_host_->service_registry()->AddService(
878 base::Bind(&device::BatteryMonitorImpl::Create));
879 }
880
876 int RenderProcessHostImpl::GetNextRoutingID() { 881 int RenderProcessHostImpl::GetNextRoutingID() {
877 return widget_helper_->GetNextRoutingID(); 882 return widget_helper_->GetNextRoutingID();
878 } 883 }
879 884
880
881 void RenderProcessHostImpl::ResumeDeferredNavigation( 885 void RenderProcessHostImpl::ResumeDeferredNavigation(
882 const GlobalRequestID& request_id) { 886 const GlobalRequestID& request_id) {
883 widget_helper_->ResumeDeferredNavigation(request_id); 887 widget_helper_->ResumeDeferredNavigation(request_id);
884 } 888 }
885 889
886 void RenderProcessHostImpl::ResumeResponseDeferredAtStart( 890 void RenderProcessHostImpl::ResumeResponseDeferredAtStart(
887 const GlobalRequestID& request_id) { 891 const GlobalRequestID& request_id) {
888 widget_helper_->ResumeResponseDeferredAtStart(request_id); 892 widget_helper_->ResumeResponseDeferredAtStart(request_id);
889 } 893 }
890 894
(...skipping 1341 matching lines...) Expand 10 before | Expand all | Expand 10 after
2232 2236
2233 void RenderProcessHostImpl::DecrementWorkerRefCount() { 2237 void RenderProcessHostImpl::DecrementWorkerRefCount() {
2234 DCHECK_CURRENTLY_ON(BrowserThread::UI); 2238 DCHECK_CURRENTLY_ON(BrowserThread::UI);
2235 DCHECK_GT(worker_ref_count_, 0); 2239 DCHECK_GT(worker_ref_count_, 0);
2236 --worker_ref_count_; 2240 --worker_ref_count_;
2237 if (worker_ref_count_ == 0) 2241 if (worker_ref_count_ == 0)
2238 Cleanup(); 2242 Cleanup();
2239 } 2243 }
2240 2244
2241 } // namespace content 2245 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_process_host_impl.h ('k') | content/common/battery_status_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698