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

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: Convert to scoped_ptr 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 2e8f9a56ed19ca8b5506a135419b771dde6f0286..a1c5c315217ff3d3a5f151b6e9743f17f043c03e 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::OnTimeChange, base::Unretained(this)))) {}
sky 2015/04/28 13:20:34 In general, unretained is error prone and it's bes
robliao 2015/04/28 14:11:55 See prior comment about this.
- virtual ~TimeZoneMonitorWin() {
- gfx::SingletonHwnd::GetInstance()->RemoveObserver(this);
- }
+ virtual ~TimeZoneMonitorWin() {}
- // gfx::SingletonHwnd::Observer implementation.
- virtual void OnWndProc(HWND hwnd,
- UINT message,
- WPARAM wparam,
- LPARAM lparam) override {
+ private:
+ void OnTimeChange(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