OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/extensions/api/usb/usb_device_resource.h" | 5 #include "chrome/browser/extensions/api/usb/usb_device_resource.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 } | 150 } |
151 | 151 |
152 } // namespace | 152 } // namespace |
153 | 153 |
154 namespace extensions { | 154 namespace extensions { |
155 | 155 |
156 UsbDeviceResource::UsbDeviceResource(ApiResourceEventNotifier* notifier, | 156 UsbDeviceResource::UsbDeviceResource(ApiResourceEventNotifier* notifier, |
157 UsbDevice* device) | 157 UsbDevice* device) |
158 : ApiResource(notifier), device_(device) {} | 158 : ApiResource(notifier), device_(device) {} |
159 | 159 |
160 UsbDeviceResource::~UsbDeviceResource() {} | 160 UsbDeviceResource::~UsbDeviceResource() { |
| 161 Close(); |
| 162 } |
| 163 |
| 164 void UsbDeviceResource::Close() { |
| 165 device_->Close(); |
| 166 } |
161 | 167 |
162 void UsbDeviceResource::ControlTransfer(const ControlTransferInfo& transfer) { | 168 void UsbDeviceResource::ControlTransfer(const ControlTransferInfo& transfer) { |
163 UsbDevice::TransferDirection direction; | 169 UsbDevice::TransferDirection direction; |
164 UsbDevice::TransferRequestType request_type; | 170 UsbDevice::TransferRequestType request_type; |
165 UsbDevice::TransferRecipient recipient; | 171 UsbDevice::TransferRecipient recipient; |
166 size_t size; | 172 size_t size; |
167 scoped_refptr<net::IOBuffer> buffer = CreateBufferForTransfer(transfer); | 173 scoped_refptr<net::IOBuffer> buffer = CreateBufferForTransfer(transfer); |
168 | 174 |
169 if (!ConvertDirection(transfer.direction, &direction) || | 175 if (!ConvertDirection(transfer.direction, &direction) || |
170 !ConvertRequestType(transfer.request_type, &request_type) || | 176 !ConvertRequestType(transfer.request_type, &request_type) || |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 UsbTransferStatus status) { | 244 UsbTransferStatus status) { |
239 if (buffer) { | 245 if (buffer) { |
240 base::BinaryValue* const response_buffer = | 246 base::BinaryValue* const response_buffer = |
241 base::BinaryValue::CreateWithCopiedBuffer(buffer->data(), length); | 247 base::BinaryValue::CreateWithCopiedBuffer(buffer->data(), length); |
242 event_notifier()->OnTransferComplete(status, | 248 event_notifier()->OnTransferComplete(status, |
243 ConvertTransferStatusToErrorString(status), response_buffer); | 249 ConvertTransferStatusToErrorString(status), response_buffer); |
244 } | 250 } |
245 } | 251 } |
246 | 252 |
247 } // namespace extensions | 253 } // namespace extensions |
OLD | NEW |