Skip to content

Commit

Permalink
Defined pairing flow interface for host side.
Browse files Browse the repository at this point in the history
BUG=375191
TEST=none

Review URL: https://codereview.chromium.org/349153004

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@279434 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
dzhioev@chromium.org committed Jun 24, 2014
1 parent 6e227a8 commit 03c32fe
Show file tree
Hide file tree
Showing 3 changed files with 94 additions and 0 deletions.
2 changes: 2 additions & 0 deletions chromeos/chromeos.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,8 @@
'pairing/fake_controller_pairing_flow.h',
'pairing/controller_pairing_flow.cc',
'pairing/controller_pairing_flow.h',
'pairing/host_pairing_controller.cc',
'pairing/host_pairing_controller.h',
'process_proxy/process_output_watcher.cc',
'process_proxy/process_output_watcher.h',
'process_proxy/process_proxy.cc',
Expand Down
16 changes: 16 additions & 0 deletions chromeos/pairing/host_pairing_controller.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// 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.

#include "chromeos/pairing/host_pairing_controller.h"

namespace chromeos {

HostPairingController::HostPairingController() {}

HostPairingController::~HostPairingController() {}

HostPairingController::Observer::Observer() {}
HostPairingController::Observer::~Observer() {}

} // namespace chromeos
76 changes: 76 additions & 0 deletions chromeos/pairing/host_pairing_controller.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
// 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 CHROMEOS_PAIRING_HOST_PAIRING_CONTROLLER_H_
#define CHROMEOS_PAIRING_HOST_PAIRING_CONTROLLER_H_

#include <string>

#include "base/macros.h"
#include "chromeos/chromeos_export.h"

namespace chromeos {

class CHROMEOS_EXPORT HostPairingController {
public:
enum Stage {
STAGE_NONE,
STAGE_WAITING_FOR_CONTROLLER,
STAGE_WAITING_FOR_CODE_CONFIRMATION,
STAGE_UPDATING,
STAGE_WAITING_FOR_CONTROLLER_AFTER_UPDATE,
STAGE_WAITING_FOR_CREDENTIALS,
STAGE_ENROLLING,
STAGE_ENROLLMENT_ERROR,
STAGE_PAIRING_DONE,
STAGE_FINISHED
};

struct UpdateProgress {
// Number in [0, 1].
double progress;
};

class Observer {
public:
Observer();
virtual ~Observer();

// Called when pairing has moved on from one stage to another.
virtual void PairingStageChanged(Stage new_stage) = 0;

// Called periodically on |STAGE_UPDATING| stage. Current update progress
// is stored in |progress|.
virtual void UpdateAdvanced(const UpdateProgress& progress) = 0;

private:
DISALLOW_COPY_AND_ASSIGN(Observer);
};

HostPairingController();
virtual ~HostPairingController();

virtual void AddObserver(Observer* observer) = 0;
virtual void RemoveObserver(Observer* observer) = 0;

// Returns current stage of pairing process.
virtual Stage GetCurrentStage() = 0;

// Starts pairing process. Can be called only on |STAGE_NONE| stage.
virtual void StartPairing() = 0;

// Returns device name.
virtual std::string GetDeviceName() = 0;

// Returns 6-digit confirmation code. Can be called only on
// |STAGE_WAITING_FOR_CODE_CONFIRMATION| stage.
virtual std::string GetConfirmationCode() = 0;

private:
DISALLOW_COPY_AND_ASSIGN(HostPairingController);
};

} // namespace chromeos

#endif // CHROMEOS_PAIRING_HOST_PAIRING_CONTROLLER_H_

0 comments on commit 03c32fe

Please sign in to comment.