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

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

Issue 1542163002: Switch to standard integer types in device/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: win Created 4 years, 12 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/bluetooth_gatt_descriptor_service_provider.h" 5 #include "device/bluetooth/dbus/bluetooth_gatt_descriptor_service_provider.h"
6 6
7 #include <stddef.h>
8
7 #include "base/bind.h" 9 #include "base/bind.h"
8 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/macros.h"
9 #include "base/memory/weak_ptr.h" 12 #include "base/memory/weak_ptr.h"
10 #include "base/strings/string_util.h" 13 #include "base/strings/string_util.h"
11 #include "base/threading/platform_thread.h" 14 #include "base/threading/platform_thread.h"
12 #include "dbus/exported_object.h" 15 #include "dbus/exported_object.h"
13 #include "dbus/message.h" 16 #include "dbus/message.h"
14 #include "device/bluetooth/dbus/bluez_dbus_manager.h" 17 #include "device/bluetooth/dbus/bluez_dbus_manager.h"
15 #include "device/bluetooth/dbus/fake_bluetooth_gatt_descriptor_service_provider. h" 18 #include "device/bluetooth/dbus/fake_bluetooth_gatt_descriptor_service_provider. h"
16 #include "third_party/cros_system_api/dbus/service_constants.h" 19 #include "third_party/cros_system_api/dbus/service_constants.h"
17 20
18 namespace bluez { 21 namespace bluez {
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 weak_ptr_factory_.GetWeakPtr())); 79 weak_ptr_factory_.GetWeakPtr()));
77 } 80 }
78 81
79 ~BluetoothGattDescriptorServiceProviderImpl() override { 82 ~BluetoothGattDescriptorServiceProviderImpl() override {
80 VLOG(1) << "Cleaning up Bluetooth GATT characteristic descriptor: " 83 VLOG(1) << "Cleaning up Bluetooth GATT characteristic descriptor: "
81 << object_path_.value(); 84 << object_path_.value();
82 bus_->UnregisterExportedObject(object_path_); 85 bus_->UnregisterExportedObject(object_path_);
83 } 86 }
84 87
85 // BluetoothGattDescriptorServiceProvider override. 88 // BluetoothGattDescriptorServiceProvider override.
86 void SendValueChanged(const std::vector<uint8>& value) override { 89 void SendValueChanged(const std::vector<uint8_t>& value) override {
87 VLOG(2) << "Emitting a PropertiesChanged signal for descriptor value."; 90 VLOG(2) << "Emitting a PropertiesChanged signal for descriptor value.";
88 dbus::Signal signal(dbus::kDBusPropertiesInterface, 91 dbus::Signal signal(dbus::kDBusPropertiesInterface,
89 dbus::kDBusPropertiesChangedSignal); 92 dbus::kDBusPropertiesChangedSignal);
90 dbus::MessageWriter writer(&signal); 93 dbus::MessageWriter writer(&signal);
91 dbus::MessageWriter array_writer(NULL); 94 dbus::MessageWriter array_writer(NULL);
92 dbus::MessageWriter dict_entry_writer(NULL); 95 dbus::MessageWriter dict_entry_writer(NULL);
93 dbus::MessageWriter variant_writer(NULL); 96 dbus::MessageWriter variant_writer(NULL);
94 97
95 // interface_name 98 // interface_name
96 writer.AppendString( 99 writer.AppendString(
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 error_message = "No such property: '" + property_name + "'."; 238 error_message = "No such property: '" + property_name + "'.";
236 } 239 }
237 scoped_ptr<dbus::ErrorResponse> error_response = 240 scoped_ptr<dbus::ErrorResponse> error_response =
238 dbus::ErrorResponse::FromMethodCall(method_call, error_name, 241 dbus::ErrorResponse::FromMethodCall(method_call, error_name,
239 error_message); 242 error_message);
240 response_sender.Run(error_response.Pass()); 243 response_sender.Run(error_response.Pass());
241 return; 244 return;
242 } 245 }
243 246
244 // Obtain the value. 247 // Obtain the value.
245 const uint8* bytes = NULL; 248 const uint8_t* bytes = NULL;
246 size_t length = 0; 249 size_t length = 0;
247 if (!variant_reader.PopArrayOfBytes(&bytes, &length)) { 250 if (!variant_reader.PopArrayOfBytes(&bytes, &length)) {
248 scoped_ptr<dbus::ErrorResponse> error_response = 251 scoped_ptr<dbus::ErrorResponse> error_response =
249 dbus::ErrorResponse::FromMethodCall( 252 dbus::ErrorResponse::FromMethodCall(
250 method_call, kErrorInvalidArgs, 253 method_call, kErrorInvalidArgs,
251 "Property '" + property_name + "' has type 'ay'."); 254 "Property '" + property_name + "' has type 'ay'.");
252 response_sender.Run(error_response.Pass()); 255 response_sender.Run(error_response.Pass());
253 return; 256 return;
254 } 257 }
255 258
256 // Pass the set request onto the delegate. 259 // Pass the set request onto the delegate.
257 std::vector<uint8> value(bytes, bytes + length); 260 std::vector<uint8_t> value(bytes, bytes + length);
258 DCHECK(delegate_); 261 DCHECK(delegate_);
259 delegate_->SetDescriptorValue( 262 delegate_->SetDescriptorValue(
260 value, base::Bind(&BluetoothGattDescriptorServiceProviderImpl::OnSet, 263 value, base::Bind(&BluetoothGattDescriptorServiceProviderImpl::OnSet,
261 weak_ptr_factory_.GetWeakPtr(), method_call, 264 weak_ptr_factory_.GetWeakPtr(), method_call,
262 response_sender), 265 response_sender),
263 base::Bind(&BluetoothGattDescriptorServiceProviderImpl::OnFailure, 266 base::Bind(&BluetoothGattDescriptorServiceProviderImpl::OnFailure,
264 weak_ptr_factory_.GetWeakPtr(), method_call, 267 weak_ptr_factory_.GetWeakPtr(), method_call,
265 response_sender)); 268 response_sender));
266 } 269 }
267 270
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 bool success) { 316 bool success) {
314 LOG_IF(WARNING, !success) << "Failed to export " << interface_name << "." 317 LOG_IF(WARNING, !success) << "Failed to export " << interface_name << "."
315 << method_name; 318 << method_name;
316 } 319 }
317 320
318 // Called by the Delegate in response to a method to call to get all 321 // Called by the Delegate in response to a method to call to get all
319 // properties, in which the delegate has successfully returned the 322 // properties, in which the delegate has successfully returned the
320 // descriptor value. 323 // descriptor value.
321 void OnGetAll(dbus::MethodCall* method_call, 324 void OnGetAll(dbus::MethodCall* method_call,
322 dbus::ExportedObject::ResponseSender response_sender, 325 dbus::ExportedObject::ResponseSender response_sender,
323 const std::vector<uint8>& value) { 326 const std::vector<uint8_t>& value) {
324 VLOG(2) << "Descriptor value obtained from delegate. Responding to " 327 VLOG(2) << "Descriptor value obtained from delegate. Responding to "
325 << "GetAll."; 328 << "GetAll.";
326 329
327 scoped_ptr<dbus::Response> response = 330 scoped_ptr<dbus::Response> response =
328 dbus::Response::FromMethodCall(method_call); 331 dbus::Response::FromMethodCall(method_call);
329 dbus::MessageWriter writer(response.get()); 332 dbus::MessageWriter writer(response.get());
330 dbus::MessageWriter array_writer(NULL); 333 dbus::MessageWriter array_writer(NULL);
331 dbus::MessageWriter dict_entry_writer(NULL); 334 dbus::MessageWriter dict_entry_writer(NULL);
332 dbus::MessageWriter variant_writer(NULL); 335 dbus::MessageWriter variant_writer(NULL);
333 336
(...skipping 21 matching lines...) Expand all
355 358
356 writer.CloseContainer(&array_writer); 359 writer.CloseContainer(&array_writer);
357 360
358 response_sender.Run(response.Pass()); 361 response_sender.Run(response.Pass());
359 } 362 }
360 363
361 // Called by the Delegate in response to a successful method call to get the 364 // Called by the Delegate in response to a successful method call to get the
362 // descriptor value. 365 // descriptor value.
363 void OnGet(dbus::MethodCall* method_call, 366 void OnGet(dbus::MethodCall* method_call,
364 dbus::ExportedObject::ResponseSender response_sender, 367 dbus::ExportedObject::ResponseSender response_sender,
365 const std::vector<uint8>& value) { 368 const std::vector<uint8_t>& value) {
366 VLOG(2) << "Returning descriptor value obtained from delegate."; 369 VLOG(2) << "Returning descriptor value obtained from delegate.";
367 scoped_ptr<dbus::Response> response = 370 scoped_ptr<dbus::Response> response =
368 dbus::Response::FromMethodCall(method_call); 371 dbus::Response::FromMethodCall(method_call);
369 dbus::MessageWriter writer(response.get()); 372 dbus::MessageWriter writer(response.get());
370 dbus::MessageWriter variant_writer(NULL); 373 dbus::MessageWriter variant_writer(NULL);
371 374
372 writer.OpenVariant("ay", &variant_writer); 375 writer.OpenVariant("ay", &variant_writer);
373 variant_writer.AppendArrayOfBytes(value.data(), value.size()); 376 variant_writer.AppendArrayOfBytes(value.data(), value.size());
374 writer.CloseContainer(&variant_writer); 377 writer.CloseContainer(&variant_writer);
375 378
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
448 const dbus::ObjectPath& characteristic_path) { 451 const dbus::ObjectPath& characteristic_path) {
449 if (!bluez::BluezDBusManager::Get()->IsUsingStub()) { 452 if (!bluez::BluezDBusManager::Get()->IsUsingStub()) {
450 return new BluetoothGattDescriptorServiceProviderImpl( 453 return new BluetoothGattDescriptorServiceProviderImpl(
451 bus, object_path, delegate, uuid, permissions, characteristic_path); 454 bus, object_path, delegate, uuid, permissions, characteristic_path);
452 } 455 }
453 return new FakeBluetoothGattDescriptorServiceProvider( 456 return new FakeBluetoothGattDescriptorServiceProvider(
454 object_path, delegate, uuid, permissions, characteristic_path); 457 object_path, delegate, uuid, permissions, characteristic_path);
455 } 458 }
456 459
457 } // namespace bluez 460 } // namespace bluez
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698