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

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

Issue 1446363003: Deleted OS_WIN and all Windows specific files from base. (Closed) Base URL: https://github.com/domokit/mojo.git@base_tests
Patch Set: Created 5 years, 1 month 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
« no previous file with comments | « base/port.h ('k') | base/power_monitor/power_monitor_device_source_win.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_DEVICE_SOURCE_H_ 5 #ifndef BASE_POWER_MONITOR_POWER_MONITOR_DEVICE_SOURCE_H_
6 #define BASE_POWER_MONITOR_POWER_MONITOR_DEVICE_SOURCE_H_ 6 #define BASE_POWER_MONITOR_POWER_MONITOR_DEVICE_SOURCE_H_
7 7
8 #include "base/base_export.h" 8 #include "base/base_export.h"
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
11 #include "base/observer_list_threadsafe.h" 11 #include "base/observer_list_threadsafe.h"
12 #include "base/power_monitor/power_monitor_source.h" 12 #include "base/power_monitor/power_monitor_source.h"
13 #include "base/power_monitor/power_observer.h" 13 #include "base/power_monitor/power_observer.h"
14 14
15 #if defined(OS_WIN)
16 #include <windows.h>
17
18 // Windows HiRes timers drain the battery faster so we need to know the battery
19 // status. This isn't true for other platforms.
20 #define ENABLE_BATTERY_MONITORING 1
21 #else
22 #undef ENABLE_BATTERY_MONITORING 15 #undef ENABLE_BATTERY_MONITORING
23 #endif // !OS_WIN
24 16
25 #if defined(ENABLE_BATTERY_MONITORING) 17 #if defined(ENABLE_BATTERY_MONITORING)
26 #include "base/timer/timer.h" 18 #include "base/timer/timer.h"
27 #endif // defined(ENABLE_BATTERY_MONITORING) 19 #endif // defined(ENABLE_BATTERY_MONITORING)
28 20
29 #if defined(OS_IOS) 21 #if defined(OS_IOS)
30 #include <objc/runtime.h> 22 #include <objc/runtime.h>
31 #endif // OS_IOS 23 #endif // OS_IOS
32 24
33 namespace base { 25 namespace base {
(...skipping 21 matching lines...) Expand all
55 // On Chrome OS, Chrome receives power-related events from powerd, the system 47 // On Chrome OS, Chrome receives power-related events from powerd, the system
56 // power daemon, via D-Bus signals received on the UI thread. base can't 48 // power daemon, via D-Bus signals received on the UI thread. base can't
57 // directly depend on that code, so this class instead exposes static methods 49 // directly depend on that code, so this class instead exposes static methods
58 // so that events can be passed in. 50 // so that events can be passed in.
59 static void SetPowerSource(bool on_battery); 51 static void SetPowerSource(bool on_battery);
60 static void HandleSystemSuspending(); 52 static void HandleSystemSuspending();
61 static void HandleSystemResumed(); 53 static void HandleSystemResumed();
62 #endif 54 #endif
63 55
64 private: 56 private:
65 #if defined(OS_WIN)
66 // Represents a message-only window for power message handling on Windows.
67 // Only allow PowerMonitor to create it.
68 class PowerMessageWindow {
69 public:
70 PowerMessageWindow();
71 ~PowerMessageWindow();
72
73 private:
74 static LRESULT CALLBACK WndProcThunk(HWND hwnd,
75 UINT message,
76 WPARAM wparam,
77 LPARAM lparam);
78 // Instance of the module containing the window procedure.
79 HMODULE instance_;
80 // A hidden message-only window.
81 HWND message_hwnd_;
82 };
83 #endif // OS_WIN
84 57
85 #if defined(OS_MACOSX) 58 #if defined(OS_MACOSX)
86 void PlatformInit(); 59 void PlatformInit();
87 void PlatformDestroy(); 60 void PlatformDestroy();
88 #endif 61 #endif
89 62
90 // Platform-specific method to check whether the system is currently 63 // Platform-specific method to check whether the system is currently
91 // running on battery power. Returns true if running on batteries, 64 // running on battery power. Returns true if running on batteries,
92 // false otherwise. 65 // false otherwise.
93 bool IsOnBatteryPowerImpl() override; 66 bool IsOnBatteryPowerImpl() override;
94 67
95 // Checks the battery status and notifies observers if the battery 68 // Checks the battery status and notifies observers if the battery
96 // status has changed. 69 // status has changed.
97 void BatteryCheck(); 70 void BatteryCheck();
98 71
99 #if defined(OS_IOS) 72 #if defined(OS_IOS)
100 // Holds pointers to system event notification observers. 73 // Holds pointers to system event notification observers.
101 std::vector<id> notification_observers_; 74 std::vector<id> notification_observers_;
102 #endif 75 #endif
103 76
104 #if defined(ENABLE_BATTERY_MONITORING) 77 #if defined(ENABLE_BATTERY_MONITORING)
105 base::OneShotTimer<PowerMonitorDeviceSource> delayed_battery_check_; 78 base::OneShotTimer<PowerMonitorDeviceSource> delayed_battery_check_;
106 #endif 79 #endif
107 80
108 #if defined(OS_WIN)
109 PowerMessageWindow power_message_window_;
110 #endif
111
112 DISALLOW_COPY_AND_ASSIGN(PowerMonitorDeviceSource); 81 DISALLOW_COPY_AND_ASSIGN(PowerMonitorDeviceSource);
113 }; 82 };
114 83
115 } // namespace base 84 } // namespace base
116 85
117 #endif // BASE_POWER_MONITOR_POWER_MONITOR_DEVICE_SOURCE_H_ 86 #endif // BASE_POWER_MONITOR_POWER_MONITOR_DEVICE_SOURCE_H_
OLDNEW
« no previous file with comments | « base/port.h ('k') | base/power_monitor/power_monitor_device_source_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698