OLD | NEW |
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_controller_pairing_controller.h" | 5 #include "components/pairing/fake_controller_pairing_controller.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 } | 212 } |
213 | 213 |
214 void FakeControllerPairingController::OnAuthenticationDone( | 214 void FakeControllerPairingController::OnAuthenticationDone( |
215 const std::string& domain, | 215 const std::string& domain, |
216 const std::string& auth_token) { | 216 const std::string& auth_token) { |
217 CHECK(current_stage_ == STAGE_WAITING_FOR_CREDENTIALS); | 217 CHECK(current_stage_ == STAGE_WAITING_FOR_CREDENTIALS); |
218 ChangeStage(STAGE_HOST_ENROLLMENT_IN_PROGRESS); | 218 ChangeStage(STAGE_HOST_ENROLLMENT_IN_PROGRESS); |
219 } | 219 } |
220 | 220 |
221 void FakeControllerPairingController::StartSession() { | 221 void FakeControllerPairingController::StartSession() { |
222 CHECK(current_stage_ == STAGE_PAIRING_DONE); | 222 CHECK(current_stage_ == STAGE_HOST_ENROLLMENT_SUCCESS); |
223 ChangeStage(STAGE_FINISHED); | 223 ChangeStage(STAGE_FINISHED); |
224 } | 224 } |
225 | 225 |
226 void FakeControllerPairingController::ChangeStage(Stage new_stage) { | 226 void FakeControllerPairingController::ChangeStage(Stage new_stage) { |
227 if (current_stage_ == new_stage) | 227 if (current_stage_ == new_stage) |
228 return; | 228 return; |
229 current_stage_ = new_stage; | 229 current_stage_ = new_stage; |
230 FOR_EACH_OBSERVER(Observer, observers_, PairingStageChanged(new_stage)); | 230 FOR_EACH_OBSERVER(Observer, observers_, PairingStageChanged(new_stage)); |
231 } | 231 } |
232 | 232 |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
308 } | 308 } |
309 case STAGE_HOST_UPDATE_IN_PROGRESS: { | 309 case STAGE_HOST_UPDATE_IN_PROGRESS: { |
310 next_stage = STAGE_WAITING_FOR_CREDENTIALS; | 310 next_stage = STAGE_WAITING_FOR_CREDENTIALS; |
311 break; | 311 break; |
312 } | 312 } |
313 case STAGE_HOST_ENROLLMENT_IN_PROGRESS: { | 313 case STAGE_HOST_ENROLLMENT_IN_PROGRESS: { |
314 if (enrollment_should_fail_) { | 314 if (enrollment_should_fail_) { |
315 enrollment_should_fail_ = false; | 315 enrollment_should_fail_ = false; |
316 next_stage = STAGE_HOST_ENROLLMENT_ERROR; | 316 next_stage = STAGE_HOST_ENROLLMENT_ERROR; |
317 } else { | 317 } else { |
318 next_stage = STAGE_PAIRING_DONE; | 318 next_stage = STAGE_HOST_ENROLLMENT_SUCCESS; |
319 } | 319 } |
320 break; | 320 break; |
321 } | 321 } |
322 case STAGE_HOST_CONNECTION_LOST: { | 322 case STAGE_HOST_CONNECTION_LOST: { |
323 next_stage = connection_lost_end_; | 323 next_stage = connection_lost_end_; |
324 connection_lost_end_ = STAGE_NONE; | 324 connection_lost_end_ = STAGE_NONE; |
325 break; | 325 break; |
326 } | 326 } |
327 default: | 327 default: |
328 break; | 328 break; |
329 } | 329 } |
330 if (new_stage == connection_lost_begin_) { | 330 if (new_stage == connection_lost_begin_) { |
331 connection_lost_begin_ = STAGE_NONE; | 331 connection_lost_begin_ = STAGE_NONE; |
332 next_stage = STAGE_HOST_CONNECTION_LOST; | 332 next_stage = STAGE_HOST_CONNECTION_LOST; |
333 } | 333 } |
334 if (next_stage != STAGE_NONE) | 334 if (next_stage != STAGE_NONE) |
335 ChangeStageLater(next_stage); | 335 ChangeStageLater(next_stage); |
336 } | 336 } |
337 | 337 |
338 void FakeControllerPairingController::DiscoveredDevicesListChanged() { | 338 void FakeControllerPairingController::DiscoveredDevicesListChanged() { |
339 } | 339 } |
340 | 340 |
341 } // namespace pairing_chromeos | 341 } // namespace pairing_chromeos |
OLD | NEW |