blob: a4a8e48392ae52be0a657c772f235cfddff67be9 [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 <memory>
#include <base/macros.h>
namespace mist {
class Context;
class UsbModemSwitchContext;
class UsbModemSwitchOperation;
// A USB modem one-shot switcher, which initiates a modem switch operation for
// a device specified by a UsbModemSwitchContext object. Upon the completion of
// the operation, the message loop is signaled to terminate.
class UsbModemOneShotSwitcher {
// Constructs a UsbModemOneShotSwitcher object by taking a raw pointer to a
// Context object as |context|. The ownership of |context| is not transferred,
// and thus they should outlive this object.
explicit UsbModemOneShotSwitcher(Context* context);
UsbModemOneShotSwitcher(const UsbModemOneShotSwitcher&) = delete;
UsbModemOneShotSwitcher& operator=(const UsbModemOneShotSwitcher&) = delete;
// Initiates a modem switch operation for the device specified by the
// UsbModemSwitchContext object |switch_context|. Upon the completion of the
// operation, OnSwitchOperationCompleted() is invoked with the status of the
// operation. The ownership of |switch_context| is transferred.
void Start(UsbModemSwitchContext* switch_context);
bool is_success() const { return is_success_; }
// 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);
Context* const context_;
std::unique_ptr<UsbModemSwitchOperation> operation_;
bool is_success_;
} // namespace mist