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

Unified Diff: content/browser/renderer_host/render_process_host_impl.cc

Issue 592153002: 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, 3 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/renderer_host/render_process_host_impl.cc
diff --git a/content/browser/renderer_host/render_process_host_impl.cc b/content/browser/renderer_host/render_process_host_impl.cc
index 9e46f2276abb407dbfdf3d0364f90284256dfecc..22ea73b3b7c0c5e794ba0d190d45801948133383 100644
--- a/content/browser/renderer_host/render_process_host_impl.cc
+++ b/content/browser/renderer_host/render_process_host_impl.cc
@@ -40,7 +40,6 @@
#include "cc/base/switches.h"
#include "content/browser/appcache/appcache_dispatcher_host.h"
#include "content/browser/appcache/chrome_appcache_service.h"
-#include "content/browser/battery_status/battery_status_message_filter.h"
#include "content/browser/browser_child_process_host_impl.h"
#include "content/browser/browser_main.h"
#include "content/browser/browser_main_loop.h"
@@ -132,6 +131,7 @@
#include "content/public/common/result_codes.h"
#include "content/public/common/sandboxed_process_launcher_delegate.h"
#include "content/public/common/url_constants.h"
+#include "device/battery/battery_monitor_impl.h"
#include "gpu/command_buffer/service/gpu_switches.h"
#include "ipc/ipc_channel.h"
#include "ipc/ipc_logging.h"
@@ -439,7 +439,6 @@ RenderProcessHostImpl::RenderProcessHostImpl(
#endif
pending_views_(0),
mojo_application_host_(new MojoApplicationHost),
- mojo_activation_required_(false),
visible_widgets_(0),
backgrounded_(true),
is_initialized_(false),
@@ -587,6 +586,7 @@ bool RenderProcessHostImpl::Init() {
GetContentClient()->browser()->RenderProcessWillLaunch(this);
CreateMessageFilters();
+ RegisterMojoServices();
if (run_renderer_in_process()) {
DCHECK(g_renderer_main_thread_factory);
@@ -644,20 +644,6 @@ bool RenderProcessHostImpl::Init() {
return true;
}
-void RenderProcessHostImpl::MaybeActivateMojo() {
- // TODO(darin): Following security review, we can unconditionally initialize
- // Mojo in all renderers. We will then be able to directly call Activate()
- // from OnProcessLaunched.
- if (!mojo_activation_required_)
- return; // Waiting on someone to require Mojo.
-
- if (!GetHandle())
- return; // Waiting on renderer startup.
-
- if (!mojo_application_host_->did_activate())
- mojo_application_host_->Activate(this, GetHandle());
-}
-
bool RenderProcessHostImpl::ShouldUseMojoChannel() const {
const base::CommandLine& command_line =
*base::CommandLine::ForCurrentProcess();
@@ -887,17 +873,20 @@ void RenderProcessHostImpl::CreateMessageFilters() {
AddFilter(new VibrationMessageFilter());
AddFilter(new PushMessagingMessageFilter(
GetID(), storage_partition_impl_->GetServiceWorkerContext()));
- AddFilter(new BatteryStatusMessageFilter());
#if defined(OS_ANDROID)
AddFilter(new ScreenOrientationMessageFilterAndroid());
#endif
}
+void RenderProcessHostImpl::RegisterMojoServices() {
+ mojo_application_host_->service_registry()->AddService(
+ base::Bind(&device::BatteryMonitorImpl::Create));
+}
+
int RenderProcessHostImpl::GetNextRoutingID() {
return widget_helper_->GetNextRoutingID();
}
-
void RenderProcessHostImpl::ResumeDeferredNavigation(
const GlobalRequestID& request_id) {
widget_helper_->ResumeDeferredNavigation(request_id);
@@ -1936,7 +1925,6 @@ void RenderProcessHostImpl::ProcessDied(bool already_dead) {
}
mojo_application_host_.reset(new MojoApplicationHost);
- mojo_activation_required_ = false;
// It's possible that one of the calls out to the observers might have caused
// this object to be no longer needed.
@@ -2103,7 +2091,7 @@ void RenderProcessHostImpl::OnProcessLaunched() {
// Allow Mojo to be setup before the renderer sees any Chrome IPC messages.
// This way, Mojo can be safely used from the renderer in response to any
// Chrome IPC message.
- MaybeActivateMojo();
+ mojo_application_host_->Activate(this, GetHandle());
timvolodine 2014/09/30 16:26:01 as qsr@ already mentioned on my patch this appears
ppi 2014/10/06 13:50:02 Yup, both patches need to wait for the fix before
if (channel_mojo_host_)
channel_mojo_host_->OnClientLaunched(GetHandle());
@@ -2247,9 +2235,4 @@ void RenderProcessHostImpl::DecrementWorkerRefCount() {
Cleanup();
}
-void RenderProcessHostImpl::EnsureMojoActivated() {
- mojo_activation_required_ = true;
- MaybeActivateMojo();
-}
-
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698