Index: content/browser/gamepad/gamepad_service.h |
diff --git a/content/browser/gamepad/gamepad_service.h b/content/browser/gamepad/gamepad_service.h |
index 94620b34b60f901c8b1bfb4865d3092eeb313ee8..0a5b03e823dcb5f183a4ac2edba79cadced54013 100644 |
--- a/content/browser/gamepad/gamepad_service.h |
+++ b/content/browser/gamepad/gamepad_service.h |
@@ -13,8 +13,13 @@ |
#include "base/threading/thread_checker.h" |
#include "content/common/content_export.h" |
+namespace blink { |
+class WebGamepad; |
+} |
+ |
namespace content { |
+class GamepadConsumer; |
class GamepadDataFetcher; |
class GamepadProvider; |
class GamepadServiceTestConstructor; |
@@ -32,12 +37,12 @@ class CONTENT_EXPORT GamepadService { |
// when there's > 0 users, and is paused when the count drops to 0. |
// |
// Must be called on the I/O thread. |
- void AddConsumer(); |
+ void AddConsumer(GamepadConsumer* consumer); |
// Removes a consumer. Should be matched with an AddConsumer call. |
// |
// Must be called on the I/O thread. |
- void RemoveConsumer(); |
+ void RemoveConsumer(GamepadConsumer* consumer); |
// Registers the given closure for calling when the user has interacted with |
// the device. This callback will only be issued once. Should only be called |
@@ -52,6 +57,12 @@ class CONTENT_EXPORT GamepadService { |
// Stop/join with the background thread in GamepadProvider |provider_|. |
void Terminate(); |
+ // Called on IO thread when a gamepad is connected. |
+ void OnGamepadConnected(int index, const blink::WebGamepad& pad); |
+ |
+ // Called on IO thread when a gamepad is disconnected. |
+ void OnGamepadDisconnected(int index, const blink::WebGamepad& pad); |
+ |
private: |
friend struct DefaultSingletonTraits<GamepadService>; |
friend class GamepadServiceTestConstructor; |
@@ -64,7 +75,25 @@ class CONTENT_EXPORT GamepadService { |
virtual ~GamepadService(); |
- int num_readers_; |
+ void OnUserGesture(); |
+ |
+ struct ConsumerInfo { |
+ explicit ConsumerInfo(GamepadConsumer* consumer) |
+ : consumer(consumer), |
+ did_observe_user_gesture(false) { |
+ } |
+ |
+ friend bool operator<(const ConsumerInfo& a, const ConsumerInfo& b) { |
+ return a.consumer < b.consumer; |
+ } |
+ |
+ GamepadConsumer* consumer; |
+ bool did_observe_user_gesture; |
+ }; |
+ |
+ typedef std::set<ConsumerInfo, std::less<ConsumerInfo> > ConsumerSet; |
+ ConsumerSet consumers_; |
+ |
scoped_ptr<GamepadProvider> provider_; |
base::ThreadChecker thread_checker_; |