Chromium Code Reviews| 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); |
| }; |