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