blob: 1d3e5123d9a9bf5531c331af380137fade48fd26 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef DEVICE_USB_USB_CONTEXT_H_
#define DEVICE_USB_USB_CONTEXT_H_
#include "base/macros.h"
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
#include "base/threading/thread_checker.h"
struct libusb_context;
namespace device {
typedef libusb_context* PlatformUsbContext;
// Ref-counted wrapper for libusb_context*.
// It also manages the life-cycle of UsbEventHandler.
// It is a blocking operation to delete UsbContext.
// Destructor must be called on FILE thread.
class UsbContext : public base::RefCountedThreadSafe<UsbContext> {
public:
PlatformUsbContext context() const { return context_; }
protected:
friend class UsbServiceImpl;
friend class base::RefCountedThreadSafe<UsbContext>;
explicit UsbContext(PlatformUsbContext context);
virtual ~UsbContext();
private:
class UsbEventHandler;
PlatformUsbContext context_;
scoped_ptr<UsbEventHandler> event_handler_;
base::ThreadChecker thread_checker_;
DISALLOW_COPY_AND_ASSIGN(UsbContext);
};
} // namespace device
#endif // DEVICE_USB_USB_CONTEXT_H_
|