| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/dbus/fake_bluetooth_gatt_characteristic_service_provi
der.h" | 5 #include "device/bluetooth/dbus/fake_bluetooth_gatt_characteristic_service_provi
der.h" |
| 6 | 6 |
| 7 #include "base/callback.h" | 7 #include "base/callback.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
| 10 #include "device/bluetooth/dbus/bluez_dbus_manager.h" | 10 #include "device/bluetooth/dbus/bluez_dbus_manager.h" |
| 11 #include "device/bluetooth/dbus/fake_bluetooth_gatt_manager_client.h" | 11 #include "device/bluetooth/dbus/fake_bluetooth_gatt_manager_client.h" |
| 12 | 12 |
| 13 namespace bluez { | 13 namespace bluez { |
| 14 | 14 |
| 15 FakeBluetoothGattCharacteristicServiceProvider:: | 15 FakeBluetoothGattCharacteristicServiceProvider:: |
| 16 FakeBluetoothGattCharacteristicServiceProvider( | 16 FakeBluetoothGattCharacteristicServiceProvider( |
| 17 const dbus::ObjectPath& object_path, | 17 const dbus::ObjectPath& object_path, |
| 18 std::unique_ptr<BluetoothGattAttributeValueDelegate> delegate, | 18 std::unique_ptr<BluetoothGattAttributeValueDelegate> delegate, |
| 19 const std::string& uuid, | 19 const std::string& uuid, |
| 20 const std::vector<std::string>& flags, | 20 const std::vector<std::string>& flags, |
| 21 const std::vector<std::string>& permissions, | |
| 22 const dbus::ObjectPath& service_path) | 21 const dbus::ObjectPath& service_path) |
| 23 : object_path_(object_path), | 22 : object_path_(object_path), |
| 24 uuid_(uuid), | 23 uuid_(uuid), |
| 25 service_path_(service_path), | 24 service_path_(service_path), |
| 26 delegate_(std::move(delegate)) { | 25 delegate_(std::move(delegate)) { |
| 27 VLOG(1) << "Creating Bluetooth GATT characteristic: " << object_path_.value(); | 26 VLOG(1) << "Creating Bluetooth GATT characteristic: " << object_path_.value(); |
| 28 | 27 |
| 29 DCHECK(object_path_.IsValid()); | 28 DCHECK(object_path_.IsValid()); |
| 30 DCHECK(service_path_.IsValid()); | 29 DCHECK(service_path_.IsValid()); |
| 31 DCHECK(!uuid.empty()); | 30 DCHECK(!uuid.empty()); |
| 32 DCHECK(delegate_); | 31 DCHECK(delegate_); |
| 33 DCHECK(base::StartsWith(object_path_.value(), service_path_.value() + "/", | 32 DCHECK(base::StartsWith(object_path_.value(), service_path_.value() + "/", |
| 34 base::CompareCase::SENSITIVE)); | 33 base::CompareCase::SENSITIVE)); |
| 35 | 34 |
| 36 // TODO(armansito): Do something with |flags| and |permissions|. | 35 // TODO(rkc): Do something with |flags|. |
| 37 FakeBluetoothGattManagerClient* fake_bluetooth_gatt_manager_client = | 36 FakeBluetoothGattManagerClient* fake_bluetooth_gatt_manager_client = |
| 38 static_cast<FakeBluetoothGattManagerClient*>( | 37 static_cast<FakeBluetoothGattManagerClient*>( |
| 39 bluez::BluezDBusManager::Get()->GetBluetoothGattManagerClient()); | 38 bluez::BluezDBusManager::Get()->GetBluetoothGattManagerClient()); |
| 40 fake_bluetooth_gatt_manager_client->RegisterCharacteristicServiceProvider( | 39 fake_bluetooth_gatt_manager_client->RegisterCharacteristicServiceProvider( |
| 41 this); | 40 this); |
| 42 } | 41 } |
| 43 | 42 |
| 44 FakeBluetoothGattCharacteristicServiceProvider:: | 43 FakeBluetoothGattCharacteristicServiceProvider:: |
| 45 ~FakeBluetoothGattCharacteristicServiceProvider() { | 44 ~FakeBluetoothGattCharacteristicServiceProvider() { |
| 46 VLOG(1) << "Cleaning up Bluetooth GATT characteristic: " | 45 VLOG(1) << "Cleaning up Bluetooth GATT characteristic: " |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 DCHECK(delegate_); | 99 DCHECK(delegate_); |
| 101 delegate_->SetValue(value, callback, error_callback); | 100 delegate_->SetValue(value, callback, error_callback); |
| 102 } | 101 } |
| 103 | 102 |
| 104 const dbus::ObjectPath& | 103 const dbus::ObjectPath& |
| 105 FakeBluetoothGattCharacteristicServiceProvider::object_path() const { | 104 FakeBluetoothGattCharacteristicServiceProvider::object_path() const { |
| 106 return object_path_; | 105 return object_path_; |
| 107 } | 106 } |
| 108 | 107 |
| 109 } // namespace bluez | 108 } // namespace bluez |
| OLD | NEW |