| 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_
|
|
|