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

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 the threading mess Created 7 years, 5 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/extensions/api/api_resource_manager.h" 15 #include "chrome/browser/extensions/api/api_resource_manager.h"
16 #include "chrome/browser/usb/usb_device.h" 16 #include "chrome/browser/usb/usb_device_handle.h"
17 #include "chrome/common/extensions/api/usb.h" 17 #include "chrome/common/extensions/api/usb.h"
18 18
19 class UsbDevice; 19 class UsbDeviceHandle;
20 20
21 namespace net { 21 namespace net {
22 class IOBuffer; 22 class IOBuffer;
23 } // namespace net 23 } // namespace net
24 24
25 namespace extensions { 25 namespace extensions {
26 26
27 // A UsbDeviceResource is an ApiResource wrapper for a UsbDevice. 27 // A UsbDeviceResource is an ApiResource wrapper for a UsbDevice.
28 // It will redirect all the requests on the FILE thread.
28 class UsbDeviceResource : public ApiResource { 29 class UsbDeviceResource : public ApiResource {
29 public: 30 public:
30 UsbDeviceResource(const std::string& owner_extension_id, 31 UsbDeviceResource(const std::string& owner_extension_id,
31 scoped_refptr<UsbDevice> device); 32 scoped_refptr<UsbDeviceHandle> device);
32 virtual ~UsbDeviceResource(); 33 virtual ~UsbDeviceResource();
33 34
34 scoped_refptr<UsbDevice> device() { 35 virtual void Close(const base::Callback<void()>& callback);
35 return device_; 36
36 } 37 virtual void ListInterfaces(UsbConfigDescriptor* config,
38 const UsbInterfaceCallback& callback);
39
40 virtual void ClaimInterface(const int interface_number,
41 const UsbInterfaceCallback& callback);
42
43 virtual void ReleaseInterface(const int interface_number,
44 const UsbInterfaceCallback& callback);
45
46 virtual void SetInterfaceAlternateSetting(
47 const int interface_number, const int alternate_setting,
48 const UsbInterfaceCallback& callback);
49
50 virtual void ControlTransfer(
51 const UsbEndpointDirection direction,
52 const UsbDeviceHandle::TransferRequestType request_type,
53 const UsbDeviceHandle::TransferRecipient recipient, const uint8 request,
54 const uint16 value, const uint16 index, net::IOBuffer* buffer,
55 const size_t length, const unsigned int timeout,
56 const UsbTransferCallback& callback);
57
58 virtual void BulkTransfer(const UsbEndpointDirection direction,
59 const uint8 endpoint, net::IOBuffer* buffer,
60 const size_t length, const unsigned int timeout,
61 const UsbTransferCallback& callback);
62
63 virtual void InterruptTransfer(const UsbEndpointDirection direction,
64 const uint8 endpoint, net::IOBuffer* buffer,
65 const size_t length,
66 const unsigned int timeout,
67 const UsbTransferCallback& callback);
68
69 virtual void IsochronousTransfer(const UsbEndpointDirection direction,
70 const uint8 endpoint, net::IOBuffer* buffer,
71 const size_t length,
72 const unsigned int packets,
73 const unsigned int packet_length,
74 const unsigned int timeout,
75 const UsbTransferCallback& callback);
76
77 virtual void ResetDevice(const base::Callback<void(bool)>& callback);
37 78
38 private: 79 private:
39 friend class ApiResourceManager<UsbDeviceResource>; 80 friend class ApiResourceManager<UsbDeviceResource>;
40 static const char* service_name() { 81 static const char* service_name() {
41 return "UsbDeviceResourceManager"; 82 return "UsbDeviceResourceManager";
42 } 83 }
43 84
44 scoped_refptr<UsbDevice> device_; 85 scoped_refptr<UsbDeviceHandle> device_;
45 86
46 DISALLOW_COPY_AND_ASSIGN(UsbDeviceResource); 87 DISALLOW_COPY_AND_ASSIGN(UsbDeviceResource);
47 }; 88 };
48 89
49 } // namespace extensions 90 } // namespace extensions
50 91
51 #endif // CHROME_BROWSER_EXTENSIONS_API_USB_USB_DEVICE_RESOURCE_H_ 92 #endif // CHROME_BROWSER_EXTENSIONS_API_USB_USB_DEVICE_RESOURCE_H_
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/usb/usb_apitest.cc ('k') | chrome/browser/extensions/api/usb/usb_device_resource.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698