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

Side by Side Diff: content/browser/gamepad/gamepad_provider.cc

Issue 165483003: Gamepad API for Android (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address comments Created 6 years, 9 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 <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
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
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
OLDNEW
« no previous file with comments | « content/browser/gamepad/gamepad_platform_data_fetcher_android.cc ('k') | content/browser/gamepad/gamepad_standard_mappings.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698