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

Side by Side Diff: device/gamepad/gamepad_service.h

Issue 2808093006: [Device Service] Move Gamepad Blink headers to be part of the Gamepad client library (Closed)
Patch Set: rebase and address comments Created 3 years, 8 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 | « device/gamepad/gamepad_provider_unittest.cc ('k') | device/gamepad/gamepad_service.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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 DEVICE_GAMEPAD_GAMEPAD_SERVICE_H_ 5 #ifndef DEVICE_GAMEPAD_GAMEPAD_SERVICE_H_
6 #define DEVICE_GAMEPAD_GAMEPAD_SERVICE_H_ 6 #define DEVICE_GAMEPAD_GAMEPAD_SERVICE_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <set> 9 #include <set>
10 10
11 #include "base/callback_forward.h" 11 #include "base/callback_forward.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/memory/shared_memory.h" 13 #include "base/memory/shared_memory.h"
14 #include "base/memory/singleton.h" 14 #include "base/memory/singleton.h"
15 #include "device/gamepad/gamepad_export.h" 15 #include "device/gamepad/gamepad_export.h"
16 #include "device/gamepad/gamepad_provider.h" 16 #include "device/gamepad/gamepad_provider.h"
17 17
18 namespace { 18 namespace {
19 class SingleThreadTaskRunner; 19 class SingleThreadTaskRunner;
20 } 20 }
21 21
22 namespace blink {
23 class WebGamepad;
24 }
25
26 namespace content { 22 namespace content {
27 class GamepadServiceTestConstructor; 23 class GamepadServiceTestConstructor;
28 } 24 }
29 25
30 namespace device { 26 namespace device {
31 class GamepadConsumer; 27 class GamepadConsumer;
32 class GamepadDataFetcher; 28 class GamepadDataFetcher;
33 class GamepadProvider; 29 class GamepadProvider;
34 30
35 // Owns the GamepadProvider (the background polling thread) and keeps track of 31 // Owns the GamepadProvider (the background polling thread) and keeps track of
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 base::SharedMemoryHandle GetSharedMemoryHandleForProcess( 72 base::SharedMemoryHandle GetSharedMemoryHandleForProcess(
77 base::ProcessHandle handle); 73 base::ProcessHandle handle);
78 74
79 // Returns a new mojo::ScopedSharedBuffer handle of the gamepad data. 75 // Returns a new mojo::ScopedSharedBuffer handle of the gamepad data.
80 mojo::ScopedSharedBufferHandle GetSharedBufferHandle(); 76 mojo::ScopedSharedBufferHandle GetSharedBufferHandle();
81 77
82 // Stop/join with the background thread in GamepadProvider |provider_|. 78 // Stop/join with the background thread in GamepadProvider |provider_|.
83 void Terminate(); 79 void Terminate();
84 80
85 // Called on IO thread when a gamepad is connected. 81 // Called on IO thread when a gamepad is connected.
86 void OnGamepadConnected(int index, const blink::WebGamepad& pad); 82 void OnGamepadConnected(int index, const Gamepad& pad);
87 83
88 // Called on IO thread when a gamepad is disconnected. 84 // Called on IO thread when a gamepad is disconnected.
89 void OnGamepadDisconnected(int index, const blink::WebGamepad& pad); 85 void OnGamepadDisconnected(int index, const Gamepad& pad);
90 86
91 private: 87 private:
92 friend struct base::DefaultSingletonTraits<GamepadService>; 88 friend struct base::DefaultSingletonTraits<GamepadService>;
93 friend class GamepadServiceTestConstructor; 89 friend class GamepadServiceTestConstructor;
94 friend class GamepadServiceTest; 90 friend class GamepadServiceTest;
95 91
96 GamepadService(); 92 GamepadService();
97 93
98 // Constructor for testing. This specifies the data fetcher to use for a 94 // Constructor for testing. This specifies the data fetcher to use for a
99 // provider, bypassing the default platform one. 95 // provider, bypassing the default platform one.
100 GamepadService(std::unique_ptr<device::GamepadDataFetcher> fetcher); 96 GamepadService(std::unique_ptr<device::GamepadDataFetcher> fetcher);
101 97
102 virtual ~GamepadService(); 98 virtual ~GamepadService();
103 99
104 static void SetInstance(GamepadService*); 100 static void SetInstance(GamepadService*);
105 101
106 void OnUserGesture(); 102 void OnUserGesture();
107 103
108 void OnGamepadConnectionChange(bool connected, 104 void OnGamepadConnectionChange(bool connected,
109 int index, 105 int index,
110 const blink::WebGamepad& pad) override; 106 const Gamepad& pad) override;
111 107
112 void SetSanitizationEnabled(bool sanitize); 108 void SetSanitizationEnabled(bool sanitize);
113 109
114 struct ConsumerInfo { 110 struct ConsumerInfo {
115 ConsumerInfo(device::GamepadConsumer* consumer) 111 ConsumerInfo(device::GamepadConsumer* consumer)
116 : consumer(consumer), did_observe_user_gesture(false) {} 112 : consumer(consumer), did_observe_user_gesture(false) {}
117 113
118 bool operator<(const ConsumerInfo& other) const { 114 bool operator<(const ConsumerInfo& other) const {
119 return consumer < other.consumer; 115 return consumer < other.consumer;
120 } 116 }
(...skipping 13 matching lines...) Expand all
134 int num_active_consumers_; 130 int num_active_consumers_;
135 131
136 bool gesture_callback_pending_; 132 bool gesture_callback_pending_;
137 133
138 DISALLOW_COPY_AND_ASSIGN(GamepadService); 134 DISALLOW_COPY_AND_ASSIGN(GamepadService);
139 }; 135 };
140 136
141 } // namespace content 137 } // namespace content
142 138
143 #endif // DEVICE_GAMEPAD_GAMEPAD_SERVICE_H_ 139 #endif // DEVICE_GAMEPAD_GAMEPAD_SERVICE_H_
OLDNEW
« no previous file with comments | « device/gamepad/gamepad_provider_unittest.cc ('k') | device/gamepad/gamepad_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698