| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_USB_USB_CONTEXT_H_ | 5 #ifndef CHROME_BROWSER_USB_USB_CONTEXT_H_ |
| 6 #define CHROME_BROWSER_USB_USB_CONTEXT_H_ | 6 #define CHROME_BROWSER_USB_USB_CONTEXT_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "base/threading/thread_checker.h" | 11 #include "base/threading/thread_checker.h" |
| 12 #include "content/public/browser/browser_thread.h" | 12 #include "content/public/browser/browser_thread.h" |
| 13 | 13 |
| 14 struct libusb_context; | 14 struct libusb_context; |
| 15 | 15 |
| 16 typedef libusb_context* PlatformUsbContext; | 16 typedef libusb_context* PlatformUsbContext; |
| 17 | 17 |
| 18 // Ref-counted wrapper for libusb_context*. | 18 // Ref-counted wrapper for libusb_context*. |
| 19 // It also manages the life-cycle of UsbEventHandler. | 19 // It also manages the life-cycle of UsbEventHandler. |
| 20 // It is a blocking operation to delete UsbContext. | 20 // It is a blocking operation to delete UsbContext. |
| 21 // Destructor must be called on FILE thread. | 21 // Destructor must be called on FILE thread. |
| 22 class UsbContext : public base::RefCountedThreadSafe<UsbContext> { | 22 class UsbContext : public base::RefCountedThreadSafe<UsbContext> { |
| 23 public: | 23 public: |
| 24 PlatformUsbContext context() const { return context_; } | 24 PlatformUsbContext context() const { return context_; } |
| 25 | 25 |
| 26 protected: | 26 protected: |
| 27 friend class UsbService; | 27 friend class UsbService; |
| 28 friend class base::RefCountedThreadSafe<UsbContext>; | 28 friend class base::RefCountedThreadSafe<UsbContext>; |
| 29 | 29 |
| 30 UsbContext(); | 30 explicit UsbContext(PlatformUsbContext context); |
| 31 virtual ~UsbContext(); | 31 virtual ~UsbContext(); |
| 32 | 32 |
| 33 private: | 33 private: |
| 34 class UsbEventHandler; | 34 class UsbEventHandler; |
| 35 PlatformUsbContext context_; | 35 PlatformUsbContext context_; |
| 36 UsbEventHandler* event_handler_; | 36 UsbEventHandler* event_handler_; |
| 37 base::ThreadChecker thread_checker_; | 37 base::ThreadChecker thread_checker_; |
| 38 | 38 |
| 39 DISALLOW_COPY_AND_ASSIGN(UsbContext); | 39 DISALLOW_COPY_AND_ASSIGN(UsbContext); |
| 40 }; | 40 }; |
| 41 | 41 |
| 42 #endif // CHROME_BROWSER_USB_USB_CONTEXT_H_ | 42 #endif // CHROME_BROWSER_USB_USB_CONTEXT_H_ |
| OLD | NEW |