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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 bool res = gamepad_shared_memory_.CreateAndMapAnonymous(data_size); | 110 bool res = gamepad_shared_memory_.CreateAndMapAnonymous(data_size); |
111 CHECK(res); | 111 CHECK(res); |
112 GamepadHardwareBuffer* hwbuf = SharedMemoryAsHardwareBuffer(); | 112 GamepadHardwareBuffer* hwbuf = SharedMemoryAsHardwareBuffer(); |
113 memset(hwbuf, 0, sizeof(GamepadHardwareBuffer)); | 113 memset(hwbuf, 0, sizeof(GamepadHardwareBuffer)); |
114 | 114 |
115 polling_thread_.reset(new base::Thread("Gamepad polling thread")); | 115 polling_thread_.reset(new base::Thread("Gamepad polling thread")); |
116 #if defined(OS_LINUX) | 116 #if defined(OS_LINUX) |
117 // On Linux, the data fetcher needs to watch file descriptors, so the message | 117 // On Linux, the data fetcher needs to watch file descriptors, so the message |
118 // loop needs to be a libevent loop. | 118 // loop needs to be a libevent loop. |
119 const base::MessageLoop::Type kMessageLoopType = base::MessageLoop::TYPE_IO; | 119 const base::MessageLoop::Type kMessageLoopType = base::MessageLoop::TYPE_IO; |
| 120 #elif defined(OS_ANDROID) |
| 121 // On Android a default loop is fine. |
| 122 const base::MessageLoop::Type kMessageLoopType = |
| 123 base::MessageLoop::TYPE_DEFAULT; |
120 #else | 124 #else |
121 // On Mac, the data fetcher uses IOKit which depends on CFRunLoop, so the | 125 // On Mac, the data fetcher uses IOKit which depends on CFRunLoop, so the |
122 // message loop needs to be a UI-type loop. On Windows it must be a UI loop | 126 // message loop needs to be a UI-type loop. On Windows it must be a UI loop |
123 // to properly pump the MessageWindow that captures device state. | 127 // to properly pump the MessageWindow that captures device state. |
124 const base::MessageLoop::Type kMessageLoopType = base::MessageLoop::TYPE_UI; | 128 const base::MessageLoop::Type kMessageLoopType = base::MessageLoop::TYPE_UI; |
125 #endif | 129 #endif |
126 polling_thread_->StartWithOptions(base::Thread::Options(kMessageLoopType, 0)); | 130 polling_thread_->StartWithOptions(base::Thread::Options(kMessageLoopType, 0)); |
127 | 131 |
128 polling_thread_->message_loop()->PostTask( | 132 polling_thread_->message_loop()->PostTask( |
129 FROM_HERE, | 133 FROM_HERE, |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 if (GamepadsHaveUserGesture(SharedMemoryAsHardwareBuffer()->buffer)) { | 215 if (GamepadsHaveUserGesture(SharedMemoryAsHardwareBuffer()->buffer)) { |
212 for (size_t i = 0; i < user_gesture_observers_.size(); i++) { | 216 for (size_t i = 0; i < user_gesture_observers_.size(); i++) { |
213 user_gesture_observers_[i].message_loop->PostTask(FROM_HERE, | 217 user_gesture_observers_[i].message_loop->PostTask(FROM_HERE, |
214 user_gesture_observers_[i].closure); | 218 user_gesture_observers_[i].closure); |
215 } | 219 } |
216 user_gesture_observers_.clear(); | 220 user_gesture_observers_.clear(); |
217 } | 221 } |
218 } | 222 } |
219 | 223 |
220 } // namespace content | 224 } // namespace content |
OLD | NEW |