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

Side by Side Diff: content/renderer/gamepad_shared_memory_reader.h

Issue 2522843002: Convert Gamepad IPC messages into mojo interface. (Closed)
Patch Set: code rebase Created 4 years 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/renderer/DEPS ('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 <memory> 8 #include <memory>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "base/memory/shared_memory.h" 11 #include "base/memory/shared_memory.h"
12 #include "content/common/gamepad_messages.h"
13 #include "content/public/renderer/renderer_gamepad_provider.h" 12 #include "content/public/renderer/renderer_gamepad_provider.h"
13 #include "device/gamepad/public/interfaces/gamepad.mojom.h"
14 #include "mojo/public/cpp/bindings/binding.h"
15 #include "mojo/public/cpp/system/platform_handle.h"
14 #include "third_party/WebKit/public/platform/WebGamepads.h" 16 #include "third_party/WebKit/public/platform/WebGamepads.h"
15 17
16 namespace content { 18 namespace content {
17 19
18 struct GamepadHardwareBuffer; 20 struct GamepadHardwareBuffer;
19 21
20 class GamepadSharedMemoryReader : public RendererGamepadProvider { 22 class GamepadSharedMemoryReader : public RendererGamepadProvider,
23 public device::mojom::GamepadObserver {
21 public: 24 public:
22 explicit GamepadSharedMemoryReader(RenderThread* thread); 25 explicit GamepadSharedMemoryReader(RenderThread* thread);
23 ~GamepadSharedMemoryReader() override; 26 ~GamepadSharedMemoryReader() override;
24 27
25 // RendererGamepadProvider implementation. 28 // RendererGamepadProvider implementation.
26 void SampleGamepads(blink::WebGamepads& gamepads) override; 29 void SampleGamepads(blink::WebGamepads& gamepads) override;
27 bool OnControlMessageReceived(const IPC::Message& message) override;
28 void Start(blink::WebPlatformEventListener* listener) override; 30 void Start(blink::WebPlatformEventListener* listener) override;
29 31
30 protected: 32 protected:
31 // PlatformEventObserver protected methods. 33 // PlatformEventObserver protected methods.
32 void SendStartMessage() override; 34 void SendStartMessage() override;
33 void SendStopMessage() override; 35 void SendStopMessage() override;
34 36
35 private: 37 private:
36 void OnGamepadConnected(int index, const blink::WebGamepad& gamepad); 38 // device::mojom::GamepadObserver methods.
37 void OnGamepadDisconnected(int index, const blink::WebGamepad& gamepad); 39 void GamepadConnected(int index, const blink::WebGamepad& gamepad) override;
40 void GamepadDisconnected(int index,
41 const blink::WebGamepad& gamepad) override;
38 42
39 base::SharedMemoryHandle renderer_shared_memory_handle_; 43 base::SharedMemoryHandle renderer_shared_memory_handle_;
40 std::unique_ptr<base::SharedMemory> renderer_shared_memory_; 44 std::unique_ptr<base::SharedMemory> renderer_shared_memory_;
41 GamepadHardwareBuffer* gamepad_hardware_buffer_; 45 GamepadHardwareBuffer* gamepad_hardware_buffer_;
42 46
43 bool ever_interacted_with_; 47 bool ever_interacted_with_;
44 48
49 mojo::Binding<device::mojom::GamepadObserver> binding_;
50 device::mojom::GamepadMonitorPtr gamepad_monitor_;
51
45 DISALLOW_COPY_AND_ASSIGN(GamepadSharedMemoryReader); 52 DISALLOW_COPY_AND_ASSIGN(GamepadSharedMemoryReader);
46 }; 53 };
47 54
48 } // namespace content 55 } // namespace content
49 56
50 #endif // CONTENT_RENDERER_GAMEPAD_SHARED_MEMORY_READER_H_ 57 #endif // CONTENT_RENDERER_GAMEPAD_SHARED_MEMORY_READER_H_
OLDNEW
« no previous file with comments | « content/renderer/DEPS ('k') | content/renderer/gamepad_shared_memory_reader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698