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

Side by Side Diff: device/bluetooth/dbus/fake_bluetooth_gatt_descriptor_service_provider.cc

Issue 1979163002: Add DBus plumbing and tests for sending devices with ATT read/writes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@devices
Patch Set: gyp fix Created 4 years, 7 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
OLDNEW
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_descriptor_service_provider. h" 5 #include "device/bluetooth/dbus/fake_bluetooth_gatt_descriptor_service_provider. h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <iterator> 8 #include <iterator>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 fake_bluetooth_gatt_manager_client->UnregisterDescriptorServiceProvider(this); 89 fake_bluetooth_gatt_manager_client->UnregisterDescriptorServiceProvider(this);
90 } 90 }
91 91
92 void FakeBluetoothGattDescriptorServiceProvider::SendValueChanged( 92 void FakeBluetoothGattDescriptorServiceProvider::SendValueChanged(
93 const std::vector<uint8_t>& value) { 93 const std::vector<uint8_t>& value) {
94 VLOG(1) << "Sent descriptor value changed: " << object_path_.value() 94 VLOG(1) << "Sent descriptor value changed: " << object_path_.value()
95 << " UUID: " << uuid_; 95 << " UUID: " << uuid_;
96 } 96 }
97 97
98 void FakeBluetoothGattDescriptorServiceProvider::GetValue( 98 void FakeBluetoothGattDescriptorServiceProvider::GetValue(
99 const dbus::ObjectPath& device_path,
99 const device::BluetoothLocalGattService::Delegate::ValueCallback& callback, 100 const device::BluetoothLocalGattService::Delegate::ValueCallback& callback,
100 const device::BluetoothLocalGattService::Delegate::ErrorCallback& 101 const device::BluetoothLocalGattService::Delegate::ErrorCallback&
101 error_callback) { 102 error_callback) {
102 VLOG(1) << "GATT descriptor value Get request: " << object_path_.value() 103 VLOG(1) << "GATT descriptor value Get request: " << object_path_.value()
103 << " UUID: " << uuid_; 104 << " UUID: " << uuid_;
104 // Check if this descriptor is registered. 105 // Check if this descriptor is registered.
105 FakeBluetoothGattManagerClient* fake_bluetooth_gatt_manager_client = 106 FakeBluetoothGattManagerClient* fake_bluetooth_gatt_manager_client =
106 static_cast<FakeBluetoothGattManagerClient*>( 107 static_cast<FakeBluetoothGattManagerClient*>(
107 bluez::BluezDBusManager::Get()->GetBluetoothGattManagerClient()); 108 bluez::BluezDBusManager::Get()->GetBluetoothGattManagerClient());
108 FakeBluetoothGattCharacteristicServiceProvider* characteristic = 109 FakeBluetoothGattCharacteristicServiceProvider* characteristic =
(...skipping 12 matching lines...) Expand all
121 } 122 }
122 123
123 if (!CanRead(flags_)) { 124 if (!CanRead(flags_)) {
124 VLOG(1) << "GATT descriptor not readable."; 125 VLOG(1) << "GATT descriptor not readable.";
125 error_callback.Run(); 126 error_callback.Run();
126 return; 127 return;
127 } 128 }
128 129
129 // Pass on to the delegate. 130 // Pass on to the delegate.
130 DCHECK(delegate_); 131 DCHECK(delegate_);
131 delegate_->GetValue(callback, error_callback); 132 delegate_->GetValue(device_path, callback, error_callback);
132 } 133 }
133 134
134 void FakeBluetoothGattDescriptorServiceProvider::SetValue( 135 void FakeBluetoothGattDescriptorServiceProvider::SetValue(
136 const dbus::ObjectPath& device_path,
135 const std::vector<uint8_t>& value, 137 const std::vector<uint8_t>& value,
136 const base::Closure& callback, 138 const base::Closure& callback,
137 const device::BluetoothLocalGattService::Delegate::ErrorCallback& 139 const device::BluetoothLocalGattService::Delegate::ErrorCallback&
138 error_callback) { 140 error_callback) {
139 VLOG(1) << "GATT descriptor value Set request: " << object_path_.value() 141 VLOG(1) << "GATT descriptor value Set request: " << object_path_.value()
140 << " UUID: " << uuid_; 142 << " UUID: " << uuid_;
141 143
142 // Check if this descriptor is registered. 144 // Check if this descriptor is registered.
143 FakeBluetoothGattManagerClient* fake_bluetooth_gatt_manager_client = 145 FakeBluetoothGattManagerClient* fake_bluetooth_gatt_manager_client =
144 static_cast<FakeBluetoothGattManagerClient*>( 146 static_cast<FakeBluetoothGattManagerClient*>(
(...skipping 14 matching lines...) Expand all
159 } 161 }
160 162
161 if (!CanWrite(flags_)) { 163 if (!CanWrite(flags_)) {
162 VLOG(1) << "GATT descriptor not writeable."; 164 VLOG(1) << "GATT descriptor not writeable.";
163 error_callback.Run(); 165 error_callback.Run();
164 return; 166 return;
165 } 167 }
166 168
167 // Pass on to the delegate. 169 // Pass on to the delegate.
168 DCHECK(delegate_); 170 DCHECK(delegate_);
169 delegate_->SetValue(value, callback, error_callback); 171 delegate_->SetValue(device_path, value, callback, error_callback);
170 } 172 }
171 173
172 const dbus::ObjectPath& 174 const dbus::ObjectPath&
173 FakeBluetoothGattDescriptorServiceProvider::object_path() const { 175 FakeBluetoothGattDescriptorServiceProvider::object_path() const {
174 return object_path_; 176 return object_path_;
175 } 177 }
176 178
177 } // namespace bluez 179 } // namespace bluez
OLDNEW
« no previous file with comments | « device/bluetooth/dbus/fake_bluetooth_gatt_descriptor_service_provider.h ('k') | device/bluetooth/test/bluetooth_test.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698