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

Side by Side Diff: device/bluetooth/test/bluetooth_test_bluez.cc

Issue 2076433002: Revert of Add support in Chrome to send notifications to a specific device. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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
« no previous file with comments | « device/bluetooth/test/bluetooth_test_bluez.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/test/bluetooth_test_bluez.h" 5 #include "device/bluetooth/test/bluetooth_test_bluez.h"
6 6
7 #include <string> 7 #include <string>
8 #include <tuple>
9 #include <utility> 8 #include <utility>
10 9
11 #include "base/bind.h" 10 #include "base/bind.h"
12 #include "base/callback.h" 11 #include "base/callback.h"
13 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
14 #include "base/run_loop.h" 13 #include "base/run_loop.h"
15 #include "dbus/object_path.h" 14 #include "dbus/object_path.h"
16 #include "device/bluetooth/bluez/bluetooth_adapter_bluez.h" 15 #include "device/bluetooth/bluez/bluetooth_adapter_bluez.h"
17 #include "device/bluetooth/bluez/bluetooth_device_bluez.h" 16 #include "device/bluetooth/bluez/bluetooth_device_bluez.h"
18 #include "device/bluetooth/bluez/bluetooth_gatt_characteristic_bluez.h" 17 #include "device/bluetooth/bluez/bluetooth_gatt_characteristic_bluez.h"
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 bluez::BluetoothLocalGattServiceBlueZ* service_bluez = 271 bluez::BluetoothLocalGattServiceBlueZ* service_bluez =
273 static_cast<bluez::BluetoothLocalGattServiceBlueZ*>( 272 static_cast<bluez::BluetoothLocalGattServiceBlueZ*>(
274 characteristic->GetService()); 273 characteristic->GetService());
275 static_cast<TestBluetoothLocalGattServiceDelegate*>( 274 static_cast<TestBluetoothLocalGattServiceDelegate*>(
276 service_bluez->GetDelegate()) 275 service_bluez->GetDelegate())
277 ->set_expected_characteristic(characteristic); 276 ->set_expected_characteristic(characteristic);
278 277
279 return characteristic_provider->NotificationsChange(start); 278 return characteristic_provider->NotificationsChange(start);
280 } 279 }
281 280
282 BluetoothTestBase::NotificationType 281 std::vector<uint8_t> BluetoothTestBlueZ::LastNotifactionValueForCharacteristic(
283 BluetoothTestBlueZ::LastNotifactionValueForCharacteristic(
284 BluetoothLocalGattCharacteristic* characteristic) { 282 BluetoothLocalGattCharacteristic* characteristic) {
285 bluez::BluetoothLocalGattCharacteristicBlueZ* characteristic_bluez = 283 bluez::BluetoothLocalGattCharacteristicBlueZ* characteristic_bluez =
286 static_cast<bluez::BluetoothLocalGattCharacteristicBlueZ*>( 284 static_cast<bluez::BluetoothLocalGattCharacteristicBlueZ*>(
287 characteristic); 285 characteristic);
288 bluez::FakeBluetoothGattManagerClient* fake_bluetooth_gatt_manager_client = 286 bluez::FakeBluetoothGattManagerClient* fake_bluetooth_gatt_manager_client =
289 static_cast<bluez::FakeBluetoothGattManagerClient*>( 287 static_cast<bluez::FakeBluetoothGattManagerClient*>(
290 bluez::BluezDBusManager::Get()->GetBluetoothGattManagerClient()); 288 bluez::BluezDBusManager::Get()->GetBluetoothGattManagerClient());
291 bluez::FakeBluetoothGattCharacteristicServiceProvider* 289 bluez::FakeBluetoothGattCharacteristicServiceProvider*
292 characteristic_provider = 290 characteristic_provider =
293 fake_bluetooth_gatt_manager_client->GetCharacteristicServiceProvider( 291 fake_bluetooth_gatt_manager_client->GetCharacteristicServiceProvider(
294 characteristic_bluez->object_path()); 292 characteristic_bluez->object_path());
295 293
296 if (!characteristic_provider) 294 return characteristic_provider ? characteristic_provider->sent_value()
297 return NotificationType(); 295 : std::vector<uint8_t>();
298
299 bluez::BluetoothAdapterBlueZ* adapter_bluez =
300 static_cast<bluez::BluetoothAdapterBlueZ*>(adapter_.get());
301
302 std::string device_id;
303 bluez::BluetoothDeviceBlueZ* device = adapter_bluez->GetDeviceWithPath(
304 characteristic_provider->last_device_path());
305 if (device)
306 device_id = device->GetIdentifier();
307
308 NotificationType notification = {
309 device_id, characteristic_provider->last_value(),
310 characteristic_provider->last_indicate_flag()};
311 return notification;
312 } 296 }
313 297
314 std::vector<BluetoothLocalGattService*> 298 std::vector<BluetoothLocalGattService*>
315 BluetoothTestBlueZ::RegisteredGattServices() { 299 BluetoothTestBlueZ::RegisteredGattServices() {
316 std::vector<BluetoothLocalGattService*> services; 300 std::vector<BluetoothLocalGattService*> services;
317 bluez::BluetoothAdapterBlueZ* adapter_bluez = 301 bluez::BluetoothAdapterBlueZ* adapter_bluez =
318 static_cast<bluez::BluetoothAdapterBlueZ*>(adapter_.get()); 302 static_cast<bluez::BluetoothAdapterBlueZ*>(adapter_.get());
319 303
320 for (const auto& iter : adapter_bluez->registered_gatt_services_) 304 for (const auto& iter : adapter_bluez->registered_gatt_services_)
321 services.push_back(iter.second); 305 services.push_back(iter.second);
322 return services; 306 return services;
323 } 307 }
324 308
325 } // namespace device 309 } // namespace device
OLDNEW
« no previous file with comments | « device/bluetooth/test/bluetooth_test_bluez.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698