| 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 #ifndef EXTENSIONS_BROWSER_API_USB_USB_DEVICE_RESOURCE_H_ | 5 #ifndef EXTENSIONS_BROWSER_API_USB_USB_DEVICE_RESOURCE_H_ |
| 6 #define EXTENSIONS_BROWSER_API_USB_USB_DEVICE_RESOURCE_H_ | 6 #define EXTENSIONS_BROWSER_API_USB_USB_DEVICE_RESOURCE_H_ |
| 7 | 7 |
| 8 #include <set> | |
| 9 #include <string> | 8 #include <string> |
| 10 | 9 |
| 11 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 12 #include "base/memory/linked_ptr.h" | |
| 13 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
| 14 #include "base/synchronization/lock.h" | 12 #include "base/synchronization/lock.h" |
| 15 #include "content/public/browser/browser_thread.h" | 13 #include "content/public/browser/browser_thread.h" |
| 16 #include "device/usb/usb_device_handle.h" | 14 #include "device/usb/usb_device_handle.h" |
| 17 #include "extensions/browser/api/api_resource.h" | 15 #include "extensions/browser/api/api_resource.h" |
| 18 #include "extensions/browser/api/api_resource_manager.h" | 16 #include "extensions/browser/api/api_resource_manager.h" |
| 19 #include "extensions/common/api/usb.h" | |
| 20 | 17 |
| 21 namespace net { | 18 namespace usb_service { |
| 22 class IOBuffer; | 19 class UsbDeviceHandle; |
| 23 } // namespace net | 20 } |
| 24 | 21 |
| 25 namespace extensions { | 22 namespace extensions { |
| 26 | 23 |
| 27 // A UsbDeviceResource is an ApiResource wrapper for a UsbDevice. | 24 // A UsbDeviceResource is an ApiResource wrapper for a UsbDevice. |
| 28 class UsbDeviceResource : public ApiResource { | 25 class UsbDeviceResource : public ApiResource { |
| 29 public: | 26 public: |
| 27 static const content::BrowserThread::ID kThreadId = |
| 28 content::BrowserThread::FILE; |
| 29 |
| 30 UsbDeviceResource(const std::string& owner_extension_id, | 30 UsbDeviceResource(const std::string& owner_extension_id, |
| 31 scoped_refptr<device::UsbDeviceHandle> device); | 31 scoped_refptr<device::UsbDeviceHandle> device); |
| 32 virtual ~UsbDeviceResource(); | 32 virtual ~UsbDeviceResource(); |
| 33 | 33 |
| 34 scoped_refptr<device::UsbDeviceHandle> device() { return device_; } | 34 scoped_refptr<device::UsbDeviceHandle> device() { return device_; } |
| 35 | 35 |
| 36 static const content::BrowserThread::ID kThreadId = | 36 virtual bool IsPersistent() const OVERRIDE; |
| 37 content::BrowserThread::FILE; | |
| 38 | 37 |
| 39 private: | 38 private: |
| 40 friend class ApiResourceManager<UsbDeviceResource>; | 39 friend class ApiResourceManager<UsbDeviceResource>; |
| 41 static const char* service_name() { return "UsbDeviceResourceManager"; } | 40 static const char* service_name() { return "UsbDeviceResourceManager"; } |
| 42 | 41 |
| 43 scoped_refptr<device::UsbDeviceHandle> device_; | 42 scoped_refptr<device::UsbDeviceHandle> device_; |
| 44 | 43 |
| 45 DISALLOW_COPY_AND_ASSIGN(UsbDeviceResource); | 44 DISALLOW_COPY_AND_ASSIGN(UsbDeviceResource); |
| 46 }; | 45 }; |
| 47 | 46 |
| 48 } // namespace extensions | 47 } // namespace extensions |
| 49 | 48 |
| 50 #endif // EXTENSIONS_BROWSER_API_USB_USB_DEVICE_RESOURCE_H_ | 49 #endif // EXTENSIONS_BROWSER_API_USB_USB_DEVICE_RESOURCE_H_ |
| OLD | NEW |