| 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());
|
| + }
|
| +}
|
|
|