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

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

Issue 1868363002: Replace scoped_ptr with std::unique_ptr in //ui (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@scopedptrcc
Patch Set: scopedptrui: rebase-make_scoped_ptr Created 4 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 unified diff | Download patch
« no previous file with comments | « ui/views/win/hwnd_message_handler.cc ('k') | ui/views/window/custom_frame_view.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 8
9 #include <memory>
10
9 #include "base/bind.h" 11 #include "base/bind.h"
10 #include "base/bind_helpers.h" 12 #include "base/bind_helpers.h"
11 #include "base/callback.h" 13 #include "base/callback.h"
12 #include "base/location.h" 14 #include "base/location.h"
13 #include "base/macros.h" 15 #include "base/macros.h"
14 #include "base/memory/ref_counted.h" 16 #include "base/memory/ref_counted.h"
15 #include "base/memory/scoped_ptr.h"
16 #include "base/memory/singleton.h" 17 #include "base/memory/singleton.h"
17 #include "base/observer_list.h" 18 #include "base/observer_list.h"
18 #include "base/task_runner.h" 19 #include "base/task_runner.h"
19 #include "ui/gfx/win/singleton_hwnd.h" 20 #include "ui/gfx/win/singleton_hwnd.h"
20 #include "ui/gfx/win/singleton_hwnd_observer.h" 21 #include "ui/gfx/win/singleton_hwnd_observer.h"
21 #include "ui/views/views_delegate.h" 22 #include "ui/views/views_delegate.h"
22 23
23 namespace views { 24 namespace views {
24 25
25 class WindowsSessionChangeObserver::WtsRegistrationNotificationManager { 26 class WindowsSessionChangeObserver::WtsRegistrationNotificationManager {
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 // 2) WM_DESTROY fired by SingletonHwnd. 95 // 2) WM_DESTROY fired by SingletonHwnd.
95 // Under both cases we are in shutdown, which means no other worker threads 96 // Under both cases we are in shutdown, which means no other worker threads
96 // can be running. 97 // can be running.
97 WTSUnRegisterSessionNotification(gfx::SingletonHwnd::GetInstance()->hwnd()); 98 WTSUnRegisterSessionNotification(gfx::SingletonHwnd::GetInstance()->hwnd());
98 FOR_EACH_OBSERVER(WindowsSessionChangeObserver, 99 FOR_EACH_OBSERVER(WindowsSessionChangeObserver,
99 observer_list_, 100 observer_list_,
100 ClearCallback()); 101 ClearCallback());
101 } 102 }
102 103
103 base::ObserverList<WindowsSessionChangeObserver, true> observer_list_; 104 base::ObserverList<WindowsSessionChangeObserver, true> observer_list_;
104 scoped_ptr<gfx::SingletonHwndObserver> singleton_hwnd_observer_; 105 std::unique_ptr<gfx::SingletonHwndObserver> singleton_hwnd_observer_;
105 106
106 DISALLOW_COPY_AND_ASSIGN(WtsRegistrationNotificationManager); 107 DISALLOW_COPY_AND_ASSIGN(WtsRegistrationNotificationManager);
107 }; 108 };
108 109
109 WindowsSessionChangeObserver::WindowsSessionChangeObserver( 110 WindowsSessionChangeObserver::WindowsSessionChangeObserver(
110 const WtsCallback& callback) 111 const WtsCallback& callback)
111 : callback_(callback) { 112 : callback_(callback) {
112 DCHECK(!callback_.is_null()); 113 DCHECK(!callback_.is_null());
113 WtsRegistrationNotificationManager::GetInstance()->AddObserver(this); 114 WtsRegistrationNotificationManager::GetInstance()->AddObserver(this);
114 } 115 }
115 116
116 WindowsSessionChangeObserver::~WindowsSessionChangeObserver() { 117 WindowsSessionChangeObserver::~WindowsSessionChangeObserver() {
117 ClearCallback(); 118 ClearCallback();
118 } 119 }
119 120
120 void WindowsSessionChangeObserver::OnSessionChange(WPARAM wparam) { 121 void WindowsSessionChangeObserver::OnSessionChange(WPARAM wparam) {
121 callback_.Run(wparam); 122 callback_.Run(wparam);
122 } 123 }
123 124
124 void WindowsSessionChangeObserver::ClearCallback() { 125 void WindowsSessionChangeObserver::ClearCallback() {
125 if (!callback_.is_null()) { 126 if (!callback_.is_null()) {
126 callback_.Reset(); 127 callback_.Reset();
127 WtsRegistrationNotificationManager::GetInstance()->RemoveObserver(this); 128 WtsRegistrationNotificationManager::GetInstance()->RemoveObserver(this);
128 } 129 }
129 } 130 }
130 131
131 } // namespace views 132 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/win/hwnd_message_handler.cc ('k') | ui/views/window/custom_frame_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698