-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathusb_modem_switch_context.h
72 lines (58 loc) · 2.66 KB
/
usb_modem_switch_context.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
61
62
63
64
65
66
67
68
69
70
71
72
// 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_SWITCH_CONTEXT_H_
#define MIST_USB_MODEM_SWITCH_CONTEXT_H_
#include <stdint.h>
#include <string>
#include <base/macros.h>
namespace mist {
class Context;
class UsbModemInfo;
// A USB modem switch context, which holds the information about the USB device
// to undergo a modem switch operation.
class UsbModemSwitchContext {
public:
UsbModemSwitchContext();
// Constructs a UsbModemSwitchContext object with the following information
// about the USB device to undergo a modem switch operation:
// |sysfs_path|: the sysfs path of the device
// |bus_number|: the number of the bus that the device is connected to
// |device_address|: the address of the device on the bus
// |vendor_id|: USB vendor ID of the device
// |product_id|: USB product ID of the device
// |modem_info|: a raw pointer to a UsbModemInfo object as that contains the
// information about how to switch the device to the modem
// mode. The ownership of |modem_info| is not transferred, and
// thus it should outlive this object.
UsbModemSwitchContext(const std::string& sys_path,
uint8_t bus_number,
uint8_t device_address,
uint16_t vendor_id,
uint16_t product_id,
const UsbModemInfo* modem_info);
UsbModemSwitchContext(const UsbModemSwitchContext&) = delete;
UsbModemSwitchContext& operator=(const UsbModemSwitchContext&) = delete;
~UsbModemSwitchContext() = default;
// Initializes this switch context object with the information obtained from
// the device on the sysfs path |sys_path|. This method uses the helper
// objects provided by |context|. Returns true if the device on |sys_path| is
// supported for modem switch operation.
bool InitializeFromSysPath(const Context* context,
const std::string& sys_path);
const std::string& sys_path() const { return sys_path_; }
uint8_t bus_number() const { return bus_number_; }
uint8_t device_address() const { return device_address_; }
uint16_t vendor_id() const { return vendor_id_; }
uint16_t product_id() const { return product_id_; }
const UsbModemInfo* modem_info() const { return modem_info_; }
private:
std::string sys_path_;
uint8_t bus_number_;
uint8_t device_address_;
uint16_t vendor_id_;
uint16_t product_id_;
const UsbModemInfo* modem_info_;
};
} // namespace mist
#endif // MIST_USB_MODEM_SWITCH_CONTEXT_H_