| 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 <cmath> | 5 #include <cmath> |
| 6 #include <set> | 6 #include <set> |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 CHECK(res); | 124 CHECK(res); |
| 125 GamepadHardwareBuffer* hwbuf = SharedMemoryAsHardwareBuffer(); | 125 GamepadHardwareBuffer* hwbuf = SharedMemoryAsHardwareBuffer(); |
| 126 memset(hwbuf, 0, sizeof(GamepadHardwareBuffer)); | 126 memset(hwbuf, 0, sizeof(GamepadHardwareBuffer)); |
| 127 pad_states_.reset(new PadState[WebGamepads::itemsLengthCap]); | 127 pad_states_.reset(new PadState[WebGamepads::itemsLengthCap]); |
| 128 | 128 |
| 129 polling_thread_.reset(new base::Thread("Gamepad polling thread")); | 129 polling_thread_.reset(new base::Thread("Gamepad polling thread")); |
| 130 #if defined(OS_LINUX) | 130 #if defined(OS_LINUX) |
| 131 // On Linux, the data fetcher needs to watch file descriptors, so the message | 131 // On Linux, the data fetcher needs to watch file descriptors, so the message |
| 132 // loop needs to be a libevent loop. | 132 // loop needs to be a libevent loop. |
| 133 const base::MessageLoop::Type kMessageLoopType = base::MessageLoop::TYPE_IO; | 133 const base::MessageLoop::Type kMessageLoopType = base::MessageLoop::TYPE_IO; |
| 134 #elif defined(OS_ANDROID) | |
| 135 // On Android, keeping a message loop of default type. | |
| 136 const base::MessageLoop::Type kMessageLoopType = | |
| 137 base::MessageLoop::TYPE_DEFAULT; | |
| 138 #else | 134 #else |
| 139 // On Mac, the data fetcher uses IOKit which depends on CFRunLoop, so the | 135 // On Mac, the data fetcher uses IOKit which depends on CFRunLoop, so the |
| 140 // message loop needs to be a UI-type loop. On Windows it must be a UI loop | 136 // message loop needs to be a UI-type loop. On Windows it must be a UI loop |
| 141 // to properly pump the MessageWindow that captures device state. | 137 // to properly pump the MessageWindow that captures device state. |
| 142 const base::MessageLoop::Type kMessageLoopType = base::MessageLoop::TYPE_UI; | 138 const base::MessageLoop::Type kMessageLoopType = base::MessageLoop::TYPE_UI; |
| 143 #endif | 139 #endif |
| 144 polling_thread_->StartWithOptions(base::Thread::Options(kMessageLoopType, 0)); | 140 polling_thread_->StartWithOptions(base::Thread::Options(kMessageLoopType, 0)); |
| 145 | 141 |
| 146 polling_thread_->message_loop()->PostTask( | 142 polling_thread_->message_loop()->PostTask( |
| 147 FROM_HERE, | 143 FROM_HERE, |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 312 ever_had_user_gesture_ = true; | 308 ever_had_user_gesture_ = true; |
| 313 for (size_t i = 0; i < user_gesture_observers_.size(); i++) { | 309 for (size_t i = 0; i < user_gesture_observers_.size(); i++) { |
| 314 user_gesture_observers_[i].message_loop->PostTask(FROM_HERE, | 310 user_gesture_observers_[i].message_loop->PostTask(FROM_HERE, |
| 315 user_gesture_observers_[i].closure); | 311 user_gesture_observers_[i].closure); |
| 316 } | 312 } |
| 317 user_gesture_observers_.clear(); | 313 user_gesture_observers_.clear(); |
| 318 } | 314 } |
| 319 } | 315 } |
| 320 | 316 |
| 321 } // namespace content | 317 } // namespace content |
| OLD | NEW |