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

Side by Side Diff: ui/events/platform/platform_event_source.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
« no previous file with comments | « ui/compositor/layer_animator.cc ('k') | ui/events/platform/x11/x11_event_source_libevent.cc » ('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 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 "ui/events/platform/platform_event_source.h" 5 #include "ui/events/platform/platform_event_source.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 68
69 uint32_t PlatformEventSource::DispatchEvent(PlatformEvent platform_event) { 69 uint32_t PlatformEventSource::DispatchEvent(PlatformEvent platform_event) {
70 uint32_t action = POST_DISPATCH_PERFORM_DEFAULT; 70 uint32_t action = POST_DISPATCH_PERFORM_DEFAULT;
71 71
72 FOR_EACH_OBSERVER(PlatformEventObserver, observers_, 72 FOR_EACH_OBSERVER(PlatformEventObserver, observers_,
73 WillProcessEvent(platform_event)); 73 WillProcessEvent(platform_event));
74 // Give the overridden dispatcher a chance to dispatch the event first. 74 // Give the overridden dispatcher a chance to dispatch the event first.
75 if (overridden_dispatcher_) 75 if (overridden_dispatcher_)
76 action = overridden_dispatcher_->DispatchEvent(platform_event); 76 action = overridden_dispatcher_->DispatchEvent(platform_event);
77 77
78 if ((action & POST_DISPATCH_PERFORM_DEFAULT) && 78 if (action & POST_DISPATCH_PERFORM_DEFAULT) {
79 dispatchers_.might_have_observers()) { 79 for (PlatformEventDispatcher& dispatcher : dispatchers_) {
80 base::ObserverList<PlatformEventDispatcher>::Iterator iter(&dispatchers_); 80 if (dispatcher.CanDispatchEvent(platform_event))
81 while (PlatformEventDispatcher* dispatcher = iter.GetNext()) { 81 action = dispatcher.DispatchEvent(platform_event);
82 if (dispatcher->CanDispatchEvent(platform_event))
83 action = dispatcher->DispatchEvent(platform_event);
84 if (action & POST_DISPATCH_STOP_PROPAGATION) 82 if (action & POST_DISPATCH_STOP_PROPAGATION)
85 break; 83 break;
86 } 84 }
87 } 85 }
88 FOR_EACH_OBSERVER(PlatformEventObserver, observers_, 86 FOR_EACH_OBSERVER(PlatformEventObserver, observers_,
89 DidProcessEvent(platform_event)); 87 DidProcessEvent(platform_event));
90 88
91 // If an overridden dispatcher has been destroyed, then the platform 89 // If an overridden dispatcher has been destroyed, then the platform
92 // event-source should halt dispatching the current stream of events, and wait 90 // event-source should halt dispatching the current stream of events, and wait
93 // until the next message-loop iteration for dispatching events. This lets any 91 // until the next message-loop iteration for dispatching events. This lets any
94 // nested message-loop to unwind correctly and any new dispatchers to receive 92 // nested message-loop to unwind correctly and any new dispatchers to receive
95 // the correct sequence of events. 93 // the correct sequence of events.
96 if (overridden_dispatcher_restored_) 94 if (overridden_dispatcher_restored_)
97 StopCurrentEventStream(); 95 StopCurrentEventStream();
98 96
99 overridden_dispatcher_restored_ = false; 97 overridden_dispatcher_restored_ = false;
100 98
101 return action; 99 return action;
102 } 100 }
103 101
104 void PlatformEventSource::OnDispatcherListChanged() { 102 void PlatformEventSource::OnDispatcherListChanged() {
105 } 103 }
106 104
107 void PlatformEventSource::OnOverriddenDispatcherRestored() { 105 void PlatformEventSource::OnOverriddenDispatcherRestored() {
108 CHECK(overridden_dispatcher_); 106 CHECK(overridden_dispatcher_);
109 overridden_dispatcher_restored_ = true; 107 overridden_dispatcher_restored_ = true;
110 } 108 }
111 109
112 } // namespace ui 110 } // namespace ui
OLDNEW
« no previous file with comments | « ui/compositor/layer_animator.cc ('k') | ui/events/platform/x11/x11_event_source_libevent.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698