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

Unified Diff: components/pairing/bluetooth_host_pairing_controller.cc

Issue 575273002: Clean up protocol for Bluetooth Pairing. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Code review fixes 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 side-by-side diff with in-line comments
Download patch
Index: components/pairing/bluetooth_host_pairing_controller.cc
diff --git a/components/pairing/bluetooth_host_pairing_controller.cc b/components/pairing/bluetooth_host_pairing_controller.cc
index 3d62c3ace401f0eafd34b146eb00e1dc0c04e8c1..48bfb5b5a959e01fcbf8eaacb61061b71f02bfa2 100644
--- a/components/pairing/bluetooth_host_pairing_controller.cc
+++ b/components/pairing/bluetooth_host_pairing_controller.cc
@@ -5,6 +5,7 @@
#include "components/pairing/bluetooth_host_pairing_controller.h"
#include "base/bind.h"
+#include "base/hash.h"
#include "base/logging.h"
#include "base/strings/stringprintf.h"
#include "components/pairing/bluetooth_pairing_constants.h"
@@ -118,9 +119,9 @@ void BluetoothHostPairingController::OnGetAdapter(
}
void BluetoothHostPairingController::SetName() {
- // TODO(zork): Make the device name prettier. (http://crbug.com/405774)
- device_name_ = base::StringPrintf("%s%s", kDeviceNamePrefix,
- adapter_->GetAddress().c_str());
+ uint32 device_id = base::Hash(adapter_->GetAddress()) & 0xFFFF;
achuithb 2014/09/18 06:59:17 A comment would help here. I'm guessing you're mas
Zachary Kuznia 2014/09/18 23:48:17 Done.
+
+ device_name_ = base::StringPrintf("%s%04X", kDeviceNamePrefix, device_id);
adapter_->SetName(
device_name_,
@@ -232,14 +233,12 @@ void BluetoothHostPairingController::OnReceiveComplete(
void BluetoothHostPairingController::OnCreateServiceError(
const std::string& message) {
LOG(ERROR) << message;
- // TODO(zork): Add a stage for initialization error. (http://crbug.com/405744)
- ChangeStage(STAGE_NONE);
+ ChangeStage(STAGE_INITIALIZATION_ERROR);
}
void BluetoothHostPairingController::OnSetError() {
adapter_->RemovePairingDelegate(this);
- // TODO(zork): Add a stage for initialization error. (http://crbug.com/405744)
- ChangeStage(STAGE_NONE);
+ ChangeStage(STAGE_INITIALIZATION_ERROR);
}
void BluetoothHostPairingController::OnAcceptError(
@@ -267,7 +266,12 @@ void BluetoothHostPairingController::OnHostStatusMessage(
void BluetoothHostPairingController::OnConfigureHostMessage(
const pairing_api::ConfigureHost& message) {
- // TODO(zork): Add event to API to handle this case. (http://crbug.com/405744)
+ FOR_EACH_OBSERVER(Observer, observers_,
+ ConfigureHost(message.parameters().accepted_eula(),
+ message.parameters().lang(),
+ message.parameters().timezone(),
+ message.parameters().send_reports(),
+ message.parameters().keyboard_layout()));
}
void BluetoothHostPairingController::OnPairDevicesMessage(
@@ -337,9 +341,10 @@ void BluetoothHostPairingController::StartPairing() {
DCHECK_EQ(current_stage_, STAGE_NONE);
bool bluetooth_available =
device::BluetoothAdapterFactory::IsBluetoothAdapterAvailable();
- // TODO(zork): Add a stage for initialization error. (http://crbug.com/405744)
- if (!bluetooth_available)
+ if (!bluetooth_available) {
+ ChangeStage(STAGE_INITIALIZATION_ERROR);
return;
+ }
device::BluetoothAdapterFactory::GetAdapter(
base::Bind(&BluetoothHostPairingController::OnGetAdapter,

Powered by Google App Engine
This is Rietveld 408576698