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.
5 #ifndef CHROME_BROWSER_USB_USB_CONTEXT_H_
6 #define CHROME_BROWSER_USB_USB_CONTEXT_H_
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 #include "content/public/browser/browser_thread.h"
14 struct libusb_context
;
16 typedef libusb_context
* PlatformUsbContext
;
18 // Ref-counted wrapper for libusb_context*.
19 // It also manages the life-cycle of UsbEventHandler.
20 // It is a blocking operation to delete UsbContext.
21 // Destructor must be called on FILE thread.
22 class UsbContext
: public base::RefCountedThreadSafe
<UsbContext
> {
24 PlatformUsbContext
context() const { return context_
; }
27 friend class UsbService
;
28 friend class base::RefCountedThreadSafe
<UsbContext
>;
30 explicit UsbContext(PlatformUsbContext context
);
31 virtual ~UsbContext();
34 class UsbEventHandler
;
35 PlatformUsbContext context_
;
36 UsbEventHandler
* event_handler_
;
37 base::ThreadChecker thread_checker_
;
39 DISALLOW_COPY_AND_ASSIGN(UsbContext
);
42 #endif // CHROME_BROWSER_USB_USB_CONTEXT_H_