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 "extensions/browser/api/usb/usb_api.h" | 5 #include "extensions/browser/api/usb/usb_api.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 922 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
933 EXTENSION_FUNCTION_VALIDATE(parameters_.get()); | 933 EXTENSION_FUNCTION_VALIDATE(parameters_.get()); |
934 return true; | 934 return true; |
935 } | 935 } |
936 | 936 |
937 void UsbCloseDeviceFunction::AsyncWorkStart() { | 937 void UsbCloseDeviceFunction::AsyncWorkStart() { |
938 scoped_refptr<UsbDeviceHandle> device_handle = | 938 scoped_refptr<UsbDeviceHandle> device_handle = |
939 GetDeviceHandleOrCompleteWithError(parameters_->handle); | 939 GetDeviceHandleOrCompleteWithError(parameters_->handle); |
940 if (!device_handle.get()) | 940 if (!device_handle.get()) |
941 return; | 941 return; |
942 | 942 |
943 device_handle->Close(); | 943 // The device handle is closed when the resource is destroyed. |
944 RemoveUsbDeviceResource(parameters_->handle.handle); | 944 RemoveUsbDeviceResource(parameters_->handle.handle); |
945 AsyncWorkCompleted(); | 945 AsyncWorkCompleted(); |
946 } | 946 } |
947 | 947 |
948 UsbClaimInterfaceFunction::UsbClaimInterfaceFunction() { | 948 UsbClaimInterfaceFunction::UsbClaimInterfaceFunction() { |
949 } | 949 } |
950 | 950 |
951 UsbClaimInterfaceFunction::~UsbClaimInterfaceFunction() { | 951 UsbClaimInterfaceFunction::~UsbClaimInterfaceFunction() { |
952 } | 952 } |
953 | 953 |
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1269 SetResult(new base::FundamentalValue(false)); | 1269 SetResult(new base::FundamentalValue(false)); |
1270 CompleteWithError(kErrorResetDevice); | 1270 CompleteWithError(kErrorResetDevice); |
1271 return; | 1271 return; |
1272 } | 1272 } |
1273 | 1273 |
1274 SetResult(new base::FundamentalValue(true)); | 1274 SetResult(new base::FundamentalValue(true)); |
1275 AsyncWorkCompleted(); | 1275 AsyncWorkCompleted(); |
1276 } | 1276 } |
1277 | 1277 |
1278 } // namespace extensions | 1278 } // namespace extensions |
OLD | NEW |