| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "device/bluetooth/bluetooth_device.h" | 5 #include "device/bluetooth/bluetooth_device.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 const char separator = canonicalized[2]; | 234 const char separator = canonicalized[2]; |
| 235 for (size_t i = 0; i < canonicalized.size(); ++i) { | 235 for (size_t i = 0; i < canonicalized.size(); ++i) { |
| 236 bool is_separator = (i + 1) % 3 == 0; | 236 bool is_separator = (i + 1) % 3 == 0; |
| 237 if (is_separator) { | 237 if (is_separator) { |
| 238 // All separators in the input |address| should be consistent. | 238 // All separators in the input |address| should be consistent. |
| 239 if (canonicalized[i] != separator) | 239 if (canonicalized[i] != separator) |
| 240 return std::string(); | 240 return std::string(); |
| 241 | 241 |
| 242 canonicalized[i] = ':'; | 242 canonicalized[i] = ':'; |
| 243 } else { | 243 } else { |
| 244 if (!IsHexDigit(canonicalized[i])) | 244 if (!base::IsHexDigit(canonicalized[i])) |
| 245 return std::string(); | 245 return std::string(); |
| 246 | 246 |
| 247 canonicalized[i] = base::ToUpperASCII(canonicalized[i]); | 247 canonicalized[i] = base::ToUpperASCII(canonicalized[i]); |
| 248 } | 248 } |
| 249 } | 249 } |
| 250 | 250 |
| 251 return canonicalized; | 251 return canonicalized; |
| 252 } | 252 } |
| 253 | 253 |
| 254 std::string BluetoothDevice::GetIdentifier() const { return GetAddress(); } | 254 std::string BluetoothDevice::GetIdentifier() const { return GetAddress(); } |
| (...skipping 19 matching lines...) Expand all Loading... |
| 274 | 274 |
| 275 void BluetoothDevice::ClearServiceData() { services_data_->Clear(); } | 275 void BluetoothDevice::ClearServiceData() { services_data_->Clear(); } |
| 276 | 276 |
| 277 void BluetoothDevice::SetServiceData(BluetoothUUID serviceUUID, | 277 void BluetoothDevice::SetServiceData(BluetoothUUID serviceUUID, |
| 278 const char* buffer, size_t size) { | 278 const char* buffer, size_t size) { |
| 279 services_data_->Set(serviceUUID.value(), | 279 services_data_->Set(serviceUUID.value(), |
| 280 base::BinaryValue::CreateWithCopiedBuffer(buffer, size)); | 280 base::BinaryValue::CreateWithCopiedBuffer(buffer, size)); |
| 281 } | 281 } |
| 282 | 282 |
| 283 } // namespace device | 283 } // namespace device |
| OLD | NEW |