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 bool UsbDeviceImpl::Close(scoped_refptr<UsbDeviceHandle> handle) { | 207 void 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 true; | 215 return; |
216 } | 216 } |
217 } | 217 } |
218 return false; | |
219 } | 218 } |
220 | 219 |
221 const UsbConfigDescriptor* UsbDeviceImpl::GetActiveConfiguration() { | 220 const UsbConfigDescriptor* UsbDeviceImpl::GetActiveConfiguration() { |
222 DCHECK(thread_checker_.CalledOnValidThread()); | 221 DCHECK(thread_checker_.CalledOnValidThread()); |
223 return active_configuration_; | 222 return active_configuration_; |
224 } | 223 } |
225 | 224 |
226 void UsbDeviceImpl::OnDisconnect() { | 225 void UsbDeviceImpl::OnDisconnect() { |
227 DCHECK(thread_checker_.CalledOnValidThread()); | 226 DCHECK(thread_checker_.CalledOnValidThread()); |
228 | 227 |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
331 void UsbDeviceImpl::Opened(PlatformUsbDeviceHandle platform_handle, | 330 void UsbDeviceImpl::Opened(PlatformUsbDeviceHandle platform_handle, |
332 const OpenCallback& callback) { | 331 const OpenCallback& callback) { |
333 DCHECK(thread_checker_.CalledOnValidThread()); | 332 DCHECK(thread_checker_.CalledOnValidThread()); |
334 scoped_refptr<UsbDeviceHandleImpl> device_handle = new UsbDeviceHandleImpl( | 333 scoped_refptr<UsbDeviceHandleImpl> device_handle = new UsbDeviceHandleImpl( |
335 context_, this, platform_handle, blocking_task_runner_); | 334 context_, this, platform_handle, blocking_task_runner_); |
336 handles_.push_back(device_handle); | 335 handles_.push_back(device_handle); |
337 callback.Run(device_handle); | 336 callback.Run(device_handle); |
338 } | 337 } |
339 | 338 |
340 } // namespace device | 339 } // namespace device |
OLD | NEW |