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

Unified Diff: content/public/android/java/src/org/chromium/content/browser/ServiceRegistrar.java

Issue 641703002: Rewrite the Android implementation of BatteryMonitor directly in Java. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@battery-status-api-to-mojo
Patch Set: Address Torne's comment. Created 6 years 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
« no previous file with comments | « content/public/android/DEPS ('k') | content/shell/browser/shell_mojo_test_utils_android.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/public/android/java/src/org/chromium/content/browser/ServiceRegistrar.java
diff --git a/content/public/android/java/src/org/chromium/content/browser/ServiceRegistrar.java b/content/public/android/java/src/org/chromium/content/browser/ServiceRegistrar.java
new file mode 100644
index 0000000000000000000000000000000000000000..39b3a9739921880ca72f03dff0b14177ccb6f433
--- /dev/null
+++ b/content/public/android/java/src/org/chromium/content/browser/ServiceRegistrar.java
@@ -0,0 +1,34 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package org.chromium.content.browser;
+
+import org.chromium.base.CalledByNative;
+import org.chromium.base.JNINamespace;
+import org.chromium.content.browser.ServiceRegistry.ImplementationFactory;
+import org.chromium.device.battery.BatteryMonitorFactory;
+import org.chromium.mojom.device.BatteryMonitor;
+
+/**
+ * Registers mojo services exposed by the browser in the given registry.
+ */
+@JNINamespace("content")
+class ServiceRegistrar {
+ // BatteryMonitorFactory can't implement ImplementationFactory itself, as we don't depend on
+ // /content in /device. Hence we use BatteryMonitorImplementationFactory as a wrapper.
+ private static class BatteryMonitorImplementationFactory
+ implements ImplementationFactory<BatteryMonitor> {
+ private final BatteryMonitorFactory mFactory = new BatteryMonitorFactory();
+
+ @Override
+ public BatteryMonitor createImpl() {
+ return mFactory.createMonitor();
+ }
+ }
+
+ @CalledByNative
+ static void registerProcessHostServices(ServiceRegistry registry) {
+ registry.addService(BatteryMonitor.MANAGER, new BatteryMonitorImplementationFactory());
+ }
+}
« no previous file with comments | « content/public/android/DEPS ('k') | content/shell/browser/shell_mojo_test_utils_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698