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

Unified Diff: content/browser/battery_status/battery_status_manager.h

Issue 267893003: Battery Status API: add plumbing for multi-platform support. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 6 years, 7 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/battery_status/battery_status_manager.h
diff --git a/content/browser/battery_status/battery_status_manager.h b/content/browser/battery_status/battery_status_manager.h
new file mode 100644
index 0000000000000000000000000000000000000000..6b4c3487216701fbbba395dcd24c8447c3053b3a
--- /dev/null
+++ b/content/browser/battery_status/battery_status_manager.h
@@ -0,0 +1,54 @@
+// 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.
+
+#ifndef CHROME_BROWSER_BATTERY_STATUS_BATTERY_STATUS_MANAGER_H_
+#define CHROME_BROWSER_BATTERY_STATUS_BATTERY_STATUS_MANAGER_H_
+
+#include "build/build_config.h"
+
+#if defined(OS_ANDROID)
+#include "base/android/scoped_java_ref.h"
+#endif
+
+#include "content/browser/battery_status/battery_status_update_callback.h"
+#include "content/common/content_export.h"
+
+namespace content {
+
+// Platform specific manager class for fetching battery status data.
+class CONTENT_EXPORT BatteryStatusManager {
+ public:
+ explicit BatteryStatusManager(const BatteryStatusUpdateCallback& callback);
+ virtual ~BatteryStatusManager();
+
+ // Start listening for battery status changes. New updates are signalled
+ // by invoking the callback provided at construction time.
+ bool StartListeningBatteryChange();
+
+ // Stop listenting for battery status changes.
+ void StopListeningBatteryChange();
+
+#if defined(OS_ANDROID)
+ // Must be called at startup.
+ static bool Register(JNIEnv* env);
+
+ // Called from Java via JNI.
+ void GotBatteryStatus(JNIEnv*, jobject, jboolean charging,
+ jdouble charging_time, jdouble discharging_time,
+ jdouble level);
+#endif
+
+ private:
+#if defined(OS_ANDROID)
+ // Java provider of battery status info.
+ base::android::ScopedJavaGlobalRef<jobject> j_manager_;
+#endif
+ BatteryStatusUpdateCallback callback_;
+
+ DISALLOW_COPY_AND_ASSIGN(BatteryStatusManager);
+};
+
+} // namespace content
+
+#endif // CHROME_BROWSER_BATTERY_STATUS_BATTERY_STATUS_MANAGER_H_
« no previous file with comments | « content/browser/android/browser_jni_registrar.cc ('k') | content/browser/battery_status/battery_status_manager_android.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698