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

Side by Side Diff: content/shell/test_runner/gamepad_controller.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 | « content/shell/test_runner/DEPS ('k') | content/shell/test_runner/gamepad_controller.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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_SHELL_TEST_RUNNER_GAMEPAD_CONTROLLER_H_ 5 #ifndef CONTENT_SHELL_TEST_RUNNER_GAMEPAD_CONTROLLER_H_
6 #define CONTENT_SHELL_TEST_RUNNER_GAMEPAD_CONTROLLER_H_ 6 #define CONTENT_SHELL_TEST_RUNNER_GAMEPAD_CONTROLLER_H_
7 7
8 #include <map> 8 #include <map>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "base/memory/weak_ptr.h" 11 #include "base/memory/weak_ptr.h"
12 #include "content/shell/test_runner/test_runner_export.h" 12 #include "content/shell/test_runner/test_runner_export.h"
13 #include "third_party/WebKit/public/platform/WebGamepads.h" 13 #include "device/gamepad/public/cpp/gamepads.h"
14 14
15 namespace blink { 15 namespace blink {
16 class WebFrame; 16 class WebFrame;
17 class WebGamepadListener; 17 class WebGamepadListener;
18 } 18 }
19 19
20 namespace test_runner { 20 namespace test_runner {
21 21
22 class WebTestDelegate; 22 class WebTestDelegate;
23 23
24 class TEST_RUNNER_EXPORT GamepadController 24 class TEST_RUNNER_EXPORT GamepadController
25 : public base::SupportsWeakPtr<GamepadController> { 25 : public base::SupportsWeakPtr<GamepadController> {
26 public: 26 public:
27 static base::WeakPtr<GamepadController> Create(WebTestDelegate* delegate); 27 static base::WeakPtr<GamepadController> Create(WebTestDelegate* delegate);
28 ~GamepadController(); 28 ~GamepadController();
29 29
30 void Reset(); 30 void Reset();
31 void Install(blink::WebFrame* frame); 31 void Install(blink::WebFrame* frame);
32 32
33 void SampleGamepads(blink::WebGamepads& gamepads); 33 void SampleGamepads(device::Gamepads& gamepads);
34 void SetListener(blink::WebGamepadListener* listener); 34 void SetListener(blink::WebGamepadListener* listener);
35 35
36 private: 36 private:
37 friend class GamepadControllerBindings; 37 friend class GamepadControllerBindings;
38 GamepadController(); 38 GamepadController();
39 39
40 // TODO(b.kelemen): for historical reasons Connect just initializes the 40 // TODO(b.kelemen): for historical reasons Connect just initializes the
41 // object. The 'gamepadconnected' event will be dispatched via 41 // object. The 'gamepadconnected' event will be dispatched via
42 // DispatchConnected. Tests for connected events need to first connect(), 42 // DispatchConnected. Tests for connected events need to first connect(),
43 // then set the gamepad data and finally call dispatchConnected(). 43 // then set the gamepad data and finally call dispatchConnected().
44 // We should consider renaming Connect to Init and DispatchConnected to 44 // We should consider renaming Connect to Init and DispatchConnected to
45 // Connect and at the same time updating all the gamepad tests. 45 // Connect and at the same time updating all the gamepad tests.
46 void Connect(int index); 46 void Connect(int index);
47 void DispatchConnected(int index); 47 void DispatchConnected(int index);
48 48
49 void Disconnect(int index); 49 void Disconnect(int index);
50 void SetId(int index, const std::string& src); 50 void SetId(int index, const std::string& src);
51 void SetButtonCount(int index, int buttons); 51 void SetButtonCount(int index, int buttons);
52 void SetButtonData(int index, int button, double data); 52 void SetButtonData(int index, int button, double data);
53 void SetAxisCount(int index, int axes); 53 void SetAxisCount(int index, int axes);
54 void SetAxisData(int index, int axis, double data); 54 void SetAxisData(int index, int axis, double data);
55 55
56 blink::WebGamepadListener* listener_; 56 blink::WebGamepadListener* listener_;
57 57
58 blink::WebGamepads gamepads_; 58 device::Gamepads gamepads_;
59 59
60 // Mapping from gamepad index to connection state. 60 // Mapping from gamepad index to connection state.
61 std::map<int, bool> pending_changes_; 61 std::map<int, bool> pending_changes_;
62 62
63 base::WeakPtrFactory<GamepadController> weak_factory_; 63 base::WeakPtrFactory<GamepadController> weak_factory_;
64 64
65 DISALLOW_COPY_AND_ASSIGN(GamepadController); 65 DISALLOW_COPY_AND_ASSIGN(GamepadController);
66 }; 66 };
67 67
68 } // namespace test_runner 68 } // namespace test_runner
69 69
70 #endif // CONTENT_SHELL_TEST_RUNNER_GAMEPAD_CONTROLLER_H_ 70 #endif // CONTENT_SHELL_TEST_RUNNER_GAMEPAD_CONTROLLER_H_
OLDNEW
« no previous file with comments | « content/shell/test_runner/DEPS ('k') | content/shell/test_runner/gamepad_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698