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 | 232 |
233 CheckForMatchingScanFilters(bluetooth_device, service_data_str); | 233 CheckForMatchingScanFilters(bluetooth_device, service_data_str); |
234 } | 234 } |
235 | 235 |
236 void BleScanner::CheckForMatchingScanFilters( | 236 void BleScanner::CheckForMatchingScanFilters( |
237 device::BluetoothDevice* bluetooth_device, | 237 device::BluetoothDevice* bluetooth_device, |
238 std::string& service_data) { | 238 std::string& service_data) { |
239 std::vector<cryptauth::BeaconSeed> beacon_seeds; | 239 std::vector<cryptauth::BeaconSeed> beacon_seeds; |
240 if (!local_device_data_provider_->GetLocalDeviceData(nullptr, | 240 if (!local_device_data_provider_->GetLocalDeviceData(nullptr, |
241 &beacon_seeds)) { | 241 &beacon_seeds)) { |
(...skipping 12 matching lines...) Expand all Loading... |
254 | 254 |
255 for (auto& observer : observer_list_) { | 255 for (auto& observer : observer_list_) { |
256 observer.OnReceivedAdvertisementFromDevice(bluetooth_device->GetAddress(), | 256 observer.OnReceivedAdvertisementFromDevice(bluetooth_device->GetAddress(), |
257 *identified_device); | 257 *identified_device); |
258 } | 258 } |
259 } | 259 } |
260 | 260 |
261 } // namespace tether | 261 } // namespace tether |
262 | 262 |
263 } // namespace chromeos | 263 } // namespace chromeos |
OLD | NEW |