OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 CONTENT_BROWSER_GAMEPAD_GAMEPAD_PROVIDER_H_ | 5 #ifndef CONTENT_BROWSER_GAMEPAD_GAMEPAD_PROVIDER_H_ |
6 #define CONTENT_BROWSER_GAMEPAD_GAMEPAD_PROVIDER_H_ | 6 #define CONTENT_BROWSER_GAMEPAD_GAMEPAD_PROVIDER_H_ |
7 | 7 |
8 #include <utility> | 8 #include <utility> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/callback_forward.h" | 11 #include "base/callback_forward.h" |
12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
14 #include "base/memory/shared_memory.h" | 14 #include "base/memory/shared_memory.h" |
15 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
| 16 #include "base/message_loop/message_loop_proxy.h" |
16 #include "base/synchronization/lock.h" | 17 #include "base/synchronization/lock.h" |
17 #include "base/system_monitor/system_monitor.h" | 18 #include "base/system_monitor/system_monitor.h" |
18 #include "content/common/content_export.h" | 19 #include "content/common/content_export.h" |
19 #include "third_party/WebKit/public/platform/WebGamepads.h" | 20 #include "third_party/WebKit/public/platform/WebGamepads.h" |
20 | 21 |
21 namespace base { | 22 namespace base { |
22 class SingleThreadTaskRunner; | 23 class MessageLoopProxy; |
23 class Thread; | 24 class Thread; |
24 } | 25 } |
25 | 26 |
26 namespace content { | 27 namespace content { |
27 | 28 |
28 class GamepadDataFetcher; | 29 class GamepadDataFetcher; |
29 struct GamepadHardwareBuffer; | 30 struct GamepadHardwareBuffer; |
30 | 31 |
31 class CONTENT_EXPORT GamepadProvider : | 32 class CONTENT_EXPORT GamepadProvider : |
32 public base::SystemMonitor::DevicesChangedObserver { | 33 public base::SystemMonitor::DevicesChangedObserver { |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 bool have_scheduled_do_poll_; | 98 bool have_scheduled_do_poll_; |
98 | 99 |
99 // Lists all observers registered for user gestures, and the thread which | 100 // Lists all observers registered for user gestures, and the thread which |
100 // to issue the callbacks on. Since we always issue the callback on the | 101 // to issue the callbacks on. Since we always issue the callback on the |
101 // thread which the registration happened, and this class lives on the I/O | 102 // thread which the registration happened, and this class lives on the I/O |
102 // thread, the message loop proxies will normally just be the I/O thread. | 103 // thread, the message loop proxies will normally just be the I/O thread. |
103 // However, this will be the main thread for unit testing. | 104 // However, this will be the main thread for unit testing. |
104 base::Lock user_gesture_lock_; | 105 base::Lock user_gesture_lock_; |
105 struct ClosureAndThread { | 106 struct ClosureAndThread { |
106 ClosureAndThread(const base::Closure& c, | 107 ClosureAndThread(const base::Closure& c, |
107 const scoped_refptr<base::SingleThreadTaskRunner>& m); | 108 const scoped_refptr<base::MessageLoopProxy>& m); |
108 ~ClosureAndThread(); | 109 ~ClosureAndThread(); |
109 | 110 |
110 base::Closure closure; | 111 base::Closure closure; |
111 scoped_refptr<base::SingleThreadTaskRunner> task_runner; | 112 scoped_refptr<base::MessageLoopProxy> message_loop; |
112 }; | 113 }; |
113 typedef std::vector<ClosureAndThread> UserGestureObserverVector; | 114 typedef std::vector<ClosureAndThread> UserGestureObserverVector; |
114 UserGestureObserverVector user_gesture_observers_; | 115 UserGestureObserverVector user_gesture_observers_; |
115 | 116 |
116 // Updated based on notification from SystemMonitor when the system devices | 117 // Updated based on notification from SystemMonitor when the system devices |
117 // have been updated, and this notification is passed on to the data fetcher | 118 // have been updated, and this notification is passed on to the data fetcher |
118 // to enable it to avoid redundant (and possibly expensive) is-connected | 119 // to enable it to avoid redundant (and possibly expensive) is-connected |
119 // tests. Access to devices_changed_ must be guarded by | 120 // tests. Access to devices_changed_ must be guarded by |
120 // devices_changed_lock_. | 121 // devices_changed_lock_. |
121 base::Lock devices_changed_lock_; | 122 base::Lock devices_changed_lock_; |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 scoped_ptr<base::Thread> polling_thread_; | 158 scoped_ptr<base::Thread> polling_thread_; |
158 | 159 |
159 static GamepadProvider* instance_; | 160 static GamepadProvider* instance_; |
160 | 161 |
161 DISALLOW_COPY_AND_ASSIGN(GamepadProvider); | 162 DISALLOW_COPY_AND_ASSIGN(GamepadProvider); |
162 }; | 163 }; |
163 | 164 |
164 } // namespace content | 165 } // namespace content |
165 | 166 |
166 #endif // CONTENT_BROWSER_GAMEPAD_GAMEPAD_PROVIDER_H_ | 167 #endif // CONTENT_BROWSER_GAMEPAD_GAMEPAD_PROVIDER_H_ |
OLD | NEW |