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

Unified Diff: ui/gfx/sys_color_change_listener.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
« no previous file with comments | « ui/gfx/screen_win.cc ('k') | ui/gfx/win/singleton_hwnd.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/sys_color_change_listener.cc
diff --git a/ui/gfx/sys_color_change_listener.cc b/ui/gfx/sys_color_change_listener.cc
index 0e5008a66e08a1e0607f08518656829f74b93315..5291a1ec389b349ade65595d5a61cb40016cb3f1 100644
--- a/ui/gfx/sys_color_change_listener.cc
+++ b/ui/gfx/sys_color_change_listener.cc
@@ -9,12 +9,15 @@
#endif
#include "base/basictypes.h"
+#include "base/bind.h"
+#include "base/bind_helpers.h"
+#include "base/memory/scoped_ptr.h"
#include "base/memory/singleton.h"
#include "base/observer_list.h"
#include "ui/gfx/color_utils.h"
#if defined(OS_WIN)
-#include "ui/gfx/win/singleton_hwnd.h"
+#include "ui/gfx/win/singleton_hwnd_observer.h"
#endif
namespace gfx {
@@ -49,7 +52,7 @@ bool IsInvertedColorScheme() {
}
#if defined(OS_WIN)
-class SysColorChangeObserver : public gfx::SingletonHwnd::Observer {
+class SysColorChangeObserver {
public:
static SysColorChangeObserver* GetInstance();
@@ -62,12 +65,10 @@ class SysColorChangeObserver : public gfx::SingletonHwnd::Observer {
SysColorChangeObserver();
virtual ~SysColorChangeObserver();
- void OnWndProc(HWND hwnd,
- UINT message,
- WPARAM wparam,
- LPARAM lparam) override;
+ void OnWndProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam);
ObserverList<SysColorChangeListener> listeners_;
+ scoped_ptr<gfx::SingletonHwndObserver> singleton_hwnd_observer_;
Alexei Svitkine (slow) 2015/05/04 15:44:29 Drive-by: Is there a reason these members are sco
robliao 2015/05/04 17:03:12 See https://codereview.chromium.org/1092183005/#ms
};
// static
@@ -75,13 +76,12 @@ SysColorChangeObserver* SysColorChangeObserver::GetInstance() {
return Singleton<SysColorChangeObserver>::get();
}
-SysColorChangeObserver::SysColorChangeObserver() {
- gfx::SingletonHwnd::GetInstance()->AddObserver(this);
-}
+SysColorChangeObserver::SysColorChangeObserver()
+ : singleton_hwnd_observer_(new SingletonHwndObserver(
+ base::Bind(&SysColorChangeObserver::OnWndProc,
+ base::Unretained(this)))) {}
-SysColorChangeObserver::~SysColorChangeObserver() {
- gfx::SingletonHwnd::GetInstance()->RemoveObserver(this);
-}
+SysColorChangeObserver::~SysColorChangeObserver() {}
void SysColorChangeObserver::AddListener(SysColorChangeListener* listener) {
listeners_.AddObserver(listener);
« no previous file with comments | « ui/gfx/screen_win.cc ('k') | ui/gfx/win/singleton_hwnd.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698