Chromium Code Reviews| OLD | NEW |
|---|---|
| 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_RENDERER_TEST_RUNNER_GAMEPAD_CONTROLLER_H_ | 5 #ifndef CONTENT_SHELL_RENDERER_TEST_RUNNER_GAMEPAD_CONTROLLER_H_ |
| 6 #define CONTENT_SHELL_RENDERER_TEST_RUNNER_GAMEPAD_CONTROLLER_H_ | 6 #define CONTENT_SHELL_RENDERER_TEST_RUNNER_GAMEPAD_CONTROLLER_H_ |
| 7 | 7 |
| 8 #include <map> | |
| 9 | |
| 8 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
| 11 #include "content/public/renderer/renderer_gamepad_provider.h" | |
| 9 #include "third_party/WebKit/public/platform/WebGamepads.h" | 12 #include "third_party/WebKit/public/platform/WebGamepads.h" |
| 10 | 13 |
| 11 namespace blink { | 14 namespace blink { |
| 12 class WebFrame; | 15 class WebFrame; |
| 16 class WebGamepadListener; | |
| 13 } | 17 } |
| 14 | 18 |
| 15 namespace content { | 19 namespace content { |
| 16 | 20 |
| 17 class WebTestDelegate; | 21 class WebTestDelegate; |
| 18 | 22 |
| 19 class GamepadController : public base::SupportsWeakPtr<GamepadController> { | 23 class GamepadController |
| 24 : public base::SupportsWeakPtr<GamepadController> | |
| 25 , public RendererGamepadProvider { | |
|
jam
2014/06/18 23:23:42
nit: use google style comma on previous line)
| |
| 20 public: | 26 public: |
| 21 GamepadController(); | 27 GamepadController(); |
| 22 ~GamepadController(); | 28 virtual ~GamepadController(); |
| 23 | 29 |
| 24 void Reset(); | 30 void Reset(); |
| 25 void Install(blink::WebFrame* frame); | 31 void Install(blink::WebFrame* frame); |
| 26 void SetDelegate(WebTestDelegate* delegate); | 32 void SetDelegate(WebTestDelegate* delegate); |
| 27 | 33 |
| 34 // RendererGamepadProvider implementation. | |
| 35 virtual void SampleGamepads(blink::WebGamepads& gamepads); | |
| 36 virtual void SetGamepadListener(blink::WebGamepadListener*); | |
|
jam
2014/06/18 23:23:42
nit: google style is to put the parameter name her
| |
| 37 | |
| 28 private: | 38 private: |
| 29 friend class GamepadControllerBindings; | 39 friend class GamepadControllerBindings; |
| 30 | 40 |
| 31 // TODO(b.kelemen): for historical reasons Connect just initializes the | 41 // TODO(b.kelemen): for historical reasons Connect just initializes the |
| 32 // object. The 'gamepadconnected' event will be dispatched via | 42 // object. The 'gamepadconnected' event will be dispatched via |
| 33 // DispatchConnected. Tests for connected events need to first connect(), | 43 // DispatchConnected. Tests for connected events need to first connect(), |
| 34 // then set the gamepad data and finally call dispatchConnected(). | 44 // then set the gamepad data and finally call dispatchConnected(). |
| 35 // We should consider renaming Connect to Init and DispatchConnected to | 45 // We should consider renaming Connect to Init and DispatchConnected to |
| 36 // Connect and at the same time updating all the gamepad tests. | 46 // Connect and at the same time updating all the gamepad tests. |
| 37 void Connect(int index); | 47 void Connect(int index); |
| 38 void DispatchConnected(int index); | 48 void DispatchConnected(int index); |
| 39 | 49 |
| 40 void Disconnect(int index); | 50 void Disconnect(int index); |
| 41 void SetId(int index, const std::string& src); | 51 void SetId(int index, const std::string& src); |
| 42 void SetButtonCount(int index, int buttons); | 52 void SetButtonCount(int index, int buttons); |
| 43 void SetButtonData(int index, int button, double data); | 53 void SetButtonData(int index, int button, double data); |
| 44 void SetAxisCount(int index, int axes); | 54 void SetAxisCount(int index, int axes); |
| 45 void SetAxisData(int index, int axis, double data); | 55 void SetAxisData(int index, int axis, double data); |
| 46 | 56 |
| 47 blink::WebGamepads gamepads_; | 57 blink::WebGamepads gamepads_; |
| 48 | 58 |
| 49 WebTestDelegate* delegate_; | 59 blink::WebGamepadListener* listener_; |
| 60 | |
| 61 // Mapping from gamepad index to connection state. | |
| 62 std::map<int, bool> pending_changes_; | |
| 50 | 63 |
| 51 base::WeakPtrFactory<GamepadController> weak_factory_; | 64 base::WeakPtrFactory<GamepadController> weak_factory_; |
| 52 | 65 |
| 53 DISALLOW_COPY_AND_ASSIGN(GamepadController); | 66 DISALLOW_COPY_AND_ASSIGN(GamepadController); |
| 54 }; | 67 }; |
| 55 | 68 |
| 56 } // namespace content | 69 } // namespace content |
| 57 | 70 |
| 58 #endif // CONTENT_SHELL_RENDERER_TEST_RUNNER_GAMEPAD_CONTROLLER_H_ | 71 #endif // CONTENT_SHELL_RENDERER_TEST_RUNNER_GAMEPAD_CONTROLLER_H_ |
| OLD | NEW |