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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/ipc_channel_proxy.h"
10 #include "third_party/WebKit/public/platform/WebGamepads.h" 12 #include "third_party/WebKit/public/platform/WebGamepads.h"
11 13
12 namespace content { 14 namespace content {
13 15
14 struct GamepadHardwareBuffer; 16 struct GamepadHardwareBuffer;
15 17
16 class GamepadSharedMemoryReader { 18 class GamepadSharedMemoryReader : public IPC::ChannelProxy::MessageFilter {
17 public: 19 public:
18 GamepadSharedMemoryReader(); 20 GamepadSharedMemoryReader(
21 const scoped_refptr<base::MessageLoopProxy>& io_message_loop);
22 void SampleGamepads(blink::WebGamepads&);
23 void SetGamepadListener(blink::WebGamepadListener* listener);
24
25 protected:
19 virtual ~GamepadSharedMemoryReader(); 26 virtual ~GamepadSharedMemoryReader();
20 void SampleGamepads(blink::WebGamepads&);
21 27
22 private: 28 private:
29 bool EnsurePollingStarted();
30
31 // IPC::ChannelProxy::MessageFilter override. Called on |io_message_loop|.
32 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
33
34 // Called when a gamepad is connected to the system
35 void OnGamepadConnected(const GamepadConnectionEventMessageParams& params);
36
37 // Called when a gamepad is disconnected from the system
38 void OnGamepadDisconnected(const GamepadConnectionEventMessageParams& params);
39
40 void DispatchGamepadConnected(int index, const blink::WebGamepad& gamepad);
41 void DispatchGamepadDisconnected(int index, const blink::WebGamepad& gamepad);
42
43 // Message loop on which IPC calls are driven.
44 const scoped_refptr<base::MessageLoopProxy> io_message_loop_;
45
46 // Main thread's message loop.
47 scoped_refptr<base::MessageLoopProxy> main_message_loop_;
48
23 base::SharedMemoryHandle renderer_shared_memory_handle_; 49 base::SharedMemoryHandle renderer_shared_memory_handle_;
24 scoped_ptr<base::SharedMemory> renderer_shared_memory_; 50 scoped_ptr<base::SharedMemory> renderer_shared_memory_;
25 GamepadHardwareBuffer* gamepad_hardware_buffer_; 51 GamepadHardwareBuffer* gamepad_hardware_buffer_;
52 blink::WebGamepadListener* gamepad_listener_;
26 53
54 bool is_polling_;
27 bool ever_interacted_with_; 55 bool ever_interacted_with_;
28 }; 56 };
29 57
30 } // namespace content 58 } // namespace content
31 59
32 #endif // CONTENT_RENDERER_GAMEPAD_SHARED_MEMORY_READER_H_ 60 #endif // CONTENT_RENDERER_GAMEPAD_SHARED_MEMORY_READER_H_
OLDNEW
« 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