Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "chromeos/components/tether/ble_scanner.h" | 5 #include "chromeos/components/tether/ble_scanner.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
| 9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
| 10 #include "chromeos/components/tether/ble_constants.h" | 10 #include "chromeos/components/tether/ble_constants.h" |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 221 if (!service_data || service_data->size() < kMinNumBytesInServiceData) { | 221 if (!service_data || service_data->size() < kMinNumBytesInServiceData) { |
| 222 // If there is no service data or the service data is of insufficient | 222 // If there is no service data or the service data is of insufficient |
| 223 // length, there is not enough information to create a connection. | 223 // length, there is not enough information to create a connection. |
| 224 return; | 224 return; |
| 225 } | 225 } |
| 226 | 226 |
| 227 // Convert the service data from a std::vector<uint8_t> to a std::string. | 227 // Convert the service data from a std::vector<uint8_t> to a std::string. |
| 228 std::string service_data_str; | 228 std::string service_data_str; |
| 229 char* string_contents_ptr = | 229 char* string_contents_ptr = |
| 230 base::WriteInto(&service_data_str, service_data->size() + 1); | 230 base::WriteInto(&service_data_str, service_data->size() + 1); |
| 231 memcpy(string_contents_ptr, service_data->data(), service_data->size() + 1); | 231 memcpy(string_contents_ptr, service_data->data(), service_data->size()); |
| 232 string_contents_ptr[service_data->size()] = '\0'; | |
|
Lei Zhang
2017/06/16 22:57:37
Do you actually need to NUL-terminate the raw stri
Kyle Horimoto
2017/06/16 23:05:04
I checked, and you don't. Removed.
| |
| 232 | 233 |
| 233 CheckForMatchingScanFilters(bluetooth_device, service_data_str); | 234 CheckForMatchingScanFilters(bluetooth_device, service_data_str); |
| 234 } | 235 } |
| 235 | 236 |
| 236 void BleScanner::CheckForMatchingScanFilters( | 237 void BleScanner::CheckForMatchingScanFilters( |
| 237 device::BluetoothDevice* bluetooth_device, | 238 device::BluetoothDevice* bluetooth_device, |
| 238 std::string& service_data) { | 239 std::string& service_data) { |
| 239 std::vector<cryptauth::BeaconSeed> beacon_seeds; | 240 std::vector<cryptauth::BeaconSeed> beacon_seeds; |
| 240 if (!local_device_data_provider_->GetLocalDeviceData(nullptr, | 241 if (!local_device_data_provider_->GetLocalDeviceData(nullptr, |
| 241 &beacon_seeds)) { | 242 &beacon_seeds)) { |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 254 | 255 |
| 255 for (auto& observer : observer_list_) { | 256 for (auto& observer : observer_list_) { |
| 256 observer.OnReceivedAdvertisementFromDevice(bluetooth_device->GetAddress(), | 257 observer.OnReceivedAdvertisementFromDevice(bluetooth_device->GetAddress(), |
| 257 *identified_device); | 258 *identified_device); |
| 258 } | 259 } |
| 259 } | 260 } |
| 260 | 261 |
| 261 } // namespace tether | 262 } // namespace tether |
| 262 | 263 |
| 263 } // namespace chromeos | 264 } // namespace chromeos |
| OLD | NEW |