Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(10)

Side by Side Diff: components/pairing/fake_host_pairing_controller.cc

Issue 491943004: Update the pairing API to include configuration and enrollment. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix compile error Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/pairing/fake_host_pairing_controller.h" 5 #include "components/pairing/fake_host_pairing_controller.h"
6 6
7 #include <map> 7 #include <map>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/message_loop/message_loop.h" 12 #include "base/message_loop/message_loop.h"
13 #include "base/rand_util.h" 13 #include "base/rand_util.h"
14 #include "base/strings/string_number_conversions.h" 14 #include "base/strings/string_number_conversions.h"
15 #include "base/strings/string_split.h" 15 #include "base/strings/string_split.h"
16 16
17 namespace { 17 namespace {
18 18
19 const int kUpdateStepsNumber = 10;
20 const int kDefaultAsyncDurationMs = 3000; 19 const int kDefaultAsyncDurationMs = 3000;
21 const size_t kCodeLength = 6; 20 const size_t kCodeLength = 6;
22 21
23 } // namespace 22 } // namespace
24 23
25 namespace pairing_chromeos { 24 namespace pairing_chromeos {
26 25
27 FakeHostPairingController::FakeHostPairingController(const std::string& config) 26 FakeHostPairingController::FakeHostPairingController(const std::string& config)
28 : current_stage_(STAGE_NONE), 27 : current_stage_(STAGE_NONE),
29 enrollment_should_fail_(false), 28 enrollment_should_fail_(false),
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 83
85 void FakeHostPairingController::ChangeStageLater(Stage new_stage) { 84 void FakeHostPairingController::ChangeStageLater(Stage new_stage) {
86 base::MessageLoop::current()->PostDelayedTask( 85 base::MessageLoop::current()->PostDelayedTask(
87 FROM_HERE, 86 FROM_HERE,
88 base::Bind(&FakeHostPairingController::ChangeStage, 87 base::Bind(&FakeHostPairingController::ChangeStage,
89 base::Unretained(this), 88 base::Unretained(this),
90 new_stage), 89 new_stage),
91 async_duration_); 90 async_duration_);
92 } 91 }
93 92
94 void FakeHostPairingController::SetUpdateProgress(int step) {
95 UpdateProgress progress;
96 progress.progress = double(step) / kUpdateStepsNumber;
97 FOR_EACH_OBSERVER(Observer, observers_, UpdateAdvanced(progress));
98 base::Closure task;
99 if (step >= kUpdateStepsNumber) {
100 task = base::Bind(&FakeHostPairingController::ChangeStage,
101 base::Unretained(this),
102 STAGE_WAITING_FOR_CONTROLLER_AFTER_UPDATE);
103 } else {
104 task = base::Bind(&FakeHostPairingController::SetUpdateProgress,
105 base::Unretained(this),
106 step + 1);
107 }
108 base::MessageLoop::current()->PostDelayedTask(
109 FROM_HERE, task, async_duration_ / kUpdateStepsNumber);
110 }
111
112 void FakeHostPairingController::AddObserver(Observer* observer) { 93 void FakeHostPairingController::AddObserver(Observer* observer) {
113 observers_.AddObserver(observer); 94 observers_.AddObserver(observer);
114 } 95 }
115 96
116 void FakeHostPairingController::RemoveObserver(Observer* observer) { 97 void FakeHostPairingController::RemoveObserver(Observer* observer) {
117 observers_.RemoveObserver(observer); 98 observers_.RemoveObserver(observer);
118 } 99 }
119 100
120 HostPairingController::Stage FakeHostPairingController::GetCurrentStage() { 101 HostPairingController::Stage FakeHostPairingController::GetCurrentStage() {
121 return current_stage_; 102 return current_stage_;
(...skipping 14 matching lines...) Expand all
136 117
137 std::string FakeHostPairingController::GetConfirmationCode() { 118 std::string FakeHostPairingController::GetConfirmationCode() {
138 CHECK(current_stage_ == STAGE_WAITING_FOR_CODE_CONFIRMATION); 119 CHECK(current_stage_ == STAGE_WAITING_FOR_CODE_CONFIRMATION);
139 return confirmation_code_; 120 return confirmation_code_;
140 } 121 }
141 122
142 std::string FakeHostPairingController::GetEnrollmentDomain() { 123 std::string FakeHostPairingController::GetEnrollmentDomain() {
143 return enrollment_domain_; 124 return enrollment_domain_;
144 } 125 }
145 126
127 void FakeHostPairingController::OnUpdateStatusChanged(
128 UpdateStatus update_status) {
129 }
130
146 void FakeHostPairingController::PairingStageChanged(Stage new_stage) { 131 void FakeHostPairingController::PairingStageChanged(Stage new_stage) {
147 switch (new_stage) { 132 switch (new_stage) {
148 case STAGE_WAITING_FOR_CONTROLLER: { 133 case STAGE_WAITING_FOR_CONTROLLER: {
149 ChangeStageLater(STAGE_WAITING_FOR_CODE_CONFIRMATION); 134 ChangeStageLater(STAGE_WAITING_FOR_CODE_CONFIRMATION);
150 break; 135 break;
151 } 136 }
152 case STAGE_WAITING_FOR_CODE_CONFIRMATION: { 137 case STAGE_WAITING_FOR_CODE_CONFIRMATION: {
153 ChangeStageLater(STAGE_UPDATING); 138 ChangeStageLater(STAGE_UPDATING);
154 break; 139 break;
155 } 140 }
156 case STAGE_UPDATING: { 141 case STAGE_UPDATING: {
157 SetUpdateProgress(0); 142 ChangeStageLater(STAGE_WAITING_FOR_CONTROLLER_AFTER_UPDATE);
158 break; 143 break;
159 } 144 }
160 case STAGE_WAITING_FOR_CONTROLLER_AFTER_UPDATE: { 145 case STAGE_WAITING_FOR_CONTROLLER_AFTER_UPDATE: {
161 ChangeStageLater(STAGE_WAITING_FOR_CREDENTIALS); 146 ChangeStageLater(STAGE_WAITING_FOR_CREDENTIALS);
162 break; 147 break;
163 } 148 }
164 case STAGE_WAITING_FOR_CREDENTIALS: { 149 case STAGE_WAITING_FOR_CREDENTIALS: {
165 ChangeStageLater(STAGE_ENROLLING); 150 ChangeStageLater(STAGE_ENROLLING);
166 break; 151 break;
167 } 152 }
(...skipping 11 matching lines...) Expand all
179 break; 164 break;
180 } 165 }
181 case STAGE_PAIRING_DONE: { 166 case STAGE_PAIRING_DONE: {
182 ChangeStageLater(STAGE_FINISHED); 167 ChangeStageLater(STAGE_FINISHED);
183 break; 168 break;
184 } 169 }
185 default: { break; } 170 default: { break; }
186 } 171 }
187 } 172 }
188 173
189 void FakeHostPairingController::UpdateAdvanced(const UpdateProgress& progress) { 174 void FakeHostPairingController::ConfigureHost(
175 bool accepted_eula,
176 const std::string& lang,
177 const std::string& timezone,
178 bool send_reports,
179 const std::string& keyboard_layout) {
180 }
181
182 void FakeHostPairingController::EnrollHost(const std::string& auth_token) {
190 } 183 }
191 184
192 } // namespace pairing_chromeos 185 } // namespace pairing_chromeos
OLDNEW
« no previous file with comments | « components/pairing/fake_host_pairing_controller.h ('k') | components/pairing/host_pairing_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698