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 "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
10 #include "base/message_loop_proxy.h" | 10 #include "base/message_loop_proxy.h" |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 | 58 |
59 GamepadHardwareBuffer* SharedMemoryAsHardwareBuffer(); | 59 GamepadHardwareBuffer* SharedMemoryAsHardwareBuffer(); |
60 | 60 |
61 enum { kDesiredSamplingIntervalMs = 16 }; | 61 enum { kDesiredSamplingIntervalMs = 16 }; |
62 | 62 |
63 // Keeps track of when the background thread is paused. Access to is_paused_ | 63 // Keeps track of when the background thread is paused. Access to is_paused_ |
64 // must be guarded by is_paused_lock_. | 64 // must be guarded by is_paused_lock_. |
65 base::Lock is_paused_lock_; | 65 base::Lock is_paused_lock_; |
66 bool is_paused_; | 66 bool is_paused_; |
67 | 67 |
| 68 // Keep track of when a polling task is schedlued, so as to prevent us from |
| 69 // accidentally scheduling more than one at any time, when rapidly toggling |
| 70 // |is_paused_|. |
| 71 bool have_scheduled_do_poll_; |
| 72 |
68 // Updated based on notification from SystemMonitor when the system devices | 73 // Updated based on notification from SystemMonitor when the system devices |
69 // have been updated, and this notification is passed on to the data fetcher | 74 // have been updated, and this notification is passed on to the data fetcher |
70 // to enable it to avoid redundant (and possibly expensive) is-connected | 75 // to enable it to avoid redundant (and possibly expensive) is-connected |
71 // tests. Access to devices_changed_ must be guarded by | 76 // tests. Access to devices_changed_ must be guarded by |
72 // devices_changed_lock_. | 77 // devices_changed_lock_. |
73 base::Lock devices_changed_lock_; | 78 base::Lock devices_changed_lock_; |
74 bool devices_changed_; | 79 bool devices_changed_; |
75 | 80 |
76 // When polling_thread_ is running, members below are only to be used | 81 // When polling_thread_ is running, members below are only to be used |
77 // from that thread. | 82 // from that thread. |
78 scoped_ptr<GamepadDataFetcher> data_fetcher_; | 83 scoped_ptr<GamepadDataFetcher> data_fetcher_; |
79 base::SharedMemory gamepad_shared_memory_; | 84 base::SharedMemory gamepad_shared_memory_; |
80 | 85 |
81 // Polling is done on this background thread. | 86 // Polling is done on this background thread. |
82 scoped_ptr<base::Thread> polling_thread_; | 87 scoped_ptr<base::Thread> polling_thread_; |
83 | 88 |
84 static GamepadProvider* instance_; | 89 static GamepadProvider* instance_; |
85 | 90 |
86 DISALLOW_COPY_AND_ASSIGN(GamepadProvider); | 91 DISALLOW_COPY_AND_ASSIGN(GamepadProvider); |
87 }; | 92 }; |
88 | 93 |
89 } // namespace content | 94 } // namespace content |
90 | 95 |
91 #endif // CONTENT_BROWSER_GAMEPAD_GAMEPAD_PROVIDER_H_ | 96 #endif // CONTENT_BROWSER_GAMEPAD_GAMEPAD_PROVIDER_H_ |
OLD | NEW |