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

Side by Side Diff: chrome/browser/ui/views/status_icons/status_tray_state_changer_win.cc

Issue 2909213002: Replace deprecated base::NonThreadSafe in chrome/browser/ui/views in favor of SequenceChecker. (Closed)
Patch Set: SequenceChecker => ThreadChecker for StatusTrayStateChangerWin Created 3 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "chrome/browser/ui/views/status_icons/status_tray_state_changer_win.h" 5 #include "chrome/browser/ui/views/status_icons/status_tray_state_changer_win.h"
6 6
7 #include <objbase.h> 7 #include <objbase.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 : interface_version_(INTERFACE_VERSION_UNKNOWN), 55 : interface_version_(INTERFACE_VERSION_UNKNOWN),
56 icon_id_(icon_id), 56 icon_id_(icon_id),
57 window_(window) { 57 window_(window) {
58 wchar_t module_name[MAX_PATH]; 58 wchar_t module_name[MAX_PATH];
59 ::GetModuleFileName(NULL, module_name, MAX_PATH); 59 ::GetModuleFileName(NULL, module_name, MAX_PATH);
60 60
61 file_name_ = module_name; 61 file_name_ = module_name;
62 } 62 }
63 63
64 void StatusTrayStateChangerWin::EnsureTrayIconVisible() { 64 void StatusTrayStateChangerWin::EnsureTrayIconVisible() {
65 DCHECK(CalledOnValidThread()); 65 DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
66 66
67 if (!CreateTrayNotify()) { 67 if (!CreateTrayNotify()) {
68 VLOG(1) << "Unable to create COM object for ITrayNotify."; 68 VLOG(1) << "Unable to create COM object for ITrayNotify.";
69 return; 69 return;
70 } 70 }
71 71
72 std::unique_ptr<NOTIFYITEM> notify_item = RegisterCallback(); 72 std::unique_ptr<NOTIFYITEM> notify_item = RegisterCallback();
73 73
74 // If the user has already hidden us explicitly, try to honor their choice by 74 // If the user has already hidden us explicitly, try to honor their choice by
75 // not changing anything. 75 // not changing anything.
76 if (notify_item->preference == PREFERENCE_SHOW_NEVER) 76 if (notify_item->preference == PREFERENCE_SHOW_NEVER)
77 return; 77 return;
78 78
79 // If we are already on the taskbar, return since nothing needs to be done. 79 // If we are already on the taskbar, return since nothing needs to be done.
80 if (notify_item->preference == PREFERENCE_SHOW_ALWAYS) 80 if (notify_item->preference == PREFERENCE_SHOW_ALWAYS)
81 return; 81 return;
82 82
83 notify_item->preference = PREFERENCE_SHOW_ALWAYS; 83 notify_item->preference = PREFERENCE_SHOW_ALWAYS;
84 84
85 SendNotifyItemUpdate(std::move(notify_item)); 85 SendNotifyItemUpdate(std::move(notify_item));
86 } 86 }
87 87
88 STDMETHODIMP_(ULONG) StatusTrayStateChangerWin::AddRef() { 88 STDMETHODIMP_(ULONG) StatusTrayStateChangerWin::AddRef() {
89 DCHECK(CalledOnValidThread()); 89 DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
90 return base::win::IUnknownImpl::AddRef(); 90 return base::win::IUnknownImpl::AddRef();
91 } 91 }
92 92
93 STDMETHODIMP_(ULONG) StatusTrayStateChangerWin::Release() { 93 STDMETHODIMP_(ULONG) StatusTrayStateChangerWin::Release() {
94 DCHECK(CalledOnValidThread()); 94 DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
95 return base::win::IUnknownImpl::Release(); 95 return base::win::IUnknownImpl::Release();
96 } 96 }
97 97
98 STDMETHODIMP StatusTrayStateChangerWin::QueryInterface(REFIID riid, 98 STDMETHODIMP StatusTrayStateChangerWin::QueryInterface(REFIID riid,
99 PVOID* ptr_void) { 99 PVOID* ptr_void) {
100 DCHECK(CalledOnValidThread()); 100 DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
101 if (riid == __uuidof(INotificationCB)) { 101 if (riid == __uuidof(INotificationCB)) {
102 *ptr_void = static_cast<INotificationCB*>(this); 102 *ptr_void = static_cast<INotificationCB*>(this);
103 AddRef(); 103 AddRef();
104 return S_OK; 104 return S_OK;
105 } 105 }
106 106
107 return base::win::IUnknownImpl::QueryInterface(riid, ptr_void); 107 return base::win::IUnknownImpl::QueryInterface(riid, ptr_void);
108 } 108 }
109 109
110 STDMETHODIMP StatusTrayStateChangerWin::Notify(ULONG event, 110 STDMETHODIMP StatusTrayStateChangerWin::Notify(ULONG event,
111 NOTIFYITEM* notify_item) { 111 NOTIFYITEM* notify_item) {
112 DCHECK(CalledOnValidThread()); 112 DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
113 DCHECK(notify_item); 113 DCHECK(notify_item);
114 if (notify_item->hwnd != window_ || notify_item->id != icon_id_ || 114 if (notify_item->hwnd != window_ || notify_item->id != icon_id_ ||
115 base::string16(notify_item->exe_name) != file_name_) { 115 base::string16(notify_item->exe_name) != file_name_) {
116 return S_OK; 116 return S_OK;
117 } 117 }
118 118
119 notify_item_.reset(new NOTIFYITEM(*notify_item)); 119 notify_item_.reset(new NOTIFYITEM(*notify_item));
120 return S_OK; 120 return S_OK;
121 } 121 }
122 122
123 StatusTrayStateChangerWin::~StatusTrayStateChangerWin() { 123 StatusTrayStateChangerWin::~StatusTrayStateChangerWin() {
124 DCHECK(CalledOnValidThread()); 124 DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
125 } 125 }
126 126
127 bool StatusTrayStateChangerWin::CreateTrayNotify() { 127 bool StatusTrayStateChangerWin::CreateTrayNotify() {
128 DCHECK(CalledOnValidThread()); 128 DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
129 129
130 tray_notify_.Reset(); // Reset so this method can be called more than once. 130 tray_notify_.Reset(); // Reset so this method can be called more than once.
131 131
132 HRESULT hr = ::CoCreateInstance(CLSID_TrayNotify, nullptr, CLSCTX_ALL, 132 HRESULT hr = ::CoCreateInstance(CLSID_TrayNotify, nullptr, CLSCTX_ALL,
133 IID_PPV_ARGS(&tray_notify_)); 133 IID_PPV_ARGS(&tray_notify_));
134 if (FAILED(hr)) 134 if (FAILED(hr))
135 return false; 135 return false;
136 136
137 base::win::ScopedComPtr<ITrayNotifyWin8> tray_notify_win8; 137 base::win::ScopedComPtr<ITrayNotifyWin8> tray_notify_win8;
138 hr = tray_notify_.CopyTo(tray_notify_win8.GetAddressOf()); 138 hr = tray_notify_.CopyTo(tray_notify_win8.GetAddressOf());
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 HRESULT hr = tray_notify_.CopyTo(tray_notify.GetAddressOf()); 227 HRESULT hr = tray_notify_.CopyTo(tray_notify.GetAddressOf());
228 if (SUCCEEDED(hr)) 228 if (SUCCEEDED(hr))
229 tray_notify->SetPreference(notify_item.get()); 229 tray_notify->SetPreference(notify_item.get());
230 } else if (interface_version_ == INTERFACE_VERSION_WIN8) { 230 } else if (interface_version_ == INTERFACE_VERSION_WIN8) {
231 base::win::ScopedComPtr<ITrayNotifyWin8> tray_notify; 231 base::win::ScopedComPtr<ITrayNotifyWin8> tray_notify;
232 HRESULT hr = tray_notify_.CopyTo(tray_notify.GetAddressOf()); 232 HRESULT hr = tray_notify_.CopyTo(tray_notify.GetAddressOf());
233 if (SUCCEEDED(hr)) 233 if (SUCCEEDED(hr))
234 tray_notify->SetPreference(notify_item.get()); 234 tray_notify->SetPreference(notify_item.get());
235 } 235 }
236 } 236 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698