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

Side by Side Diff: content/shell/renderer/test_runner/gamepad_controller.cc

Issue 613203002: Have PlatformEventObserver implementations orderly stop on destruction. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Clean up a comment. Created 6 years, 2 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/renderer/screen_orientation/screen_orientation_observer.cc ('k') | no next file » | 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 #include "content/shell/renderer/test_runner/gamepad_controller.h" 5 #include "content/shell/renderer/test_runner/gamepad_controller.h"
6 6
7 #include "content/shell/renderer/test_runner/web_test_delegate.h" 7 #include "content/shell/renderer/test_runner/web_test_delegate.h"
8 #include "gin/arguments.h" 8 #include "gin/arguments.h"
9 #include "gin/handle.h" 9 #include "gin/handle.h"
10 #include "gin/object_template_builder.h" 10 #include "gin/object_template_builder.h"
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 delegate->SetGamepadProvider(scoped_ptr<RendererGamepadProvider>(controller)); 144 delegate->SetGamepadProvider(scoped_ptr<RendererGamepadProvider>(controller));
145 return controller->weak_factory_.GetWeakPtr(); 145 return controller->weak_factory_.GetWeakPtr();
146 } 146 }
147 147
148 GamepadController::GamepadController() 148 GamepadController::GamepadController()
149 : RendererGamepadProvider(0), 149 : RendererGamepadProvider(0),
150 weak_factory_(this) { 150 weak_factory_(this) {
151 Reset(); 151 Reset();
152 } 152 }
153 153
154 GamepadController::~GamepadController() {} 154 GamepadController::~GamepadController() {
155 StopIfObserving();
156 }
155 157
156 void GamepadController::Reset() { 158 void GamepadController::Reset() {
157 memset(&gamepads_, 0, sizeof(gamepads_)); 159 memset(&gamepads_, 0, sizeof(gamepads_));
158 } 160 }
159 161
160 void GamepadController::Install(WebFrame* frame) { 162 void GamepadController::Install(WebFrame* frame) {
161 GamepadControllerBindings::Install(weak_factory_.GetWeakPtr(), frame); 163 GamepadControllerBindings::Install(weak_factory_.GetWeakPtr(), frame);
162 } 164 }
163 165
164 166
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 248
247 void GamepadController::SetAxisData(int index, int axis, double data) { 249 void GamepadController::SetAxisData(int index, int axis, double data) {
248 if (index < 0 || index >= static_cast<int>(WebGamepads::itemsLengthCap)) 250 if (index < 0 || index >= static_cast<int>(WebGamepads::itemsLengthCap))
249 return; 251 return;
250 if (axis < 0 || axis >= static_cast<int>(WebGamepad::axesLengthCap)) 252 if (axis < 0 || axis >= static_cast<int>(WebGamepad::axesLengthCap))
251 return; 253 return;
252 gamepads_.items[index].axes[axis] = data; 254 gamepads_.items[index].axes[axis] = data;
253 } 255 }
254 256
255 } // namespace content 257 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/screen_orientation/screen_orientation_observer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698