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

Unified Diff: device/battery/android/java/src/org/chromium/device/battery/BatteryMonitorImpl.java

Issue 2818673003: [DeviceService] Expose battery monitoring solely via the Device Service (Closed)
Patch Set: Java file format change Created 3 years, 8 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: device/battery/android/java/src/org/chromium/device/battery/BatteryMonitorImpl.java
diff --git a/device/battery/android/java/src/org/chromium/device/battery/BatteryMonitorImpl.java b/device/battery/android/java/src/org/chromium/device/battery/BatteryMonitorImpl.java
deleted file mode 100644
index 907e516702779feef09bec4dc5f59360475fe6f6..0000000000000000000000000000000000000000
--- a/device/battery/android/java/src/org/chromium/device/battery/BatteryMonitorImpl.java
+++ /dev/null
@@ -1,80 +0,0 @@
-// 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.device.battery;
-
-import android.util.Log;
-
-import org.chromium.device.mojom.BatteryMonitor;
-import org.chromium.device.mojom.BatteryStatus;
-import org.chromium.mojo.system.MojoException;
-
-/**
- * Android implementation of the battery monitor service defined in
- * device/battery/battery_monitor.mojom.
- */
-public class BatteryMonitorImpl implements BatteryMonitor {
-
- private static final String TAG = "BatteryMonitorImpl";
-
- // Factory that created this instance and notifies it about battery status changes.
- private final BatteryMonitorFactory mFactory;
- private QueryNextStatusResponse mCallback;
- private BatteryStatus mStatus;
- private boolean mHasStatusToReport;
- private boolean mSubscribed;
-
- public BatteryMonitorImpl(BatteryMonitorFactory batteryMonitorFactory) {
- mFactory = batteryMonitorFactory;
- mHasStatusToReport = false;
- mSubscribed = true;
- }
-
- private void unsubscribe() {
- if (mSubscribed) {
- mFactory.unsubscribe(this);
- mSubscribed = false;
- }
- }
-
- @Override
- public void close() {
- unsubscribe();
- }
-
- @Override
- public void onConnectionError(MojoException e) {
- unsubscribe();
- }
-
- @Override
- public void queryNextStatus(QueryNextStatusResponse callback) {
- if (mCallback != null) {
- Log.e(TAG, "Overlapped call to queryNextStatus!");
- unsubscribe();
- return;
- }
-
- mCallback = callback;
-
- if (mHasStatusToReport) {
- reportStatus();
- }
- }
-
- void didChange(BatteryStatus batteryStatus) {
- mStatus = batteryStatus;
- mHasStatusToReport = true;
-
- if (mCallback != null) {
- reportStatus();
- }
- }
-
- void reportStatus() {
- mCallback.call(mStatus);
- mCallback = null;
- mHasStatusToReport = false;
- }
-}

Powered by Google App Engine
This is Rietveld 408576698