blob: ca0bf10e2937bb206d82a81b544b484e5884a6ff [file] [log] [blame]
// 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.
#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 {
// 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;
// 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();
// 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