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

Side by Side Diff: device/gamepad/gamepad_provider.cc

Issue 2572323002: Delete WebGamepads::length. (Closed)
Patch Set: Rebase Created 3 years, 11 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
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 #include "device/gamepad/gamepad_provider.h" 5 #include "device/gamepad/gamepad_provider.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <string.h> 8 #include <string.h>
9 #include <cmath> 9 #include <cmath>
10 #include <utility> 10 #include <utility>
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 } 258 }
259 } 259 }
260 } 260 }
261 261
262 { 262 {
263 base::AutoLock lock(shared_memory_lock_); 263 base::AutoLock lock(shared_memory_lock_);
264 264
265 // Acquire the SeqLock. There is only ever one writer to this data. 265 // Acquire the SeqLock. There is only ever one writer to this data.
266 // See gamepad_shared_buffer.h. 266 // See gamepad_shared_buffer.h.
267 gamepad_shared_buffer_->WriteBegin(); 267 gamepad_shared_buffer_->WriteBegin();
268 buffer->length = 0;
269 for (unsigned i = 0; i < WebGamepads::itemsLengthCap; ++i) { 268 for (unsigned i = 0; i < WebGamepads::itemsLengthCap; ++i) {
270 PadState& state = pad_states_.get()[i]; 269 PadState& state = pad_states_.get()[i];
271 // Must run through the map+sanitize here or CheckForUserGesture may fail. 270 // Must run through the map+sanitize here or CheckForUserGesture may fail.
272 MapAndSanitizeGamepadData(&state, &buffer->items[i], sanitize_); 271 MapAndSanitizeGamepadData(&state, &buffer->items[i], sanitize_);
273 if (state.active_state)
274 buffer->length++;
275 } 272 }
276 gamepad_shared_buffer_->WriteEnd(); 273 gamepad_shared_buffer_->WriteEnd();
277 } 274 }
278 275
279 if (ever_had_user_gesture_) { 276 if (ever_had_user_gesture_) {
280 for (unsigned i = 0; i < WebGamepads::itemsLengthCap; ++i) { 277 for (unsigned i = 0; i < WebGamepads::itemsLengthCap; ++i) {
281 PadState& state = pad_states_.get()[i]; 278 PadState& state = pad_states_.get()[i];
282 279
283 if (state.active_state) { 280 if (state.active_state) {
284 if (state.active_state == GAMEPAD_NEWLY_ACTIVE) 281 if (state.active_state == GAMEPAD_NEWLY_ACTIVE)
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 ever_had_user_gesture_ = true; 325 ever_had_user_gesture_ = true;
329 for (size_t i = 0; i < user_gesture_observers_.size(); i++) { 326 for (size_t i = 0; i < user_gesture_observers_.size(); i++) {
330 user_gesture_observers_[i].task_runner->PostTask( 327 user_gesture_observers_[i].task_runner->PostTask(
331 FROM_HERE, user_gesture_observers_[i].closure); 328 FROM_HERE, user_gesture_observers_[i].closure);
332 } 329 }
333 user_gesture_observers_.clear(); 330 user_gesture_observers_.clear();
334 } 331 }
335 } 332 }
336 333
337 } // namespace device 334 } // namespace device
OLDNEW
« no previous file with comments | « content/browser/renderer_host/pepper/pepper_gamepad_host_unittest.cc ('k') | device/gamepad/gamepad_provider_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698