diff options
4 files changed, 10 insertions, 21 deletions
diff --git a/chrome/browser/extensions/api/api_resource_event_notifier.cc b/chrome/browser/extensions/api/api_resource_event_notifier.cc index 20a5e20..a970dbc 100644 --- a/chrome/browser/extensions/api/api_resource_event_notifier.cc +++ b/chrome/browser/extensions/api/api_resource_event_notifier.cc @@ -82,7 +82,7 @@ void APIResourceEventNotifier::OnWriteComplete(int result_code) { } void APIResourceEventNotifier::OnTransferComplete(int result_code, - base::ListValue* data) { + base::BinaryValue* data) { if (src_id_ < 0) { delete data; return; diff --git a/chrome/browser/extensions/api/api_resource_event_notifier.h b/chrome/browser/extensions/api/api_resource_event_notifier.h index 09f4070..270ac84 100644 --- a/chrome/browser/extensions/api/api_resource_event_notifier.h +++ b/chrome/browser/extensions/api/api_resource_event_notifier.h @@ -60,7 +60,7 @@ class APIResourceEventNotifier virtual void OnWriteComplete(int result_code); - virtual void OnTransferComplete(int result_code, base::ListValue* data); + virtual void OnTransferComplete(int result_code, base::BinaryValue* data); static std::string APIResourceEventTypeToString( APIResourceEventType event_type); diff --git a/chrome/browser/extensions/api/usb/usb_device_resource.cc b/chrome/browser/extensions/api/usb/usb_device_resource.cc index f2046d4..f90ef5a 100644 --- a/chrome/browser/extensions/api/usb/usb_device_resource.cc +++ b/chrome/browser/extensions/api/usb/usb_device_resource.cc @@ -94,7 +94,7 @@ static bool GetTransferSize(const T& input, size_t* output) { } } else if (input.direction == kDirectionOut) { if (input.data.get()) { - *output = input.data->size(); + *output = input.data->GetSize(); return true; } } @@ -113,10 +113,7 @@ static scoped_refptr<net::IOBuffer> CreateBufferForTransfer(const T& input) { return buffer; } - const vector<int>& input_buffer = *input.data.get(); - for (size_t i = 0; i < size; ++i) { - buffer->data()[i] = input_buffer[i]; - } + memcpy(buffer->data(), input.data->GetBuffer(), size); return buffer; } @@ -209,11 +206,8 @@ void UsbDeviceResource::TransferComplete(net::IOBuffer* buffer, const size_t length, int success) { if (buffer) { - base::ListValue *const response_buffer = new base::ListValue(); - for (size_t i = 0; i < length; ++i) { - const uint8_t value = buffer->data()[i] & 0xFF; - response_buffer->Append(base::Value::CreateIntegerValue(value)); - } + base::BinaryValue* const response_buffer = + base::BinaryValue::CreateWithCopiedBuffer(buffer->data(), length); event_notifier()->OnTransferComplete(success, response_buffer); } } diff --git a/chrome/common/extensions/api/experimental_usb.idl b/chrome/common/extensions/api/experimental_usb.idl index 55affc3..f9fec95 100644 --- a/chrome/common/extensions/api/experimental_usb.idl +++ b/chrome/common/extensions/api/experimental_usb.idl @@ -3,8 +3,7 @@ // found in the LICENSE file. // TODO(gdk): The string-style enumerations are temporary, and will be removed -// once full enumeration support is added. Also, the array-of-longs are -// temporary and will be removed once there is full ArrayBuffer support. +// once full enumeration support is added. [nodoc] namespace experimental.usb { @@ -42,7 +41,7 @@ // The data payload carried by this transfer. If this is an output tranfer // then this field must be set. - long[]? data; + ArrayBuffer? data; }; // GenericTransferInfo is used by both bulk and interrupt transfers to @@ -59,7 +58,7 @@ // If this is an output transfer then this field must be populated. // Otherwise, it will be ignored. - long[]? data; + ArrayBuffer? data; }; // IsochronousTransferInfo describes a single multi-packet isochronous @@ -92,7 +91,7 @@ // If the transfer was an input transfer then this field will contain all // of the input data requested. - long[]? data; + ArrayBuffer? data; // The following fields are used for internal event routing and can be // ignored. @@ -103,10 +102,6 @@ callback OnEventCallback = void (UsbEvent event); dictionary DeviceOptions { - // The schema generator does not support dictionaries with only events. - // Ignore this field. - [nodoc] long? dummyValue; - // Invoked by the extension API whenever an event occurs for the device(s) // that this DeviceOptions is associated with. OnEventCallback? onEvent; |