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

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

Issue 1369643002: Add configuration and interface permission checks to DeviceImpl. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add new method ot Android USB mocks. Created 5 years, 2 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 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_handle_impl.h" 5 #include "device/usb/usb_device_handle_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 665 matching lines...) Expand 10 before | Expand all | Expand 10 after
676 task_runner_, callback); 676 task_runner_, callback);
677 } else { 677 } else {
678 task_runner_->PostTask( 678 task_runner_->PostTask(
679 FROM_HERE, 679 FROM_HERE,
680 base::Bind(&UsbDeviceHandleImpl::GenericTransferInternal, this, 680 base::Bind(&UsbDeviceHandleImpl::GenericTransferInternal, this,
681 direction, endpoint, buffer, length, timeout, 681 direction, endpoint, buffer, length, timeout,
682 base::ThreadTaskRunnerHandle::Get(), callback)); 682 base::ThreadTaskRunnerHandle::Get(), callback));
683 } 683 }
684 } 684 }
685 685
686 bool UsbDeviceHandleImpl::FindInterfaceByEndpoint(uint8_t endpoint_address,
687 uint8_t* interface_number) {
688 DCHECK(thread_checker_.CalledOnValidThread());
689 const auto endpoint_it = endpoint_map_.find(endpoint_address);
690 if (endpoint_it != endpoint_map_.end()) {
691 *interface_number = endpoint_it->second.interface_number;
692 return true;
693 }
694 return false;
695 }
696
686 UsbDeviceHandleImpl::UsbDeviceHandleImpl( 697 UsbDeviceHandleImpl::UsbDeviceHandleImpl(
687 scoped_refptr<UsbContext> context, 698 scoped_refptr<UsbContext> context,
688 scoped_refptr<UsbDeviceImpl> device, 699 scoped_refptr<UsbDeviceImpl> device,
689 PlatformUsbDeviceHandle handle, 700 PlatformUsbDeviceHandle handle,
690 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner) 701 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner)
691 : device_(device), 702 : device_(device),
692 handle_(handle), 703 handle_(handle),
693 context_(context), 704 context_(context),
694 task_runner_(base::ThreadTaskRunnerHandle::Get()), 705 task_runner_(base::ThreadTaskRunnerHandle::Get()),
695 blocking_task_runner_(blocking_task_runner) { 706 blocking_task_runner_(blocking_task_runner) {
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
820 } 831 }
821 break; 832 break;
822 } 833 }
823 } 834 }
824 } 835 }
825 } 836 }
826 } 837 }
827 838
828 scoped_refptr<UsbDeviceHandleImpl::InterfaceClaimer> 839 scoped_refptr<UsbDeviceHandleImpl::InterfaceClaimer>
829 UsbDeviceHandleImpl::GetClaimedInterfaceForEndpoint(uint8_t endpoint) { 840 UsbDeviceHandleImpl::GetClaimedInterfaceForEndpoint(uint8_t endpoint) {
830 if (ContainsKey(endpoint_map_, endpoint)) 841 const auto endpoint_it = endpoint_map_.find(endpoint);
831 return claimed_interfaces_[endpoint_map_[endpoint].interface_number]; 842 if (endpoint_it != endpoint_map_.end())
832 return NULL; 843 return claimed_interfaces_[endpoint_it->second.interface_number];
844 return nullptr;
833 } 845 }
834 846
835 void UsbDeviceHandleImpl::ControlTransferInternal( 847 void UsbDeviceHandleImpl::ControlTransferInternal(
836 UsbEndpointDirection direction, 848 UsbEndpointDirection direction,
837 TransferRequestType request_type, 849 TransferRequestType request_type,
838 TransferRecipient recipient, 850 TransferRecipient recipient,
839 uint8_t request, 851 uint8_t request,
840 uint16_t value, 852 uint16_t value,
841 uint16_t index, 853 uint16_t index,
842 scoped_refptr<net::IOBuffer> buffer, 854 scoped_refptr<net::IOBuffer> buffer,
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
1050 // Attempt-release all the interfaces. 1062 // Attempt-release all the interfaces.
1051 // It will be retained until the transfer cancellation is finished. 1063 // It will be retained until the transfer cancellation is finished.
1052 claimed_interfaces_.clear(); 1064 claimed_interfaces_.clear();
1053 1065
1054 // Cannot close device handle here. Need to wait for libusb_cancel_transfer to 1066 // Cannot close device handle here. Need to wait for libusb_cancel_transfer to
1055 // finish. 1067 // finish.
1056 device_ = NULL; 1068 device_ = NULL;
1057 } 1069 }
1058 1070
1059 } // namespace device 1071 } // namespace device
OLDNEW
« chrome/browser/usb/web_usb_permission_provider.cc ('K') | « device/usb/usb_device_handle_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698