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