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

Side by Side Diff: device/usb/usb_device_impl.cc

Issue 1514603006: Implement basic USB device enumeration on Android. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix android_usb_browsertest.cc. Created 5 years 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "device/usb/usb_device_impl.h" 5 #include "device/usb/usb_device_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/location.h" 10 #include "base/location.h"
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 client->OpenPath( 194 client->OpenPath(
195 device_path_, 195 device_path_,
196 base::Bind(&UsbDeviceImpl::OnOpenRequestComplete, this, callback)); 196 base::Bind(&UsbDeviceImpl::OnOpenRequestComplete, this, callback));
197 #else 197 #else
198 blocking_task_runner_->PostTask( 198 blocking_task_runner_->PostTask(
199 FROM_HERE, 199 FROM_HERE,
200 base::Bind(&UsbDeviceImpl::OpenOnBlockingThread, this, callback)); 200 base::Bind(&UsbDeviceImpl::OpenOnBlockingThread, this, callback));
201 #endif // defined(OS_CHROMEOS) 201 #endif // defined(OS_CHROMEOS)
202 } 202 }
203 203
204 bool UsbDeviceImpl::Close(scoped_refptr<UsbDeviceHandle> handle) { 204 void UsbDeviceImpl::Close(scoped_refptr<UsbDeviceHandle> handle) {
205 DCHECK(thread_checker_.CalledOnValidThread()); 205 DCHECK(thread_checker_.CalledOnValidThread());
206 206
207 for (HandlesVector::iterator it = handles_.begin(); it != handles_.end(); 207 for (HandlesVector::iterator it = handles_.begin(); it != handles_.end();
208 ++it) { 208 ++it) {
209 if (it->get() == handle.get()) { 209 if (it->get() == handle.get()) {
210 (*it)->InternalClose(); 210 (*it)->InternalClose();
211 handles_.erase(it); 211 handles_.erase(it);
212 return true; 212 return;
213 } 213 }
214 } 214 }
215 return false;
216 } 215 }
217 216
218 const UsbConfigDescriptor* UsbDeviceImpl::GetActiveConfiguration() { 217 const UsbConfigDescriptor* UsbDeviceImpl::GetActiveConfiguration() {
219 DCHECK(thread_checker_.CalledOnValidThread()); 218 DCHECK(thread_checker_.CalledOnValidThread());
220 return active_configuration_; 219 return active_configuration_;
221 } 220 }
222 221
223 void UsbDeviceImpl::OnDisconnect() { 222 void UsbDeviceImpl::OnDisconnect() {
224 DCHECK(thread_checker_.CalledOnValidThread()); 223 DCHECK(thread_checker_.CalledOnValidThread());
225 224
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 void UsbDeviceImpl::Opened(PlatformUsbDeviceHandle platform_handle, 327 void UsbDeviceImpl::Opened(PlatformUsbDeviceHandle platform_handle,
329 const OpenCallback& callback) { 328 const OpenCallback& callback) {
330 DCHECK(thread_checker_.CalledOnValidThread()); 329 DCHECK(thread_checker_.CalledOnValidThread());
331 scoped_refptr<UsbDeviceHandleImpl> device_handle = new UsbDeviceHandleImpl( 330 scoped_refptr<UsbDeviceHandleImpl> device_handle = new UsbDeviceHandleImpl(
332 context_, this, platform_handle, blocking_task_runner_); 331 context_, this, platform_handle, blocking_task_runner_);
333 handles_.push_back(device_handle); 332 handles_.push_back(device_handle);
334 callback.Run(device_handle); 333 callback.Run(device_handle);
335 } 334 }
336 335
337 } // namespace device 336 } // namespace device
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698