| Index: content/browser/battery_status/battery_status_service.h
|
| diff --git a/content/browser/battery_status/battery_status_service.h b/content/browser/battery_status/battery_status_service.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..8d267565772bb0098b205ea1d533bf5e043b4136
|
| --- /dev/null
|
| +++ b/content/browser/battery_status/battery_status_service.h
|
| @@ -0,0 +1,62 @@
|
| +// Copyright 2013 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 CONTENT_BROWSER_BATTERY_STATUS_BATTERY_STATUS_SERVICE_H_
|
| +#define CONTENT_BROWSER_BATTERY_STATUS_BATTERY_STATUS_SERVICE_H_
|
| +
|
| +#include "base/callback_forward.h"
|
| +#include "base/memory/scoped_ptr.h"
|
| +#include "base/memory/singleton.h"
|
| +#include "content/common/content_export.h"
|
| +
|
| +#include "content/browser/battery_status/battery_status_manager_android.h"
|
| +#include <vector>
|
| +
|
| +#include "third_party/WebKit/public/platform/WebBatteryStatus.h"
|
| +
|
| +namespace content {
|
| +
|
| +class CONTENT_EXPORT BatteryStatusService {
|
| + public:
|
| + // Returns the BatteryStatusService singleton.
|
| + static BatteryStatusService* GetInstance();
|
| +
|
| + typedef base::Callback<void(const blink::WebBatteryStatus&)> BatteryStatusUpdateCallback;
|
| +
|
| + // Adds a callback to receive battery status updates.
|
| + // Must be called on the I/O thread.
|
| + void AddConsumer(const BatteryStatusUpdateCallback& callback);
|
| +
|
| + // Removes a callback. Must be called on the I/O thread.
|
| + void RemoveConsumer(const BatteryStatusUpdateCallback& callback);
|
| +
|
| + // TODO: is this needed?
|
| + void Shutdown();
|
| +
|
| + // Injects a custom battery status manager for testing purposes. This class takes
|
| + // ownership of the injected object.
|
| + //void SetDataFetcherForTests(BatteryStatusManager* test_data_fetcher);
|
| +
|
| + void UpdateBatteryStatus(bool charging, double chargingTime, double dischargingTime, double level);
|
| + const blink::WebBatteryStatus& GetBatteryStatus() const;
|
| +
|
| + private:
|
| + friend struct DefaultSingletonTraits<BatteryStatusService>;
|
| +
|
| + BatteryStatusService();
|
| + virtual ~BatteryStatusService();
|
| +
|
| + void NotifyConsumers();
|
| +
|
| + bool is_shutdown_;
|
| + scoped_ptr<BatteryStatusManagerAndroid> battery_fetcher_;
|
| + std::vector<BatteryStatusUpdateCallback> callbacks_;
|
| + blink::WebBatteryStatus status_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(BatteryStatusService);
|
| +};
|
| +
|
| +} // namespace content
|
| +
|
| +#endif // CONTENT_BROWSER_BATTERY_STATUS_BATTERY_STATUS_SERVICE_H_
|
|
|