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

Side by Side Diff: device/bluetooth/dbus/bluetooth_gatt_service_service_provider_impl.h

Issue 1914893002: DBus changes for implementing local GATT attributes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bluetooth_classes
Patch Set: test leak 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef DEVICE_BLUETOOTH_DBUS_BLUETOOTH_GATT_SERVICE_SERVICE_PROVIDER_IMPL_H_
6 #define DEVICE_BLUETOOTH_DBUS_BLUETOOTH_GATT_SERVICE_SERVICE_PROVIDER_IMPL_H_
7
8 #include <string>
9 #include <vector>
10
11 #include <base/macros.h>
12 #include <base/memory/ref_counted.h>
13 #include <base/memory/weak_ptr.h>
14 #include <base/threading/platform_thread.h>
15 #include <dbus/bus.h>
16 #include <dbus/exported_object.h>
17 #include <dbus/message.h>
18 #include <dbus/object_path.h>
19 #include <device/bluetooth/dbus/bluetooth_gatt_service_service_provider.h>
20
21 namespace bluez {
22
23 // The BluetoothGattServiceServiceProvider implementation used in production.
24 class DEVICE_BLUETOOTH_EXPORT BluetoothGattServiceServiceProviderImpl
25 : public BluetoothGattServiceServiceProvider {
26 public:
27 BluetoothGattServiceServiceProviderImpl(
28 dbus::Bus* bus,
29 const dbus::ObjectPath& object_path,
30 const std::string& uuid,
31 const std::vector<dbus::ObjectPath>& includes);
32
33 ~BluetoothGattServiceServiceProviderImpl() override;
34
35 // For testing.
36 BluetoothGattServiceServiceProviderImpl(const dbus::ObjectPath& object_path,
37 const std::string& uuid);
38
39 private:
40 // Returns true if the current thread is on the origin thread.
41 bool OnOriginThread();
42
43 // Called by dbus:: when the Bluetooth daemon fetches a single property of
44 // the service.
45 void Get(dbus::MethodCall* method_call,
46 dbus::ExportedObject::ResponseSender response_sender);
47
48 // Called by dbus:: when the Bluetooth daemon sets a single property of the
49 // service.
50 void Set(dbus::MethodCall* method_call,
51 dbus::ExportedObject::ResponseSender response_sender);
52
53 // Called by dbus:: when the Bluetooth daemon fetches all properties of the
54 // service.
55 void GetAll(dbus::MethodCall* method_call,
56 dbus::ExportedObject::ResponseSender response_sender);
57
58 void WriteProperties(dbus::MessageWriter* writer) override;
59
60 // Called by dbus:: when a method is exported.
61 void OnExported(const std::string& interface_name,
62 const std::string& method_name,
63 bool success);
64
65 const dbus::ObjectPath& object_path() const override;
66
67 // Origin thread (i.e. the UI thread in production).
68 base::PlatformThreadId origin_thread_id_;
69
70 // 128-bit service UUID of this object.
71 std::string uuid_;
72
73 // List of object paths that represent other exported GATT services that are
74 // included from this service.
75 std::vector<dbus::ObjectPath> includes_;
76
77 // D-Bus bus object is exported on, not owned by this object and must
78 // outlive it.
79 dbus::Bus* bus_;
80
81 // D-Bus object path of object we are exporting, kept so we can unregister
82 // again in our destructor.
83 dbus::ObjectPath object_path_;
84
85 // D-Bus object we are exporting, owned by this object.
86 scoped_refptr<dbus::ExportedObject> exported_object_;
87
88 // Weak pointer factory for generating 'this' pointers that might live longer
89 // than we do.
90 // Note: This should remain the last member so it'll be destroyed and
91 // invalidate its weak pointers before any other members are destroyed.
92 base::WeakPtrFactory<BluetoothGattServiceServiceProviderImpl>
93 weak_ptr_factory_;
94
95 DISALLOW_COPY_AND_ASSIGN(BluetoothGattServiceServiceProviderImpl);
96 };
97
98 } // namespace bluez
99
100 #endif // DEVICE_BLUETOOTH_DBUS_BLUETOOTH_GATT_SERVICE_SERVICE_PROVIDER_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698