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

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

Issue 133943002: Gamepad API support for chrome on android (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: 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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 size_t data_size = sizeof(GamepadHardwareBuffer); 106 size_t data_size = sizeof(GamepadHardwareBuffer);
107 base::SystemMonitor* monitor = base::SystemMonitor::Get(); 107 base::SystemMonitor* monitor = base::SystemMonitor::Get();
108 if (monitor) 108 if (monitor)
109 monitor->AddDevicesChangedObserver(this); 109 monitor->AddDevicesChangedObserver(this);
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) || defined(OS_ANDROID)
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 #else 120 #else
121 // On Mac, the data fetcher uses IOKit which depends on CFRunLoop, so the 121 // 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 122 // 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. 123 // to properly pump the MessageWindow that captures device state.
124 const base::MessageLoop::Type kMessageLoopType = base::MessageLoop::TYPE_UI; 124 const base::MessageLoop::Type kMessageLoopType = base::MessageLoop::TYPE_UI;
125 #endif 125 #endif
126 polling_thread_->StartWithOptions(base::Thread::Options(kMessageLoopType, 0)); 126 polling_thread_->StartWithOptions(base::Thread::Options(kMessageLoopType, 0));
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 if (GamepadsHaveUserGesture(SharedMemoryAsHardwareBuffer()->buffer)) { 211 if (GamepadsHaveUserGesture(SharedMemoryAsHardwareBuffer()->buffer)) {
212 for (size_t i = 0; i < user_gesture_observers_.size(); i++) { 212 for (size_t i = 0; i < user_gesture_observers_.size(); i++) {
213 user_gesture_observers_[i].message_loop->PostTask(FROM_HERE, 213 user_gesture_observers_[i].message_loop->PostTask(FROM_HERE,
214 user_gesture_observers_[i].closure); 214 user_gesture_observers_[i].closure);
215 } 215 }
216 user_gesture_observers_.clear(); 216 user_gesture_observers_.clear();
217 } 217 }
218 } 218 }
219 219
220 } // namespace content 220 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698