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

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, 6 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 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
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;
134 #else 138 #else
135 // On Mac, the data fetcher uses IOKit which depends on CFRunLoop, so the 139 // On Mac, the data fetcher uses IOKit which depends on CFRunLoop, so the
136 // message loop needs to be a UI-type loop. On Windows it must be a UI loop 140 // message loop needs to be a UI-type loop. On Windows it must be a UI loop
137 // to properly pump the MessageWindow that captures device state. 141 // to properly pump the MessageWindow that captures device state.
138 const base::MessageLoop::Type kMessageLoopType = base::MessageLoop::TYPE_UI; 142 const base::MessageLoop::Type kMessageLoopType = base::MessageLoop::TYPE_UI;
139 #endif 143 #endif
140 polling_thread_->StartWithOptions(base::Thread::Options(kMessageLoopType, 0)); 144 polling_thread_->StartWithOptions(base::Thread::Options(kMessageLoopType, 0));
141 145
142 polling_thread_->message_loop()->PostTask( 146 polling_thread_->message_loop()->PostTask(
143 FROM_HERE, 147 FROM_HERE,
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 ever_had_user_gesture_ = true; 312 ever_had_user_gesture_ = true;
309 for (size_t i = 0; i < user_gesture_observers_.size(); i++) { 313 for (size_t i = 0; i < user_gesture_observers_.size(); i++) {
310 user_gesture_observers_[i].message_loop->PostTask(FROM_HERE, 314 user_gesture_observers_[i].message_loop->PostTask(FROM_HERE,
311 user_gesture_observers_[i].closure); 315 user_gesture_observers_[i].closure);
312 } 316 }
313 user_gesture_observers_.clear(); 317 user_gesture_observers_.clear();
314 } 318 }
315 } 319 }
316 320
317 } // namespace content 321 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698