| Index: extensions/browser/api/usb/usb_api.cc
|
| diff --git a/extensions/browser/api/usb/usb_api.cc b/extensions/browser/api/usb/usb_api.cc
|
| index 6006dfbc502b01224fcb4955a054502ec04ae787..8280a63ae18618764fbeae4d55af963b94da986b 100644
|
| --- a/extensions/browser/api/usb/usb_api.cc
|
| +++ b/extensions/browser/api/usb/usb_api.cc
|
| @@ -51,14 +51,16 @@ namespace SetInterfaceAlternateSetting = usb::SetInterfaceAlternateSetting;
|
|
|
| using content::BrowserThread;
|
| using device::UsbConfigDescriptor;
|
| +using device::UsbControlTransferRecipient;
|
| +using device::UsbControlTransferType;
|
| using device::UsbDevice;
|
| using device::UsbDeviceFilter;
|
| using device::UsbDeviceHandle;
|
| using device::UsbEndpointDescriptor;
|
| -using device::UsbEndpointDirection;
|
| using device::UsbInterfaceDescriptor;
|
| using device::UsbService;
|
| using device::UsbSynchronizationType;
|
| +using device::UsbTransferDirection;
|
| using device::UsbTransferStatus;
|
| using device::UsbTransferType;
|
| using device::UsbUsageType;
|
| @@ -127,13 +129,13 @@ const int kMaxPackets = 4 * 1024 * 1024;
|
| const int kMaxPacketLength = 64 * 1024;
|
|
|
| bool ConvertDirectionFromApi(const Direction& input,
|
| - UsbEndpointDirection* output) {
|
| + UsbTransferDirection* output) {
|
| switch (input) {
|
| case usb::DIRECTION_IN:
|
| - *output = device::USB_DIRECTION_INBOUND;
|
| + *output = UsbTransferDirection::INBOUND;
|
| return true;
|
| case usb::DIRECTION_OUT:
|
| - *output = device::USB_DIRECTION_OUTBOUND;
|
| + *output = UsbTransferDirection::OUTBOUND;
|
| return true;
|
| default:
|
| NOTREACHED();
|
| @@ -142,19 +144,19 @@ bool ConvertDirectionFromApi(const Direction& input,
|
| }
|
|
|
| bool ConvertRequestTypeFromApi(const RequestType& input,
|
| - UsbDeviceHandle::TransferRequestType* output) {
|
| + UsbControlTransferType* output) {
|
| switch (input) {
|
| case usb::REQUEST_TYPE_STANDARD:
|
| - *output = UsbDeviceHandle::STANDARD;
|
| + *output = UsbControlTransferType::STANDARD;
|
| return true;
|
| case usb::REQUEST_TYPE_CLASS:
|
| - *output = UsbDeviceHandle::CLASS;
|
| + *output = UsbControlTransferType::CLASS;
|
| return true;
|
| case usb::REQUEST_TYPE_VENDOR:
|
| - *output = UsbDeviceHandle::VENDOR;
|
| + *output = UsbControlTransferType::VENDOR;
|
| return true;
|
| case usb::REQUEST_TYPE_RESERVED:
|
| - *output = UsbDeviceHandle::RESERVED;
|
| + *output = UsbControlTransferType::RESERVED;
|
| return true;
|
| default:
|
| NOTREACHED();
|
| @@ -163,19 +165,19 @@ bool ConvertRequestTypeFromApi(const RequestType& input,
|
| }
|
|
|
| bool ConvertRecipientFromApi(const Recipient& input,
|
| - UsbDeviceHandle::TransferRecipient* output) {
|
| + UsbControlTransferRecipient* output) {
|
| switch (input) {
|
| case usb::RECIPIENT_DEVICE:
|
| - *output = UsbDeviceHandle::DEVICE;
|
| + *output = UsbControlTransferRecipient::DEVICE;
|
| return true;
|
| case usb::RECIPIENT_INTERFACE:
|
| - *output = UsbDeviceHandle::INTERFACE;
|
| + *output = UsbControlTransferRecipient::INTERFACE;
|
| return true;
|
| case usb::RECIPIENT_ENDPOINT:
|
| - *output = UsbDeviceHandle::ENDPOINT;
|
| + *output = UsbControlTransferRecipient::ENDPOINT;
|
| return true;
|
| case usb::RECIPIENT_OTHER:
|
| - *output = UsbDeviceHandle::OTHER;
|
| + *output = UsbControlTransferRecipient::OTHER;
|
| return true;
|
| default:
|
| NOTREACHED();
|
| @@ -204,7 +206,7 @@ bool GetTransferSize(const T& input, size_t* output) {
|
| template <class T>
|
| scoped_refptr<net::IOBuffer> CreateBufferForTransfer(
|
| const T& input,
|
| - UsbEndpointDirection direction,
|
| + UsbTransferDirection direction,
|
| size_t size) {
|
| if (size >= kMaxTransferLength)
|
| return NULL;
|
| @@ -215,9 +217,9 @@ scoped_refptr<net::IOBuffer> CreateBufferForTransfer(
|
| scoped_refptr<net::IOBuffer> buffer =
|
| new net::IOBuffer(std::max(static_cast<size_t>(1), size));
|
|
|
| - if (direction == device::USB_DIRECTION_INBOUND) {
|
| + if (direction == UsbTransferDirection::INBOUND) {
|
| return buffer;
|
| - } else if (direction == device::USB_DIRECTION_OUTBOUND) {
|
| + } else if (direction == UsbTransferDirection::OUTBOUND) {
|
| if (input.data.get() && size <= input.data->size()) {
|
| memcpy(buffer->data(), input.data->data(), size);
|
| return buffer;
|
| @@ -229,21 +231,21 @@ scoped_refptr<net::IOBuffer> CreateBufferForTransfer(
|
|
|
| const char* ConvertTransferStatusToApi(const UsbTransferStatus status) {
|
| switch (status) {
|
| - case device::USB_TRANSFER_COMPLETED:
|
| + case UsbTransferStatus::COMPLETED:
|
| return "";
|
| - case device::USB_TRANSFER_ERROR:
|
| + case UsbTransferStatus::TRANSFER_ERROR:
|
| return kErrorGeneric;
|
| - case device::USB_TRANSFER_TIMEOUT:
|
| + case UsbTransferStatus::TIMEOUT:
|
| return kErrorTimeout;
|
| - case device::USB_TRANSFER_CANCELLED:
|
| + case UsbTransferStatus::CANCELLED:
|
| return kErrorCancelled;
|
| - case device::USB_TRANSFER_STALLED:
|
| + case UsbTransferStatus::STALLED:
|
| return kErrorStalled;
|
| - case device::USB_TRANSFER_DISCONNECT:
|
| + case UsbTransferStatus::DISCONNECT:
|
| return kErrorDisconnect;
|
| - case device::USB_TRANSFER_OVERFLOW:
|
| + case UsbTransferStatus::BABBLE:
|
| return kErrorOverflow;
|
| - case device::USB_TRANSFER_LENGTH_SHORT:
|
| + case UsbTransferStatus::SHORT_PACKET:
|
| return kErrorTransferLength;
|
| default:
|
| NOTREACHED();
|
| @@ -263,13 +265,13 @@ std::unique_ptr<base::Value> PopulateConnectionHandle(int handle,
|
|
|
| TransferType ConvertTransferTypeToApi(const UsbTransferType& input) {
|
| switch (input) {
|
| - case device::USB_TRANSFER_CONTROL:
|
| + case UsbTransferType::CONTROL:
|
| return usb::TRANSFER_TYPE_CONTROL;
|
| - case device::USB_TRANSFER_INTERRUPT:
|
| + case UsbTransferType::INTERRUPT:
|
| return usb::TRANSFER_TYPE_INTERRUPT;
|
| - case device::USB_TRANSFER_ISOCHRONOUS:
|
| + case UsbTransferType::ISOCHRONOUS:
|
| return usb::TRANSFER_TYPE_ISOCHRONOUS;
|
| - case device::USB_TRANSFER_BULK:
|
| + case UsbTransferType::BULK:
|
| return usb::TRANSFER_TYPE_BULK;
|
| default:
|
| NOTREACHED();
|
| @@ -277,11 +279,11 @@ TransferType ConvertTransferTypeToApi(const UsbTransferType& input) {
|
| }
|
| }
|
|
|
| -Direction ConvertDirectionToApi(const UsbEndpointDirection& input) {
|
| +Direction ConvertDirectionToApi(const UsbTransferDirection& input) {
|
| switch (input) {
|
| - case device::USB_DIRECTION_INBOUND:
|
| + case UsbTransferDirection::INBOUND:
|
| return usb::DIRECTION_IN;
|
| - case device::USB_DIRECTION_OUTBOUND:
|
| + case UsbTransferDirection::OUTBOUND:
|
| return usb::DIRECTION_OUT;
|
| default:
|
| NOTREACHED();
|
| @@ -463,7 +465,7 @@ void UsbTransferFunction::OnCompleted(UsbTransferStatus status,
|
| size_t length) {
|
| std::unique_ptr<base::DictionaryValue> transfer_info(
|
| new base::DictionaryValue());
|
| - transfer_info->SetInteger(kResultCodeKey, status);
|
| + transfer_info->SetInteger(kResultCodeKey, static_cast<int>(status));
|
|
|
| if (data) {
|
| transfer_info->Set(
|
| @@ -472,7 +474,7 @@ void UsbTransferFunction::OnCompleted(UsbTransferStatus status,
|
| transfer_info->Set(kDataKey, new base::Value(base::Value::Type::BINARY));
|
| }
|
|
|
| - if (status == device::USB_TRANSFER_COMPLETED) {
|
| + if (status == UsbTransferStatus::COMPLETED) {
|
| Respond(OneArgument(std::move(transfer_info)));
|
| } else {
|
| std::unique_ptr<base::ListValue> error_args(new base::ListValue());
|
| @@ -1016,9 +1018,9 @@ ExtensionFunction::ResponseAction UsbControlTransferFunction::Run() {
|
| }
|
|
|
| const ControlTransferInfo& transfer = parameters->transfer_info;
|
| - UsbEndpointDirection direction = device::USB_DIRECTION_INBOUND;
|
| - UsbDeviceHandle::TransferRequestType request_type;
|
| - UsbDeviceHandle::TransferRecipient recipient;
|
| + UsbTransferDirection direction = UsbTransferDirection::INBOUND;
|
| + UsbControlTransferType request_type;
|
| + UsbControlTransferRecipient recipient;
|
| size_t size = 0;
|
|
|
| if (!ConvertDirectionFromApi(transfer.direction, &direction)) {
|
| @@ -1073,7 +1075,7 @@ ExtensionFunction::ResponseAction UsbBulkTransferFunction::Run() {
|
| }
|
|
|
| const GenericTransferInfo& transfer = parameters->transfer_info;
|
| - UsbEndpointDirection direction = device::USB_DIRECTION_INBOUND;
|
| + UsbTransferDirection direction = UsbTransferDirection::INBOUND;
|
| size_t size = 0;
|
|
|
| if (!ConvertDirectionFromApi(transfer.direction, &direction)) {
|
| @@ -1119,7 +1121,7 @@ ExtensionFunction::ResponseAction UsbInterruptTransferFunction::Run() {
|
| }
|
|
|
| const GenericTransferInfo& transfer = parameters->transfer_info;
|
| - UsbEndpointDirection direction = device::USB_DIRECTION_INBOUND;
|
| + UsbTransferDirection direction = UsbTransferDirection::INBOUND;
|
| size_t size = 0;
|
|
|
| if (!ConvertDirectionFromApi(transfer.direction, &direction)) {
|
| @@ -1167,7 +1169,7 @@ ExtensionFunction::ResponseAction UsbIsochronousTransferFunction::Run() {
|
| const IsochronousTransferInfo& transfer = parameters->transfer_info;
|
| const GenericTransferInfo& generic_transfer = transfer.transfer_info;
|
| size_t size = 0;
|
| - UsbEndpointDirection direction = device::USB_DIRECTION_INBOUND;
|
| + UsbTransferDirection direction = UsbTransferDirection::INBOUND;
|
|
|
| if (!ConvertDirectionFromApi(generic_transfer.direction, &direction))
|
| return RespondNow(Error(kErrorConvertDirection));
|
| @@ -1193,7 +1195,7 @@ ExtensionFunction::ResponseAction UsbIsochronousTransferFunction::Run() {
|
| if (timeout < 0)
|
| return RespondNow(Error(kErrorInvalidTimeout));
|
|
|
| - if (direction == device::USB_DIRECTION_INBOUND) {
|
| + if (direction == UsbTransferDirection::INBOUND) {
|
| device_handle->IsochronousTransferIn(
|
| generic_transfer.endpoint, packet_lengths, timeout,
|
| base::Bind(&UsbIsochronousTransferFunction::OnCompleted, this));
|
| @@ -1221,12 +1223,12 @@ void UsbIsochronousTransferFunction::OnCompleted(
|
| std::vector<char> buffer;
|
| buffer.reserve(length);
|
|
|
| - UsbTransferStatus status = device::USB_TRANSFER_COMPLETED;
|
| + UsbTransferStatus status = UsbTransferStatus::COMPLETED;
|
| const char* data_ptr = data ? data->data() : nullptr;
|
| for (const auto& packet : packets) {
|
| // Capture the error status of the first unsuccessful packet.
|
| - if (status == device::USB_TRANSFER_COMPLETED &&
|
| - packet.status != device::USB_TRANSFER_COMPLETED) {
|
| + if (status == UsbTransferStatus::COMPLETED &&
|
| + packet.status != UsbTransferStatus::COMPLETED) {
|
| status = packet.status;
|
| }
|
|
|
| @@ -1239,9 +1241,9 @@ void UsbIsochronousTransferFunction::OnCompleted(
|
|
|
| std::unique_ptr<base::DictionaryValue> transfer_info(
|
| new base::DictionaryValue());
|
| - transfer_info->SetInteger(kResultCodeKey, status);
|
| + transfer_info->SetInteger(kResultCodeKey, static_cast<int>(status));
|
| transfer_info->Set(kDataKey, new base::Value(std::move(buffer)));
|
| - if (status == device::USB_TRANSFER_COMPLETED) {
|
| + if (status == UsbTransferStatus::COMPLETED) {
|
| Respond(OneArgument(std::move(transfer_info)));
|
| } else {
|
| std::unique_ptr<base::ListValue> error_args(new base::ListValue());
|
|
|