-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathusb_modem_switcher.h
60 lines (45 loc) · 1.97 KB
/
usb_modem_switcher.h
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// Copyright (c) 2013 The Chromium OS 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 MIST_USB_MODEM_SWITCHER_H_
#define MIST_USB_MODEM_SWITCHER_H_
#include <stdint.h>
#include <string>
#include <base/macros.h>
#include "mist/usb_device_event_observer.h"
namespace mist {
class Context;
class UsbModemSwitchOperation;
// A USB modem switcher, which initiates a modem switch operation for each
// supported USB device that currently exists on the system, or when a supported
// USB device is added to the system.
class UsbModemSwitcher : public UsbDeviceEventObserver {
public:
// Constructs a UsbModemSwitcher object by taking a raw pointer to a Context
// object as |context|. The ownership of |context| is not transferred, and
// thus it should outlive this object.
explicit UsbModemSwitcher(Context* context);
UsbModemSwitcher(const UsbModemSwitcher&) = delete;
UsbModemSwitcher& operator=(const UsbModemSwitcher&) = delete;
~UsbModemSwitcher();
// Starts scanning existing USB devices on the system and monitoring new USB
// devices being added to the system. Initiates a switch operation for each
// supported device.
void Start();
private:
// Invoked upon the completion of a switch operation where |success| indicates
// whether the operation completed successfully or not. |operation| is deleted
// in this callback.
void OnSwitchOperationCompleted(UsbModemSwitchOperation* operation,
bool success);
// Implements UsbDeviceEventObserver.
void OnUsbDeviceAdded(const std::string& sys_path,
uint8_t bus_number,
uint8_t device_address,
uint16_t vendor_id,
uint16_t product_id) override;
void OnUsbDeviceRemoved(const std::string& sys_path) override;
Context* const context_;
};
} // namespace mist
#endif // MIST_USB_MODEM_SWITCHER_H_