| OLD | NEW |
| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 | 10 |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 client->OpenPath( | 197 client->OpenPath( |
| 198 device_path_, | 198 device_path_, |
| 199 base::Bind(&UsbDeviceImpl::OnOpenRequestComplete, this, callback)); | 199 base::Bind(&UsbDeviceImpl::OnOpenRequestComplete, this, callback)); |
| 200 #else | 200 #else |
| 201 blocking_task_runner_->PostTask( | 201 blocking_task_runner_->PostTask( |
| 202 FROM_HERE, | 202 FROM_HERE, |
| 203 base::Bind(&UsbDeviceImpl::OpenOnBlockingThread, this, callback)); | 203 base::Bind(&UsbDeviceImpl::OpenOnBlockingThread, this, callback)); |
| 204 #endif // defined(OS_CHROMEOS) | 204 #endif // defined(OS_CHROMEOS) |
| 205 } | 205 } |
| 206 | 206 |
| 207 void UsbDeviceImpl::Close(scoped_refptr<UsbDeviceHandle> handle) { | 207 bool UsbDeviceImpl::Close(scoped_refptr<UsbDeviceHandle> handle) { |
| 208 DCHECK(thread_checker_.CalledOnValidThread()); | 208 DCHECK(thread_checker_.CalledOnValidThread()); |
| 209 | 209 |
| 210 for (HandlesVector::iterator it = handles_.begin(); it != handles_.end(); | 210 for (HandlesVector::iterator it = handles_.begin(); it != handles_.end(); |
| 211 ++it) { | 211 ++it) { |
| 212 if (it->get() == handle.get()) { | 212 if (it->get() == handle.get()) { |
| 213 (*it)->InternalClose(); | 213 (*it)->InternalClose(); |
| 214 handles_.erase(it); | 214 handles_.erase(it); |
| 215 return; | 215 return true; |
| 216 } | 216 } |
| 217 } | 217 } |
| 218 return false; |
| 218 } | 219 } |
| 219 | 220 |
| 220 const UsbConfigDescriptor* UsbDeviceImpl::GetActiveConfiguration() { | 221 const UsbConfigDescriptor* UsbDeviceImpl::GetActiveConfiguration() { |
| 221 DCHECK(thread_checker_.CalledOnValidThread()); | 222 DCHECK(thread_checker_.CalledOnValidThread()); |
| 222 return active_configuration_; | 223 return active_configuration_; |
| 223 } | 224 } |
| 224 | 225 |
| 225 void UsbDeviceImpl::OnDisconnect() { | 226 void UsbDeviceImpl::OnDisconnect() { |
| 226 DCHECK(thread_checker_.CalledOnValidThread()); | 227 DCHECK(thread_checker_.CalledOnValidThread()); |
| 227 | 228 |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 330 void UsbDeviceImpl::Opened(PlatformUsbDeviceHandle platform_handle, | 331 void UsbDeviceImpl::Opened(PlatformUsbDeviceHandle platform_handle, |
| 331 const OpenCallback& callback) { | 332 const OpenCallback& callback) { |
| 332 DCHECK(thread_checker_.CalledOnValidThread()); | 333 DCHECK(thread_checker_.CalledOnValidThread()); |
| 333 scoped_refptr<UsbDeviceHandleImpl> device_handle = new UsbDeviceHandleImpl( | 334 scoped_refptr<UsbDeviceHandleImpl> device_handle = new UsbDeviceHandleImpl( |
| 334 context_, this, platform_handle, blocking_task_runner_); | 335 context_, this, platform_handle, blocking_task_runner_); |
| 335 handles_.push_back(device_handle); | 336 handles_.push_back(device_handle); |
| 336 callback.Run(device_handle); | 337 callback.Run(device_handle); |
| 337 } | 338 } |
| 338 | 339 |
| 339 } // namespace device | 340 } // namespace device |
| OLD | NEW |