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

Unified Diff: content/browser/time_zone_monitor_win.cc

Issue 1092183005: Fix Up SingletonHwnd Observer Lifetime Issues (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Allow null SingletonHwnd Hwnd Created 5 years, 8 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: content/browser/time_zone_monitor_win.cc
diff --git a/content/browser/time_zone_monitor_win.cc b/content/browser/time_zone_monitor_win.cc
index f9205bc7a4a39db10ba7584be8bc936db976d926..abeaafff81cadc84ceb4f7547b09a59c4b724d91 100644
--- a/content/browser/time_zone_monitor_win.cc
+++ b/content/browser/time_zone_monitor_win.cc
@@ -7,26 +7,25 @@
#include <windows.h>
#include "base/basictypes.h"
-#include "ui/gfx/win/singleton_hwnd.h"
+#include "base/bind.h"
+#include "base/bind_helpers.h"
+#include "base/memory/scoped_ptr.h"
+#include "ui/gfx/win/singleton_hwnd_observer.h"
namespace content {
-class TimeZoneMonitorWin : public TimeZoneMonitor,
- public gfx::SingletonHwnd::Observer {
+class TimeZoneMonitorWin : public TimeZoneMonitor {
public:
- TimeZoneMonitorWin() : TimeZoneMonitor() {
- gfx::SingletonHwnd::GetInstance()->AddObserver(this);
- }
+ TimeZoneMonitorWin()
+ : TimeZoneMonitor(),
+ singleton_hwnd_observer_(
+ new gfx::SingletonHwndObserver(base::Bind(
+ &TimeZoneMonitorWin::OnWndProc, base::Unretained(this)))) {}
- ~TimeZoneMonitorWin() override {
- gfx::SingletonHwnd::GetInstance()->RemoveObserver(this);
- }
+ ~TimeZoneMonitorWin() override {}
- // gfx::SingletonHwnd::Observer implementation.
- void OnWndProc(HWND hwnd,
- UINT message,
- WPARAM wparam,
- LPARAM lparam) override {
+ private:
+ void OnWndProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam) {
if (message != WM_TIMECHANGE) {
return;
}
@@ -34,7 +33,8 @@ class TimeZoneMonitorWin : public TimeZoneMonitor,
NotifyRenderers();
}
- private:
+ scoped_ptr<gfx::SingletonHwndObserver> singleton_hwnd_observer_;
+
DISALLOW_COPY_AND_ASSIGN(TimeZoneMonitorWin);
};

Powered by Google App Engine
This is Rietveld 408576698