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

Side by Side Diff: base/power_monitor/power_monitor_source.h

Issue 2351593004: Implement base::PowerMonitor::IsOnBatteryPower() for OSX. (Closed)
Patch Set: Invert setter. Created 4 years, 3 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef BASE_POWER_MONITOR_POWER_MONITOR_SOURCE_H_ 5 #ifndef BASE_POWER_MONITOR_POWER_MONITOR_SOURCE_H_
6 #define BASE_POWER_MONITOR_POWER_MONITOR_SOURCE_H_ 6 #define BASE_POWER_MONITOR_POWER_MONITOR_SOURCE_H_
7 7
8 #include "base/base_export.h" 8 #include "base/base_export.h"
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 42
43 // ProcessPowerEvent should only be called from a single thread, most likely 43 // ProcessPowerEvent should only be called from a single thread, most likely
44 // the UI thread or, in child processes, the IO thread. 44 // the UI thread or, in child processes, the IO thread.
45 static void ProcessPowerEvent(PowerEvent event_id); 45 static void ProcessPowerEvent(PowerEvent event_id);
46 46
47 // Platform-specific method to check whether the system is currently 47 // Platform-specific method to check whether the system is currently
48 // running on battery power. Returns true if running on batteries, 48 // running on battery power. Returns true if running on batteries,
49 // false otherwise. 49 // false otherwise.
50 virtual bool IsOnBatteryPowerImpl() = 0; 50 virtual bool IsOnBatteryPowerImpl() = 0;
51 51
52 // Sets the initial state for |on_battery_power_|, which defaults to false
53 // since not all implementations can provide the value at construction. May
54 // only be called before a base::PowerMonitor has been created.
55 void SetInitialOnBatteryPowerState(bool on_battery_power);
56
52 private: 57 private:
53 bool on_battery_power_; 58 bool on_battery_power_ = false;
54 bool suspended_; 59 bool suspended_ = false;
55 60
56 // This lock guards access to on_battery_power_, to ensure that 61 // This lock guards access to on_battery_power_, to ensure that
57 // IsOnBatteryPower can be called from any thread. 62 // IsOnBatteryPower can be called from any thread.
58 Lock battery_lock_; 63 Lock battery_lock_;
59 64
60 DISALLOW_COPY_AND_ASSIGN(PowerMonitorSource); 65 DISALLOW_COPY_AND_ASSIGN(PowerMonitorSource);
61 }; 66 };
62 67
63 } // namespace base 68 } // namespace base
64 69
65 #endif // BASE_POWER_MONITOR_POWER_MONITOR_SOURCE_H_ 70 #endif // BASE_POWER_MONITOR_POWER_MONITOR_SOURCE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698