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

Side by Side Diff: ui/views/win/windows_session_change_observer.cc

Issue 1162943002: Replace more ObserverList with base::ObserverList. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@observer
Patch Set: Created 5 years, 6 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 unified diff | Download patch
« no previous file with comments | « ui/views/widget/widget.h ('k') | ui/wm/core/compound_event_filter.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/views/win/windows_session_change_observer.h" 5 #include "ui/views/win/windows_session_change_observer.h"
6 6
7 #include <wtsapi32.h> 7 #include <wtsapi32.h>
8 #pragma comment(lib, "wtsapi32.lib") 8 #pragma comment(lib, "wtsapi32.lib")
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 // 1) Destruction due to Singleton Destruction. 92 // 1) Destruction due to Singleton Destruction.
93 // 2) WM_DESTROY fired by SingletonHwnd. 93 // 2) WM_DESTROY fired by SingletonHwnd.
94 // Under both cases we are in shutdown, which means no other worker threads 94 // Under both cases we are in shutdown, which means no other worker threads
95 // can be running. 95 // can be running.
96 WTSUnRegisterSessionNotification(gfx::SingletonHwnd::GetInstance()->hwnd()); 96 WTSUnRegisterSessionNotification(gfx::SingletonHwnd::GetInstance()->hwnd());
97 FOR_EACH_OBSERVER(WindowsSessionChangeObserver, 97 FOR_EACH_OBSERVER(WindowsSessionChangeObserver,
98 observer_list_, 98 observer_list_,
99 ClearCallback()); 99 ClearCallback());
100 } 100 }
101 101
102 ObserverList<WindowsSessionChangeObserver, true> observer_list_; 102 base::ObserverList<WindowsSessionChangeObserver, true> observer_list_;
103 scoped_ptr<gfx::SingletonHwndObserver> singleton_hwnd_observer_; 103 scoped_ptr<gfx::SingletonHwndObserver> singleton_hwnd_observer_;
104 104
105 DISALLOW_COPY_AND_ASSIGN(WtsRegistrationNotificationManager); 105 DISALLOW_COPY_AND_ASSIGN(WtsRegistrationNotificationManager);
106 }; 106 };
107 107
108 WindowsSessionChangeObserver::WindowsSessionChangeObserver( 108 WindowsSessionChangeObserver::WindowsSessionChangeObserver(
109 const WtsCallback& callback) 109 const WtsCallback& callback)
110 : callback_(callback) { 110 : callback_(callback) {
111 DCHECK(!callback_.is_null()); 111 DCHECK(!callback_.is_null());
112 WtsRegistrationNotificationManager::GetInstance()->AddObserver(this); 112 WtsRegistrationNotificationManager::GetInstance()->AddObserver(this);
113 } 113 }
114 114
115 WindowsSessionChangeObserver::~WindowsSessionChangeObserver() { 115 WindowsSessionChangeObserver::~WindowsSessionChangeObserver() {
116 ClearCallback(); 116 ClearCallback();
117 } 117 }
118 118
119 void WindowsSessionChangeObserver::OnSessionChange(WPARAM wparam) { 119 void WindowsSessionChangeObserver::OnSessionChange(WPARAM wparam) {
120 callback_.Run(wparam); 120 callback_.Run(wparam);
121 } 121 }
122 122
123 void WindowsSessionChangeObserver::ClearCallback() { 123 void WindowsSessionChangeObserver::ClearCallback() {
124 if (!callback_.is_null()) { 124 if (!callback_.is_null()) {
125 callback_.Reset(); 125 callback_.Reset();
126 WtsRegistrationNotificationManager::GetInstance()->RemoveObserver(this); 126 WtsRegistrationNotificationManager::GetInstance()->RemoveObserver(this);
127 } 127 }
128 } 128 }
129 129
130 } // namespace views 130 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/widget/widget.h ('k') | ui/wm/core/compound_event_filter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698