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

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

Issue 2901653002: Bootstrapping: Reboot on enrollment failure (Closed)
Patch Set: Fixed comments. Created 3 years, 7 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
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/bluetooth_controller_pairing_controller.h" 5 #include "components/pairing/bluetooth_controller_pairing_controller.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 if (connectivity == pairing_api::HostStatusParameters::CONNECTIVITY_NONE) { 389 if (connectivity == pairing_api::HostStatusParameters::CONNECTIVITY_NONE) {
390 ChangeStage(STAGE_HOST_NETWORK_ERROR); 390 ChangeStage(STAGE_HOST_NETWORK_ERROR);
391 } else if (enrollment_status == 391 } else if (enrollment_status ==
392 pairing_api::HostStatusParameters::ENROLLMENT_STATUS_SUCCESS) { 392 pairing_api::HostStatusParameters::ENROLLMENT_STATUS_SUCCESS) {
393 // TODO(achuith, zork): Need to ensure that controller has also successfully 393 // TODO(achuith, zork): Need to ensure that controller has also successfully
394 // enrolled. 394 // enrolled.
395 CompleteSetup(); 395 CompleteSetup();
396 } else if (enrollment_status == 396 } else if (enrollment_status ==
397 pairing_api::HostStatusParameters::ENROLLMENT_STATUS_FAILURE) { 397 pairing_api::HostStatusParameters::ENROLLMENT_STATUS_FAILURE) {
398 ChangeStage(STAGE_HOST_ENROLLMENT_ERROR); 398 ChangeStage(STAGE_HOST_ENROLLMENT_ERROR);
399 // Reboot the host if enrollment failed.
400 pairing_api::Reboot reboot;
401 reboot.set_api_version(kPairingAPIVersion);
402 int size = 0;
403 scoped_refptr<net::IOBuffer> io_buffer(
404 ProtoDecoder::SendRebootHost(reboot, &size));
405 SendBuffer(io_buffer, size);
399 } else if (update_status == 406 } else if (update_status ==
400 pairing_api::HostStatusParameters::UPDATE_STATUS_UPDATING) { 407 pairing_api::HostStatusParameters::UPDATE_STATUS_UPDATING) {
401 ChangeStage(STAGE_HOST_UPDATE_IN_PROGRESS); 408 ChangeStage(STAGE_HOST_UPDATE_IN_PROGRESS);
402 } else if (update_status == 409 } else if (update_status ==
403 pairing_api::HostStatusParameters::UPDATE_STATUS_UPDATED) { 410 pairing_api::HostStatusParameters::UPDATE_STATUS_UPDATED) {
404 ChangeStage(STAGE_WAITING_FOR_CREDENTIALS); 411 ChangeStage(STAGE_WAITING_FOR_CREDENTIALS);
405 } 412 }
406 } 413 }
407 414
408 void BluetoothControllerPairingController::CompleteSetup() { 415 void BluetoothControllerPairingController::CompleteSetup() {
(...skipping 30 matching lines...) Expand all
439 LOG(ERROR) << message.parameters().code() << ", " << 446 LOG(ERROR) << message.parameters().code() << ", " <<
440 message.parameters().description(); 447 message.parameters().description();
441 ChangeStage(STAGE_HOST_ENROLLMENT_ERROR); 448 ChangeStage(STAGE_HOST_ENROLLMENT_ERROR);
442 } 449 }
443 450
444 void BluetoothControllerPairingController::OnAddNetworkMessage( 451 void BluetoothControllerPairingController::OnAddNetworkMessage(
445 const pairing_api::AddNetwork& message) { 452 const pairing_api::AddNetwork& message) {
446 NOTREACHED(); 453 NOTREACHED();
447 } 454 }
448 455
456 void BluetoothControllerPairingController::OnRebootMessage(
457 const pairing_api::Reboot& message) {
458 NOTREACHED();
459 }
460
449 void BluetoothControllerPairingController::DeviceAdded( 461 void BluetoothControllerPairingController::DeviceAdded(
450 device::BluetoothAdapter* adapter, 462 device::BluetoothAdapter* adapter,
451 device::BluetoothDevice* device) { 463 device::BluetoothDevice* device) {
452 DCHECK_EQ(adapter, adapter_.get()); 464 DCHECK_EQ(adapter, adapter_.get());
453 DeviceFound(device); 465 DeviceFound(device);
454 } 466 }
455 467
456 void BluetoothControllerPairingController::DeviceRemoved( 468 void BluetoothControllerPairingController::DeviceRemoved(
457 device::BluetoothAdapter* adapter, 469 device::BluetoothAdapter* adapter,
458 device::BluetoothDevice* device) { 470 device::BluetoothDevice* device) {
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
500 ChangeStage(STAGE_WAITING_FOR_CODE_CONFIRMATION); 512 ChangeStage(STAGE_WAITING_FOR_CODE_CONFIRMATION);
501 } 513 }
502 514
503 void BluetoothControllerPairingController::AuthorizePairing( 515 void BluetoothControllerPairingController::AuthorizePairing(
504 device::BluetoothDevice* device) { 516 device::BluetoothDevice* device) {
505 // Disallow unknown device. 517 // Disallow unknown device.
506 device->RejectPairing(); 518 device->RejectPairing();
507 } 519 }
508 520
509 } // namespace pairing_chromeos 521 } // namespace pairing_chromeos
OLDNEW
« no previous file with comments | « components/pairing/bluetooth_controller_pairing_controller.h ('k') | components/pairing/bluetooth_host_pairing_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698