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

Unified Diff: content/renderer/gamepad_shared_memory_reader.h

Issue 195873019: Gamepad API: add support for connection events (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: incorp comments and fix build Created 6 years, 7 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
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..314b6ccdde11a5a6d8d0257f3227a2202857bc1e 100644
--- a/content/renderer/gamepad_shared_memory_reader.h
+++ b/content/renderer/gamepad_shared_memory_reader.h
@@ -7,23 +7,54 @@
#include "base/memory/scoped_ptr.h"
#include "base/memory/shared_memory.h"
+#include "content/common/gamepad_messages.h"
+#include "ipc/message_filter.h"
#include "third_party/WebKit/public/platform/WebGamepads.h"
+namespace blink { class WebGamepadListener; }
+
namespace content {
struct GamepadHardwareBuffer;
-class GamepadSharedMemoryReader {
+class GamepadSharedMemoryReader : public IPC::MessageFilter {
jam 2014/05/05 21:19:09 generally, you would implement an IPC::MessageFilt
kbalazs 2014/05/06 22:20:34 Done, indeed much better this way.
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:
+ void StartPollingIfNecessary();
+ void StopPollingIfNecessary();
+
+ // 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(int index, const blink::WebGamepad& gamepad);
+
+ // Called when a gamepad is disconnected from the system
+ void OnGamepadDisconnected(int index, const blink::WebGamepad& gamepad);
+
+ 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_;
};

Powered by Google App Engine
This is Rietveld 408576698