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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CONTENT_RENDERER_GAMEPAD_SHARED_MEMORY_READER_H_ 5 #ifndef CONTENT_RENDERER_GAMEPAD_SHARED_MEMORY_READER_H_
6 #define CONTENT_RENDERER_GAMEPAD_SHARED_MEMORY_READER_H_ 6 #define CONTENT_RENDERER_GAMEPAD_SHARED_MEMORY_READER_H_
7 7
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/memory/shared_memory.h" 9 #include "base/memory/shared_memory.h"
10 #include "content/common/gamepad_messages.h"
11 #include "ipc/message_filter.h"
10 #include "third_party/WebKit/public/platform/WebGamepads.h" 12 #include "third_party/WebKit/public/platform/WebGamepads.h"
11 13
14 namespace blink { class WebGamepadListener; }
15
12 namespace content { 16 namespace content {
13 17
14 struct GamepadHardwareBuffer; 18 struct GamepadHardwareBuffer;
15 19
16 class GamepadSharedMemoryReader { 20 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.
17 public: 21 public:
18 GamepadSharedMemoryReader(); 22 GamepadSharedMemoryReader(
23 const scoped_refptr<base::MessageLoopProxy>& io_message_loop);
24 void SampleGamepads(blink::WebGamepads&);
25 void SetGamepadListener(blink::WebGamepadListener* listener);
26
27 protected:
19 virtual ~GamepadSharedMemoryReader(); 28 virtual ~GamepadSharedMemoryReader();
20 void SampleGamepads(blink::WebGamepads&);
21 29
22 private: 30 private:
31 void StartPollingIfNecessary();
32 void StopPollingIfNecessary();
33
34 // IPC::ChannelProxy::MessageFilter override. Called on |io_message_loop|.
35 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
36
37 // Called when a gamepad is connected to the system
38 void OnGamepadConnected(int index, const blink::WebGamepad& gamepad);
39
40 // Called when a gamepad is disconnected from the system
41 void OnGamepadDisconnected(int index, const blink::WebGamepad& gamepad);
42
43 void DispatchGamepadConnected(int index, const blink::WebGamepad& gamepad);
44 void DispatchGamepadDisconnected(int index, const blink::WebGamepad& gamepad);
45
46 // Message loop on which IPC calls are driven.
47 const scoped_refptr<base::MessageLoopProxy> io_message_loop_;
48
49 // Main thread's message loop.
50 scoped_refptr<base::MessageLoopProxy> main_message_loop_;
51
23 base::SharedMemoryHandle renderer_shared_memory_handle_; 52 base::SharedMemoryHandle renderer_shared_memory_handle_;
24 scoped_ptr<base::SharedMemory> renderer_shared_memory_; 53 scoped_ptr<base::SharedMemory> renderer_shared_memory_;
25 GamepadHardwareBuffer* gamepad_hardware_buffer_; 54 GamepadHardwareBuffer* gamepad_hardware_buffer_;
55 blink::WebGamepadListener* gamepad_listener_;
26 56
57 bool is_polling_;
27 bool ever_interacted_with_; 58 bool ever_interacted_with_;
28 }; 59 };
29 60
30 } // namespace content 61 } // namespace content
31 62
32 #endif // CONTENT_RENDERER_GAMEPAD_SHARED_MEMORY_READER_H_ 63 #endif // CONTENT_RENDERER_GAMEPAD_SHARED_MEMORY_READER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698