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

Unified Diff: ui/views/win/hwnd_message_handler.cc

Issue 10959020: SystemMonitor refactoring: move power state monitor into a separate class called PowerMonitor (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: add power notifier Created 8 years, 2 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: ui/views/win/hwnd_message_handler.cc
diff --git a/ui/views/win/hwnd_message_handler.cc b/ui/views/win/hwnd_message_handler.cc
index c52deb53156bbe562d5acdd2bfbb693e1f5434a2..28e0b06830dfcb936e2e72e2a58f422ec16dc6d3 100644
--- a/ui/views/win/hwnd_message_handler.cc
+++ b/ui/views/win/hwnd_message_handler.cc
@@ -8,7 +8,7 @@
#include <shellapi.h>
#include "base/bind.h"
-#include "base/system_monitor/system_monitor.h"
+#include "base/power_monitor/power_monitor.h"
#include "base/win/windows_version.h"
#include "ui/base/events/event.h"
#include "ui/base/keycodes/keyboard_code_conversion_win.h"
@@ -40,6 +40,9 @@
namespace views {
namespace {
+// Reference the Notifier defined in the global PowerMonitor instance.
+base::PowerMonitor::Notifier* g_power_notifier = NULL;
vandebo (ex-Chrome) 2012/10/23 01:27:57 Set this in the constructor and assert that we get
+
// MoveLoopMouseWatcher is used to determine if the user canceled or completed a
// move. win32 doesn't appear to offer a way to determine the result of a move,
// so we install hooks to determine if we got a mouse up and assume the move
@@ -1852,9 +1855,11 @@ void HWNDMessageHandler::OnPaint(HDC dc) {
}
LRESULT HWNDMessageHandler::OnPowerBroadcast(DWORD power_event, DWORD data) {
- base::SystemMonitor* monitor = base::SystemMonitor::Get();
- if (monitor)
- monitor->ProcessWmPowerBroadcastMessage(power_event);
+ if (g_power_notifier == NULL)
+ g_power_notifier = base::PowerMonitor::GetInstance()->GetNotifierOnce();
+ if (g_power_notifier)
+ g_power_notifier->ProcessWmPowerBroadcastMessage(power_event);
+
SetMsgHandled(FALSE);
return 0;
}

Powered by Google App Engine
This is Rietveld 408576698