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

Unified Diff: content/renderer/gamepad_shared_memory_reader.h

Issue 200873002: Gamepad API: add support for connection events (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 9 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/content_common.gypi ('k') | content/renderer/gamepad_shared_memory_reader.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/gamepad_shared_memory_reader.h
diff --git a/content/renderer/gamepad_shared_memory_reader.h b/content/renderer/gamepad_shared_memory_reader.h
index 08dc41a8c91e1e9edd7aedbfdf591777e5c78481..795ab4f27168aa868bab69b44fcdc2c921bd0bb6 100644
--- a/content/renderer/gamepad_shared_memory_reader.h
+++ b/content/renderer/gamepad_shared_memory_reader.h
@@ -7,23 +7,51 @@
#include "base/memory/scoped_ptr.h"
#include "base/memory/shared_memory.h"
+#include "content/common/gamepad_messages.h"
+#include "ipc/ipc_channel_proxy.h"
#include "third_party/WebKit/public/platform/WebGamepads.h"
namespace content {
struct GamepadHardwareBuffer;
-class GamepadSharedMemoryReader {
+class GamepadSharedMemoryReader : public IPC::ChannelProxy::MessageFilter {
public:
- GamepadSharedMemoryReader();
- virtual ~GamepadSharedMemoryReader();
+ GamepadSharedMemoryReader(
+ const scoped_refptr<base::MessageLoopProxy>& io_message_loop);
void SampleGamepads(blink::WebGamepads&);
+ void SetGamepadListener(blink::WebGamepadListener* listener);
+
+ protected:
+ virtual ~GamepadSharedMemoryReader();
private:
+ bool EnsurePollingStarted();
+
+ // IPC::ChannelProxy::MessageFilter override. Called on |io_message_loop|.
+ virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
+
+ // Called when a gamepad is connected to the system
+ void OnGamepadConnected(const GamepadConnectionEventMessageParams& params);
+
+ // Called when a gamepad is disconnected from the system
+ void OnGamepadDisconnected(const GamepadConnectionEventMessageParams& params);
+
+ void DispatchGamepadConnected(int index, const blink::WebGamepad& gamepad);
+ void DispatchGamepadDisconnected(int index, const blink::WebGamepad& gamepad);
+
+ // Message loop on which IPC calls are driven.
+ const scoped_refptr<base::MessageLoopProxy> io_message_loop_;
+
+ // Main thread's message loop.
+ scoped_refptr<base::MessageLoopProxy> main_message_loop_;
+
base::SharedMemoryHandle renderer_shared_memory_handle_;
scoped_ptr<base::SharedMemory> renderer_shared_memory_;
GamepadHardwareBuffer* gamepad_hardware_buffer_;
+ blink::WebGamepadListener* gamepad_listener_;
+ bool is_polling_;
bool ever_interacted_with_;
};
« no previous file with comments | « content/content_common.gypi ('k') | content/renderer/gamepad_shared_memory_reader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698