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

Unified Diff: chrome/browser/chromeos/cros/power_library.h

Issue 1142005: Mocks for all libcros elements (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 9 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
« no previous file with comments | « chrome/browser/chromeos/cros/network_library.cc ('k') | chrome/browser/chromeos/cros/power_library.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chromeos/cros/power_library.h
===================================================================
--- chrome/browser/chromeos/cros/power_library.h (revision 42341)
+++ chrome/browser/chromeos/cros/power_library.h (working copy)
@@ -12,7 +12,7 @@
namespace chromeos {
-// This class handles the interaction with the ChromeOS power library APIs.
+// This interface defines interaction with the ChromeOS power library APIs.
// Classes can add themselves as observers. Users can get an instance of this
// library class like this: PowerLibrary::Get()
class PowerLibrary {
@@ -21,37 +21,61 @@
public:
virtual void PowerChanged(PowerLibrary* obj) = 0;
};
+ virtual ~PowerLibrary() {}
+ virtual void AddObserver(Observer* observer) = 0;
+ virtual void RemoveObserver(Observer* observer) = 0;
+ // Whether or not the line power is connected.
+ virtual bool line_power_on() const = 0;
- // This gets the singleton PowerLibrary
- static PowerLibrary* Get();
+ // Whether or not the battery is fully charged..
+ virtual bool battery_fully_charged() const = 0;
- void AddObserver(Observer* observer);
- void RemoveObserver(Observer* observer);
+ // The percentage (0-100) of remaining battery.
+ virtual double battery_percentage() const = 0;
+ // Whether there is a battery present.
+ virtual bool battery_is_present() const = 0;
+
+ // The amount of time until battery is empty.
+ virtual base::TimeDelta battery_time_to_empty() const = 0;
+
+ // The amount of time until battery is full.
+ virtual base::TimeDelta battery_time_to_full() const = 0;
+};
+
+
+// This class handles the interaction with the ChromeOS power library APIs.
+// Classes can add themselves as observers. Users can get an instance of this
+// library class like this: PowerLibrary::Get()
+class PowerLibraryImpl : public PowerLibrary {
+ public:
+ PowerLibraryImpl();
+ virtual ~PowerLibraryImpl();
+
+ // PowerLibrary overrides.
+ virtual void AddObserver(Observer* observer);
+ virtual void RemoveObserver(Observer* observer);
+
// Whether or not the line power is connected.
- bool line_power_on() const;
+ virtual bool line_power_on() const;
// Whether or not the battery is fully charged..
- bool battery_fully_charged() const;
+ virtual bool battery_fully_charged() const;
// The percentage (0-100) of remaining battery.
- double battery_percentage() const;
+ virtual double battery_percentage() const;
// Whether there is a battery present.
- bool battery_is_present() const;
+ virtual bool battery_is_present() const;
// The amount of time until battery is empty.
- base::TimeDelta battery_time_to_empty() const;
+ virtual base::TimeDelta battery_time_to_empty() const;
// The amount of time until battery is full.
- base::TimeDelta battery_time_to_full() const;
+ virtual base::TimeDelta battery_time_to_full() const;
private:
- friend struct DefaultSingletonTraits<PowerLibrary>;
- PowerLibrary();
- ~PowerLibrary();
-
// This method is called when there's a change in power status.
// This method is called on a background thread.
static void PowerStatusChangedHandler(void* object,
@@ -73,7 +97,7 @@
// The latest power status.
chromeos::PowerStatus status_;
- DISALLOW_COPY_AND_ASSIGN(PowerLibrary);
+ DISALLOW_COPY_AND_ASSIGN(PowerLibraryImpl);
};
} // namespace chromeos
« no previous file with comments | « chrome/browser/chromeos/cros/network_library.cc ('k') | chrome/browser/chromeos/cros/power_library.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698