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

Unified Diff: device/gamepad/gamepad_provider.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 | « device/gamepad/gamepad_platform_data_fetcher_win.cc ('k') | device/gamepad/gamepad_provider.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: device/gamepad/gamepad_provider.h
diff --git a/content/browser/gamepad/gamepad_provider.h b/device/gamepad/gamepad_provider.h
similarity index 80%
rename from content/browser/gamepad/gamepad_provider.h
rename to device/gamepad/gamepad_provider.h
index 916138986aa57bec04e4ef94199cf4d00199dff5..5d2e2b2eb9b744f646705cb2945d58ba4a98433b 100644
--- a/content/browser/gamepad/gamepad_provider.h
+++ b/device/gamepad/gamepad_provider.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CONTENT_BROWSER_GAMEPAD_GAMEPAD_PROVIDER_H_
-#define CONTENT_BROWSER_GAMEPAD_GAMEPAD_PROVIDER_H_
+#ifndef DEVICE_GAMEPAD_GAMEPAD_PROVIDER_H_
+#define DEVICE_GAMEPAD_GAMEPAD_PROVIDER_H_
#include <memory>
#include <utility>
@@ -16,7 +16,8 @@
#include "base/memory/weak_ptr.h"
#include "base/synchronization/lock.h"
#include "base/system_monitor/system_monitor.h"
-#include "content/common/content_export.h"
+#include "device/gamepad/gamepad_export.h"
+#include "device/gamepad/gamepad_shared_buffer.h"
#include "third_party/WebKit/public/platform/WebGamepads.h"
namespace base {
@@ -24,18 +25,29 @@ class SingleThreadTaskRunner;
class Thread;
}
-namespace content {
+namespace device {
class GamepadDataFetcher;
-struct GamepadHardwareBuffer;
-class CONTENT_EXPORT GamepadProvider :
- public base::SystemMonitor::DevicesChangedObserver {
+class DEVICE_GAMEPAD_EXPORT GamepadConnectionChangeClient {
public:
- GamepadProvider();
+ virtual void OnGamepadConnectionChange(bool connected,
+ int index,
+ const blink::WebGamepad& pad) = 0;
+};
+
+class DEVICE_GAMEPAD_EXPORT GamepadProvider
+ : public base::SystemMonitor::DevicesChangedObserver {
+ public:
+ explicit GamepadProvider(
+ std::unique_ptr<GamepadSharedBuffer> buffer,
+ GamepadConnectionChangeClient* connection_change_client);
// Manually specifies the data fetcher. Used for testing.
- explicit GamepadProvider(std::unique_ptr<GamepadDataFetcher> fetcher);
+ explicit GamepadProvider(
+ std::unique_ptr<GamepadSharedBuffer> buffer,
+ GamepadConnectionChangeClient* connection_change_client,
+ std::unique_ptr<GamepadDataFetcher> fetcher);
~GamepadProvider() override;
@@ -76,11 +88,6 @@ class CONTENT_EXPORT GamepadProvider :
void OnGamepadConnectionChange(bool connected,
int index,
const blink::WebGamepad& pad);
- void DispatchGamepadConnectionChange(bool connected,
- int index,
- const blink::WebGamepad& pad);
-
- GamepadHardwareBuffer* SharedMemoryAsHardwareBuffer();
// Checks the gamepad state to see if the user has interacted with it.
void CheckForUserGesture();
@@ -127,9 +134,7 @@ class CONTENT_EXPORT GamepadProvider :
class PadState {
public:
- PadState() {
- SetDisconnected();
- }
+ PadState() { SetDisconnected(); }
bool Match(const blink::WebGamepad& pad) const;
void SetPad(const blink::WebGamepad& pad);
@@ -153,16 +158,18 @@ class CONTENT_EXPORT GamepadProvider :
std::unique_ptr<GamepadDataFetcher> data_fetcher_;
base::Lock shared_memory_lock_;
- base::SharedMemory gamepad_shared_memory_;
+ std::unique_ptr<GamepadSharedBuffer> gamepad_shared_buffer_;
// Polling is done on this background thread.
std::unique_ptr<base::Thread> polling_thread_;
+ GamepadConnectionChangeClient* connection_change_client_;
+
static GamepadProvider* instance_;
DISALLOW_COPY_AND_ASSIGN(GamepadProvider);
};
-} // namespace content
+} // namespace device
-#endif // CONTENT_BROWSER_GAMEPAD_GAMEPAD_PROVIDER_H_
+#endif // DEVICE_GAMEPAD_GAMEPAD_PROVIDER_H_
« no previous file with comments | « device/gamepad/gamepad_platform_data_fetcher_win.cc ('k') | device/gamepad/gamepad_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698