Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / usb / usb_context.h
blob934319d034ab5ae374119ec3a3b0c2279faeb5c2
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> {
23 public:
24 PlatformUsbContext context() const { return context_; }
26 protected:
27 friend class UsbService;
28 friend class base::RefCountedThreadSafe<UsbContext>;
30 explicit UsbContext(PlatformUsbContext context);
31 virtual ~UsbContext();
33 private:
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_