| OLD | NEW |
| 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 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 246 | 246 |
| 247 blink::WebGamepads* buffer = gamepad_shared_buffer_->buffer(); | 247 blink::WebGamepads* buffer = gamepad_shared_buffer_->buffer(); |
| 248 | 248 |
| 249 // Send out disconnect events using the last polled data before we wipe it out | 249 // Send out disconnect events using the last polled data before we wipe it out |
| 250 // in the mapping step. | 250 // in the mapping step. |
| 251 if (ever_had_user_gesture_) { | 251 if (ever_had_user_gesture_) { |
| 252 for (unsigned i = 0; i < WebGamepads::itemsLengthCap; ++i) { | 252 for (unsigned i = 0; i < WebGamepads::itemsLengthCap; ++i) { |
| 253 PadState& state = pad_states_.get()[i]; | 253 PadState& state = pad_states_.get()[i]; |
| 254 | 254 |
| 255 if (!state.active_state && state.source != GAMEPAD_SOURCE_NONE) { | 255 if (!state.active_state && state.source != GAMEPAD_SOURCE_NONE) { |
| 256 OnGamepadConnectionChange(false, i, buffer->items[i]); | 256 blink::WebGamepad& pad = buffer->items[i]; |
| 257 pad.connected = false; |
| 258 OnGamepadConnectionChange(false, i, pad); |
| 257 ClearPadState(state); | 259 ClearPadState(state); |
| 258 } | 260 } |
| 259 } | 261 } |
| 260 } | 262 } |
| 261 | 263 |
| 262 { | 264 { |
| 263 base::AutoLock lock(shared_memory_lock_); | 265 base::AutoLock lock(shared_memory_lock_); |
| 264 | 266 |
| 265 // Acquire the SeqLock. There is only ever one writer to this data. | 267 // Acquire the SeqLock. There is only ever one writer to this data. |
| 266 // See gamepad_shared_buffer.h. | 268 // See gamepad_shared_buffer.h. |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 325 ever_had_user_gesture_ = true; | 327 ever_had_user_gesture_ = true; |
| 326 for (size_t i = 0; i < user_gesture_observers_.size(); i++) { | 328 for (size_t i = 0; i < user_gesture_observers_.size(); i++) { |
| 327 user_gesture_observers_[i].task_runner->PostTask( | 329 user_gesture_observers_[i].task_runner->PostTask( |
| 328 FROM_HERE, user_gesture_observers_[i].closure); | 330 FROM_HERE, user_gesture_observers_[i].closure); |
| 329 } | 331 } |
| 330 user_gesture_observers_.clear(); | 332 user_gesture_observers_.clear(); |
| 331 } | 333 } |
| 332 } | 334 } |
| 333 | 335 |
| 334 } // namespace device | 336 } // namespace device |
| OLD | NEW |