Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1088)

Unified Diff: content/browser/gamepad/gamepad_service.h

Issue 2081583002: Migrating majority of gamepad from content/browser/ to device/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Final tweaks Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/browser/gamepad/gamepad_provider_unittest.cc ('k') | content/browser/gamepad/gamepad_service.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/gamepad/gamepad_service.h
diff --git a/content/browser/gamepad/gamepad_service.h b/content/browser/gamepad/gamepad_service.h
index d453639363011f3b3ef898bc132d734704088804..b5c419b44d619ff30bb9995c2562c12bf766c016 100644
--- a/content/browser/gamepad/gamepad_service.h
+++ b/content/browser/gamepad/gamepad_service.h
@@ -14,23 +14,28 @@
#include "base/memory/singleton.h"
#include "base/threading/thread_checker.h"
#include "content/common/content_export.h"
+#include "device/gamepad/gamepad_provider.h"
namespace blink {
class WebGamepad;
}
-namespace content {
-
+namespace device {
class GamepadConsumer;
class GamepadDataFetcher;
class GamepadProvider;
+}
+
+namespace content {
+
class GamepadServiceTestConstructor;
class RenderProcessHost;
// Owns the GamepadProvider (the background polling thread) and keeps track of
// the number of consumers currently using the data (and pausing the provider
// when not in use).
-class CONTENT_EXPORT GamepadService {
+class CONTENT_EXPORT GamepadService
+ : public device::GamepadConnectionChangeClient {
public:
// Returns the GamepadService singleton.
static GamepadService* GetInstance();
@@ -44,21 +49,21 @@ class CONTENT_EXPORT GamepadService {
// gamepads.
//
// Must be called on the I/O thread.
- void ConsumerBecameActive(GamepadConsumer* consumer);
+ void ConsumerBecameActive(device::GamepadConsumer* consumer);
// Decrements the number of users of the provider. consumer will not be
// informed about connections until it's added back via ConsumerBecameActive.
// Must be matched with a ConsumerBecameActive call.
//
// Must be called on the I/O thread.
- void ConsumerBecameInactive(GamepadConsumer* consumer);
+ void ConsumerBecameInactive(device::GamepadConsumer* consumer);
// Decrements the number of users of the provider and removes consumer from
// the set of consumers. Should be matched with a a ConsumerBecameActive
// call.
//
// Must be called on the I/O thread.
- void RemoveConsumer(GamepadConsumer* consumer);
+ void RemoveConsumer(device::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
@@ -88,7 +93,8 @@ class CONTENT_EXPORT GamepadService {
// Constructor for testing. This specifies the data fetcher to use for a
// provider, bypassing the default platform one.
- GamepadService(std::unique_ptr<GamepadDataFetcher> fetcher);
+ GamepadService(
+ std::unique_ptr<device::GamepadDataFetcher> fetcher);
virtual ~GamepadService();
@@ -96,22 +102,24 @@ class CONTENT_EXPORT GamepadService {
void OnUserGesture();
+ void OnGamepadConnectionChange(bool connected,
+ int index,
+ const blink::WebGamepad& pad) override;
+
struct ConsumerInfo {
- ConsumerInfo(GamepadConsumer* consumer)
- : consumer(consumer),
- did_observe_user_gesture(false) {
- }
+ ConsumerInfo(device::GamepadConsumer* consumer)
+ : consumer(consumer), did_observe_user_gesture(false) {}
bool operator<(const ConsumerInfo& other) const {
return consumer < other.consumer;
}
- GamepadConsumer* consumer;
+ device::GamepadConsumer* consumer;
mutable bool is_active;
mutable bool did_observe_user_gesture;
};
- std::unique_ptr<GamepadProvider> provider_;
+ std::unique_ptr<device::GamepadProvider> provider_;
base::ThreadChecker thread_checker_;
« no previous file with comments | « content/browser/gamepad/gamepad_provider_unittest.cc ('k') | content/browser/gamepad/gamepad_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698