OLD | NEW |
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 #ifndef UI_EVENTS_PLATFORM_PLATFORM_EVENT_SOURCE_H_ | 5 #ifndef UI_EVENTS_PLATFORM_PLATFORM_EVENT_SOURCE_H_ |
6 #define UI_EVENTS_PLATFORM_PLATFORM_EVENT_SOURCE_H_ | 6 #define UI_EVENTS_PLATFORM_PLATFORM_EVENT_SOURCE_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <map> | 10 #include <map> |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 // dispatcher installed using |OverrideDispatcher()|, then that dispatcher | 73 // dispatcher installed using |OverrideDispatcher()|, then that dispatcher |
74 // receives the event first. |POST_DISPATCH_QUIT_LOOP| flag is set in the | 74 // receives the event first. |POST_DISPATCH_QUIT_LOOP| flag is set in the |
75 // returned value if the event-source should stop dispatching events at the | 75 // returned value if the event-source should stop dispatching events at the |
76 // current message-loop iteration. | 76 // current message-loop iteration. |
77 virtual uint32_t DispatchEvent(PlatformEvent platform_event); | 77 virtual uint32_t DispatchEvent(PlatformEvent platform_event); |
78 | 78 |
79 private: | 79 private: |
80 friend class ScopedEventDispatcher; | 80 friend class ScopedEventDispatcher; |
81 friend class test::PlatformEventSourceTestAPI; | 81 friend class test::PlatformEventSourceTestAPI; |
82 | 82 |
83 static PlatformEventSource* instance_; | |
84 | |
85 // This is invoked when the list of dispatchers changes (i.e. a new dispatcher | 83 // This is invoked when the list of dispatchers changes (i.e. a new dispatcher |
86 // is added, or a dispatcher is removed). | 84 // is added, or a dispatcher is removed). |
87 virtual void OnDispatcherListChanged(); | 85 virtual void OnDispatcherListChanged(); |
88 | 86 |
89 void OnOverriddenDispatcherRestored(); | 87 void OnOverriddenDispatcherRestored(); |
90 | 88 |
91 // Use an base::ObserverList<> instead of an std::vector<> to store the list | 89 // Use an base::ObserverList<> instead of an std::vector<> to store the list |
92 // of | 90 // of |
93 // dispatchers, so that adding/removing dispatchers during an event dispatch | 91 // dispatchers, so that adding/removing dispatchers during an event dispatch |
94 // is well-defined. | 92 // is well-defined. |
95 typedef base::ObserverList<PlatformEventDispatcher> | 93 typedef base::ObserverList<PlatformEventDispatcher> |
96 PlatformEventDispatcherList; | 94 PlatformEventDispatcherList; |
97 PlatformEventDispatcherList dispatchers_; | 95 PlatformEventDispatcherList dispatchers_; |
98 PlatformEventDispatcher* overridden_dispatcher_; | 96 PlatformEventDispatcher* overridden_dispatcher_; |
99 | 97 |
100 // Used to keep track of whether the current override-dispatcher has been | 98 // Used to keep track of whether the current override-dispatcher has been |
101 // reset and a previous override-dispatcher has been restored. | 99 // reset and a previous override-dispatcher has been restored. |
102 bool overridden_dispatcher_restored_; | 100 bool overridden_dispatcher_restored_; |
103 | 101 |
104 base::ObserverList<PlatformEventObserver> observers_; | 102 base::ObserverList<PlatformEventObserver> observers_; |
105 | 103 |
106 DISALLOW_COPY_AND_ASSIGN(PlatformEventSource); | 104 DISALLOW_COPY_AND_ASSIGN(PlatformEventSource); |
107 }; | 105 }; |
108 | 106 |
109 } // namespace ui | 107 } // namespace ui |
110 | 108 |
111 #endif // UI_EVENTS_PLATFORM_PLATFORM_EVENT_SOURCE_H_ | 109 #endif // UI_EVENTS_PLATFORM_PLATFORM_EVENT_SOURCE_H_ |
OLD | NEW |