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

Side by Side Diff: device/bluetooth/dbus/fake_bluetooth_gatt_characteristic_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_characteristic_service_provi der.h" 5 #include "device/bluetooth/dbus/fake_bluetooth_gatt_characteristic_service_provi der.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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 } 106 }
107 107
108 void FakeBluetoothGattCharacteristicServiceProvider::SendValueChanged( 108 void FakeBluetoothGattCharacteristicServiceProvider::SendValueChanged(
109 const std::vector<uint8_t>& value) { 109 const std::vector<uint8_t>& value) {
110 VLOG(1) << "Sent characteristic value changed: " << object_path_.value() 110 VLOG(1) << "Sent characteristic value changed: " << object_path_.value()
111 << " UUID: " << uuid_; 111 << " UUID: " << uuid_;
112 sent_value_ = value; 112 sent_value_ = value;
113 } 113 }
114 114
115 void FakeBluetoothGattCharacteristicServiceProvider::GetValue( 115 void FakeBluetoothGattCharacteristicServiceProvider::GetValue(
116 const dbus::ObjectPath& device_path,
116 const device::BluetoothLocalGattService::Delegate::ValueCallback& callback, 117 const device::BluetoothLocalGattService::Delegate::ValueCallback& callback,
117 const device::BluetoothLocalGattService::Delegate::ErrorCallback& 118 const device::BluetoothLocalGattService::Delegate::ErrorCallback&
118 error_callback) { 119 error_callback) {
119 VLOG(1) << "GATT characteristic value Get request: " << object_path_.value() 120 VLOG(1) << "GATT characteristic value Get request: " << object_path_.value()
120 << " UUID: " << uuid_; 121 << " UUID: " << uuid_;
121 // Check if this characteristic is registered. 122 // Check if this characteristic is registered.
122 FakeBluetoothGattManagerClient* fake_bluetooth_gatt_manager_client = 123 FakeBluetoothGattManagerClient* fake_bluetooth_gatt_manager_client =
123 static_cast<FakeBluetoothGattManagerClient*>( 124 static_cast<FakeBluetoothGattManagerClient*>(
124 bluez::BluezDBusManager::Get()->GetBluetoothGattManagerClient()); 125 bluez::BluezDBusManager::Get()->GetBluetoothGattManagerClient());
125 if (!fake_bluetooth_gatt_manager_client->IsServiceRegistered(service_path_)) { 126 if (!fake_bluetooth_gatt_manager_client->IsServiceRegistered(service_path_)) {
126 VLOG(1) << "GATT characteristic not registered."; 127 VLOG(1) << "GATT characteristic not registered.";
127 error_callback.Run(); 128 error_callback.Run();
128 return; 129 return;
129 } 130 }
130 131
131 if (!CanRead(flags_)) { 132 if (!CanRead(flags_)) {
132 VLOG(1) << "GATT characteristic not readable."; 133 VLOG(1) << "GATT characteristic not readable.";
133 error_callback.Run(); 134 error_callback.Run();
134 return; 135 return;
135 } 136 }
136 137
137 // Pass on to the delegate. 138 // Pass on to the delegate.
138 DCHECK(delegate_); 139 DCHECK(delegate_);
139 delegate_->GetValue(callback, error_callback); 140 delegate_->GetValue(device_path, callback, error_callback);
140 } 141 }
141 142
142 void FakeBluetoothGattCharacteristicServiceProvider::SetValue( 143 void FakeBluetoothGattCharacteristicServiceProvider::SetValue(
144 const dbus::ObjectPath& device_path,
143 const std::vector<uint8_t>& value, 145 const std::vector<uint8_t>& value,
144 const base::Closure& callback, 146 const base::Closure& callback,
145 const device::BluetoothLocalGattService::Delegate::ErrorCallback& 147 const device::BluetoothLocalGattService::Delegate::ErrorCallback&
146 error_callback) { 148 error_callback) {
147 VLOG(1) << "GATT characteristic value Set request: " << object_path_.value() 149 VLOG(1) << "GATT characteristic value Set request: " << object_path_.value()
148 << " UUID: " << uuid_; 150 << " UUID: " << uuid_;
149 // Check if this characteristic is registered. 151 // Check if this characteristic is registered.
150 FakeBluetoothGattManagerClient* fake_bluetooth_gatt_manager_client = 152 FakeBluetoothGattManagerClient* fake_bluetooth_gatt_manager_client =
151 static_cast<FakeBluetoothGattManagerClient*>( 153 static_cast<FakeBluetoothGattManagerClient*>(
152 bluez::BluezDBusManager::Get()->GetBluetoothGattManagerClient()); 154 bluez::BluezDBusManager::Get()->GetBluetoothGattManagerClient());
153 if (!fake_bluetooth_gatt_manager_client->IsServiceRegistered(service_path_)) { 155 if (!fake_bluetooth_gatt_manager_client->IsServiceRegistered(service_path_)) {
154 VLOG(1) << "GATT characteristic not registered."; 156 VLOG(1) << "GATT characteristic not registered.";
155 error_callback.Run(); 157 error_callback.Run();
156 return; 158 return;
157 } 159 }
158 160
159 if (!CanWrite(flags_)) { 161 if (!CanWrite(flags_)) {
160 VLOG(1) << "GATT characteristic not writeable."; 162 VLOG(1) << "GATT characteristic not writeable.";
161 error_callback.Run(); 163 error_callback.Run();
162 return; 164 return;
163 } 165 }
164 166
165 // Pass on to the delegate. 167 // Pass on to the delegate.
166 DCHECK(delegate_); 168 DCHECK(delegate_);
167 delegate_->SetValue(value, callback, error_callback); 169 delegate_->SetValue(device_path, value, callback, error_callback);
168 } 170 }
169 171
170 bool FakeBluetoothGattCharacteristicServiceProvider::NotificationsChange( 172 bool FakeBluetoothGattCharacteristicServiceProvider::NotificationsChange(
171 bool start) { 173 bool start) {
172 VLOG(1) << "GATT characteristic value notification request: " 174 VLOG(1) << "GATT characteristic value notification request: "
173 << object_path_.value() << " UUID: " << uuid_ << " start=" << start; 175 << object_path_.value() << " UUID: " << uuid_ << " start=" << start;
174 // Check if this characteristic is registered. 176 // Check if this characteristic is registered.
175 FakeBluetoothGattManagerClient* fake_bluetooth_gatt_manager_client = 177 FakeBluetoothGattManagerClient* fake_bluetooth_gatt_manager_client =
176 static_cast<FakeBluetoothGattManagerClient*>( 178 static_cast<FakeBluetoothGattManagerClient*>(
177 bluez::BluezDBusManager::Get()->GetBluetoothGattManagerClient()); 179 bluez::BluezDBusManager::Get()->GetBluetoothGattManagerClient());
(...skipping 13 matching lines...) Expand all
191 193
192 return true; 194 return true;
193 } 195 }
194 196
195 const dbus::ObjectPath& 197 const dbus::ObjectPath&
196 FakeBluetoothGattCharacteristicServiceProvider::object_path() const { 198 FakeBluetoothGattCharacteristicServiceProvider::object_path() const {
197 return object_path_; 199 return object_path_;
198 } 200 }
199 201
200 } // namespace bluez 202 } // namespace bluez
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698