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

Side by Side Diff: ui/views/mus/pointer_watcher_event_router.cc

Issue 2414863002: Remove usage of base::ObserverList<T>::Iter::GetNext() in //ui. (Closed)
Patch Set: debrace Created 4 years, 2 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/mus/pointer_watcher_event_router.h" 5 #include "ui/views/mus/pointer_watcher_event_router.h"
6 6
7 #include "services/ui/public/cpp/window.h" 7 #include "services/ui/public/cpp/window.h"
8 #include "services/ui/public/cpp/window_tree_client.h" 8 #include "services/ui/public/cpp/window_tree_client.h"
9 #include "ui/display/screen.h" 9 #include "ui/display/screen.h"
10 #include "ui/events/base_event_utils.h" 10 #include "ui/events/base_event_utils.h"
11 #include "ui/events/event.h" 11 #include "ui/events/event.h"
12 #include "ui/views/mus/native_widget_mus.h" 12 #include "ui/views/mus/native_widget_mus.h"
13 #include "ui/views/pointer_watcher.h" 13 #include "ui/views/pointer_watcher.h"
14 14
15 namespace views { 15 namespace views {
16 namespace { 16 namespace {
17 17
18 bool HasPointerWatcher( 18 bool HasPointerWatcher(
19 base::ObserverList<views::PointerWatcher, true>* observer_list) { 19 base::ObserverList<views::PointerWatcher, true>* observer_list) {
20 if (!observer_list->might_have_observers()) 20 return observer_list->begin() != observer_list->end();
21 return false;
22
23 // might_have_observers() returned true, see if there really are any
24 // observers. The only way to truly know is to use an Iterator and see if it
25 // has at least one observer.
26 base::ObserverList<PointerWatcher>::Iterator iterator(observer_list);
27 return !!iterator.GetNext();
28 } 21 }
29 22
30 } // namespace 23 } // namespace
31 24
32 PointerWatcherEventRouter::PointerWatcherEventRouter( 25 PointerWatcherEventRouter::PointerWatcherEventRouter(
33 ui::WindowTreeClient* client) 26 ui::WindowTreeClient* client)
34 : window_tree_client_(client) { 27 : window_tree_client_(client) {
35 client->AddObserver(this); 28 client->AddObserver(this);
36 } 29 }
37 30
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 void PointerWatcherEventRouter::OnDidDestroyClient( 136 void PointerWatcherEventRouter::OnDidDestroyClient(
144 ui::WindowTreeClient* client) { 137 ui::WindowTreeClient* client) {
145 // We expect that all observers have been removed by this time. 138 // We expect that all observers have been removed by this time.
146 DCHECK_EQ(event_types_, EventTypes::NONE); 139 DCHECK_EQ(event_types_, EventTypes::NONE);
147 DCHECK_EQ(client, window_tree_client_); 140 DCHECK_EQ(client, window_tree_client_);
148 window_tree_client_->RemoveObserver(this); 141 window_tree_client_->RemoveObserver(this);
149 window_tree_client_ = nullptr; 142 window_tree_client_ = nullptr;
150 } 143 }
151 144
152 } // namespace views 145 } // namespace views
OLDNEW
« no previous file with comments | « ui/events/platform/x11/x11_event_source_libevent.cc ('k') | ui/wm/core/compound_event_filter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698