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

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

Issue 1974633002: Implement DBus changes needed for notifications. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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_application_service_provider_impl .h" 5 #include "device/bluetooth/dbus/bluetooth_gatt_application_service_provider_impl .h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "third_party/cros_system_api/dbus/service_constants.h" 9 #include "third_party/cros_system_api/dbus/service_constants.h"
10 10
11 namespace bluez { 11 namespace bluez {
12 12
13 BluetoothGattApplicationServiceProviderImpl:: 13 BluetoothGattApplicationServiceProviderImpl::
14 BluetoothGattApplicationServiceProviderImpl( 14 BluetoothGattApplicationServiceProviderImpl(
15 dbus::Bus* bus, 15 dbus::Bus* bus,
16 const dbus::ObjectPath& object_path, 16 const dbus::ObjectPath& object_path,
17 const std::map<dbus::ObjectPath, BluetoothLocalGattServiceBlueZ*>& 17 const std::map<dbus::ObjectPath, BluetoothLocalGattServiceBlueZ*>&
18 services) 18 services)
19 : origin_thread_id_(base::PlatformThread::CurrentId()), 19 : origin_thread_id_(base::PlatformThread::CurrentId()),
20 bus_(bus), 20 bus_(bus),
21 object_path_(object_path), 21 object_path_(object_path),
22 weak_ptr_factory_(this) { 22 weak_ptr_factory_(this) {
23 VLOG(1) << "Creating Bluetooth GATT application: " << object_path_.value(); 23 VLOG(1) << "Creating Bluetooth GATT application: " << object_path_.value();
24 DCHECK(object_path_.IsValid()); 24 DCHECK(object_path_.IsValid());
25 DCHECK(bus_); 25 if (!bus_)
26 return;
26 27
27 exported_object_ = bus_->GetExportedObject(object_path_); 28 exported_object_ = bus_->GetExportedObject(object_path_);
28 29
29 exported_object_->ExportMethod( 30 exported_object_->ExportMethod(
30 dbus::kDBusObjectManagerInterface, 31 dbus::kDBusObjectManagerInterface,
31 dbus::kDBusObjectManagerGetManagedObjects, 32 dbus::kDBusObjectManagerGetManagedObjects,
32 base::Bind( 33 base::Bind(
33 &BluetoothGattApplicationServiceProviderImpl::GetManagedObjects, 34 &BluetoothGattApplicationServiceProviderImpl::GetManagedObjects,
34 weak_ptr_factory_.GetWeakPtr()), 35 weak_ptr_factory_.GetWeakPtr()),
35 base::Bind(&BluetoothGattApplicationServiceProviderImpl::OnExported, 36 base::Bind(&BluetoothGattApplicationServiceProviderImpl::OnExported,
36 weak_ptr_factory_.GetWeakPtr())); 37 weak_ptr_factory_.GetWeakPtr()));
37 38
38 BluetoothGattApplicationServiceProvider::CreateAttributeServiceProviders( 39 CreateAttributeServiceProviders(bus, services);
39 bus, services, &service_providers_, &characteristic_providers_,
40 &descriptor_providers_);
41 } 40 }
42 41
43 BluetoothGattApplicationServiceProviderImpl:: 42 BluetoothGattApplicationServiceProviderImpl::
44 ~BluetoothGattApplicationServiceProviderImpl() { 43 ~BluetoothGattApplicationServiceProviderImpl() {
45 VLOG(1) << "Cleaning up Bluetooth GATT service: " << object_path_.value(); 44 VLOG(1) << "Cleaning up Bluetooth GATT service: " << object_path_.value();
46 if (bus_) 45 if (bus_)
47 bus_->UnregisterExportedObject(object_path_); 46 bus_->UnregisterExportedObject(object_path_);
48 } 47 }
49 48
50 BluetoothGattApplicationServiceProviderImpl::
51 BluetoothGattApplicationServiceProviderImpl(
52 const dbus::ObjectPath& object_path)
53 : origin_thread_id_(base::PlatformThread::CurrentId()),
54 bus_(nullptr),
55 object_path_(object_path),
56 weak_ptr_factory_(this) {
57 VLOG(1) << "Creating Fake Bluetooth GATT application service provider.";
58 }
59
60 bool BluetoothGattApplicationServiceProviderImpl::OnOriginThread() { 49 bool BluetoothGattApplicationServiceProviderImpl::OnOriginThread() {
61 return base::PlatformThread::CurrentId() == origin_thread_id_; 50 return base::PlatformThread::CurrentId() == origin_thread_id_;
62 } 51 }
63 52
64 template <typename AttributeProvider> 53 template <typename AttributeProvider>
65 void BluetoothGattApplicationServiceProviderImpl::WriteObjectDict( 54 void BluetoothGattApplicationServiceProviderImpl::WriteObjectDict(
66 dbus::MessageWriter* writer, 55 dbus::MessageWriter* writer,
67 const std::string& attribute_interface, 56 const std::string& attribute_interface,
68 AttributeProvider* attribute_provider) { 57 AttributeProvider* attribute_provider) {
69 // Open a dict entry for { object_path : interface_list }. 58 // Open a dict entry for { object_path : interface_list }.
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 // Called by dbus:: when a method is exported. 153 // Called by dbus:: when a method is exported.
165 void BluetoothGattApplicationServiceProviderImpl::OnExported( 154 void BluetoothGattApplicationServiceProviderImpl::OnExported(
166 const std::string& interface_name, 155 const std::string& interface_name,
167 const std::string& method_name, 156 const std::string& method_name,
168 bool success) { 157 bool success) {
169 LOG_IF(WARNING, !success) << "Failed to export " << interface_name << "." 158 LOG_IF(WARNING, !success) << "Failed to export " << interface_name << "."
170 << method_name; 159 << method_name;
171 } 160 }
172 161
173 } // namespace bluez 162 } // namespace bluez
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698