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

Side by Side Diff: chrome/browser/extensions/api/usb/usb_device_resource.h

Issue 16316004: Separate usb device handle from usb device. (deprecate) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix build Created 7 years, 6 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 | Annotate | Revision Log
OLDNEW
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 #ifndef CHROME_BROWSER_EXTENSIONS_API_USB_USB_DEVICE_RESOURCE_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_USB_USB_DEVICE_RESOURCE_H_
6 #define CHROME_BROWSER_EXTENSIONS_API_USB_USB_DEVICE_RESOURCE_H_ 6 #define CHROME_BROWSER_EXTENSIONS_API_USB_USB_DEVICE_RESOURCE_H_
7 7
8 #include <set> 8 #include <set>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/memory/linked_ptr.h" 11 #include "base/memory/linked_ptr.h"
12 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
13 #include "base/synchronization/lock.h" 13 #include "base/synchronization/lock.h"
14 #include "chrome/browser/extensions/api/api_resource.h" 14 #include "chrome/browser/extensions/api/api_resource.h"
15 #include "chrome/browser/usb/usb_device.h" 15 #include "chrome/browser/usb/usb_device_handle.h"
16 #include "chrome/common/extensions/api/usb.h" 16 #include "chrome/common/extensions/api/usb.h"
17 17
18 class UsbDevice; 18 class UsbDeviceHandle;
19 19
20 namespace net { 20 namespace net {
21 class IOBuffer; 21 class IOBuffer;
22 } // namespace net 22 } // namespace net
23 23
24 namespace extensions { 24 namespace extensions {
25 25
26 // A UsbDeviceResource is an ApiResource wrapper for a UsbDevice. 26 // A UsbDeviceResource is an ApiResource wrapper for a UsbDevice.
27 // It will redirect all the requests on the FILE thread.
27 class UsbDeviceResource : public ApiResource { 28 class UsbDeviceResource : public ApiResource {
28 public: 29 public:
29 UsbDeviceResource(const std::string& owner_extension_id, 30 UsbDeviceResource(const std::string& owner_extension_id,
30 scoped_refptr<UsbDevice> device); 31 scoped_refptr<UsbDeviceHandle> device);
31 virtual ~UsbDeviceResource(); 32 virtual ~UsbDeviceResource();
32 33
33 scoped_refptr<UsbDevice> device() { 34 virtual void Close(const base::Callback<void()>& callback);
34 return device_; 35
35 } 36 virtual void ListInterfaces(UsbConfigDescriptor* config,
37 const UsbInterfaceCallback& callback);
38
39 virtual void ClaimInterface(const int interface_number,
40 const UsbInterfaceCallback& callback);
41
42 virtual void ReleaseInterface(const int interface_number,
43 const UsbInterfaceCallback& callback);
44
45 virtual void SetInterfaceAlternateSetting(
46 const int interface_number, const int alternate_setting,
47 const UsbInterfaceCallback& callback);
48
49 virtual void ControlTransfer(
50 const UsbEndpointDirection direction,
51 const UsbDeviceHandle::TransferRequestType request_type,
52 const UsbDeviceHandle::TransferRecipient recipient, const uint8 request,
53 const uint16 value, const uint16 index, net::IOBuffer* buffer,
54 const size_t length, const unsigned int timeout,
55 const UsbTransferCallback& callback);
56
57 virtual void BulkTransfer(const UsbEndpointDirection direction,
58 const uint8 endpoint, net::IOBuffer* buffer,
59 const size_t length, const unsigned int timeout,
60 const UsbTransferCallback& callback);
61
62 virtual void InterruptTransfer(const UsbEndpointDirection direction,
63 const uint8 endpoint, net::IOBuffer* buffer,
64 const size_t length,
65 const unsigned int timeout,
66 const UsbTransferCallback& callback);
67
68 virtual void IsochronousTransfer(const UsbEndpointDirection direction,
69 const uint8 endpoint, net::IOBuffer* buffer,
70 const size_t length,
71 const unsigned int packets,
72 const unsigned int packet_length,
73 const unsigned int timeout,
74 const UsbTransferCallback& callback);
75
76 virtual void ResetDevice(const base::Callback<void(bool)>& callback);
36 77
37 private: 78 private:
38 scoped_refptr<UsbDevice> device_; 79 scoped_refptr<UsbDeviceHandle> device_;
39 80
40 DISALLOW_COPY_AND_ASSIGN(UsbDeviceResource); 81 DISALLOW_COPY_AND_ASSIGN(UsbDeviceResource);
41 }; 82 };
42 83
43 } // namespace extensions 84 } // namespace extensions
44 85
45 #endif // CHROME_BROWSER_EXTENSIONS_API_USB_USB_DEVICE_RESOURCE_H_ 86 #endif // CHROME_BROWSER_EXTENSIONS_API_USB_USB_DEVICE_RESOURCE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698