OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2015 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_BLUETOOTH_ADAPTER_PROFILE_CHROMEOS_H_ | |
6 #define DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_PROFILE_CHROMEOS_H_ | |
7 | |
8 #include "base/memory/weak_ptr.h" | |
9 #include "chromeos/dbus/bluetooth_profile_manager_client.h" | |
10 #include "chromeos/dbus/bluetooth_profile_service_provider.h" | |
11 #include "device/bluetooth/bluetooth_export.h" | |
12 | |
13 namespace device { | |
14 class BluetoothUUID; | |
15 } // namespace device | |
16 | |
17 namespace chromeos { | |
18 | |
19 class BluetoothAdapterChromeOS; | |
20 | |
21 // The BluetoothAdapterProfileChromeOS class implements a multiplexing | |
22 // profile for custom bluetooth services managed by a BluetoothAdapter. | |
armansito
2015/01/21 01:44:47
nit: s/bluetooth/Bluetooth/
Marie Janssen
2015/01/22 21:55:33
Done.
| |
23 // Maintains a list of delegates which may serve the profile. | |
24 // One delegate is allowed for each device. | |
25 class DEVICE_BLUETOOTH_EXPORT BluetoothAdapterProfileChromeOS | |
26 : public chromeos::BluetoothProfileServiceProvider::Delegate { | |
27 public: | |
28 // Registers a profile with the BlueZ server for |uuid| with the | |
29 // options |options|. Returns a newly allocated pointer, or NULL | |
30 // if there was a problem. | |
31 static BluetoothAdapterProfileChromeOS* Register( | |
32 BluetoothAdapterChromeOS* adapter, | |
33 const device::BluetoothUUID& uuid, | |
34 const BluetoothProfileManagerClient::Options* options, | |
armansito
2015/01/21 01:44:47
I'd pass |options| as a const reference rather tha
Marie Janssen
2015/01/22 21:55:33
Done.
| |
35 const base::Closure& success_callback, | |
36 const BluetoothProfileManagerClient::ErrorCallback& error_callback); | |
37 | |
38 virtual ~BluetoothAdapterProfileChromeOS(); | |
39 | |
40 // The object path of the profile. | |
41 const dbus::ObjectPath& object_path() const { return object_path_; } | |
42 | |
43 // Add a delegate for a device associated with this profile. | |
44 // An empty |device_path| indicates a local listening service. | |
45 // Returns true if the delegate was set, and false if the |device_path| | |
46 // already had a delegate set. | |
47 bool SetDelegate(const dbus::ObjectPath& device_path, | |
48 BluetoothProfileServiceProvider::Delegate* delegate); | |
49 | |
50 // Remove the delegate for a device. | |
51 void RemoveDelegate(const dbus::ObjectPath& device_path); | |
52 | |
53 // Returns the number of delegates for this profile. | |
54 size_t DelegateCount() const { return delegates_.size(); } | |
55 | |
56 // BluetoothProfileServiceProvider::Delegate: | |
armansito
2015/01/21 01:44:47
I'd define these as private methods.
Marie Janssen
2015/01/22 21:55:33
Done.
| |
57 virtual void Released() override; | |
58 virtual void NewConnection( | |
59 const dbus::ObjectPath& device_path, | |
60 scoped_ptr<dbus::FileDescriptor> fd, | |
61 const BluetoothProfileServiceProvider::Delegate::Options& options, | |
62 const ConfirmationCallback& callback) override; | |
63 virtual void RequestDisconnection( | |
64 const dbus::ObjectPath& device_path, | |
65 const ConfirmationCallback& callback) override; | |
66 virtual void Cancel() override; | |
armansito
2015/01/21 01:44:47
I'd define these as private methods.
armansito
2015/01/21 01:44:47
nit: Remove "virtual" when using "override".
Marie Janssen
2015/01/22 21:55:33
Done.
Marie Janssen
2015/01/22 21:55:33
Done.
| |
67 | |
68 private: | |
69 BluetoothAdapterProfileChromeOS(BluetoothAdapterChromeOS* adapter, | |
70 const device::BluetoothUUID& uuid); | |
71 | |
72 // Called by dbus:: on completion of the D-Bus method to unregister a profile. | |
73 void OnUnregisterProfile(); | |
74 void OnUnregisterProfileError(const std::string& error_name, | |
75 const std::string& error_message); | |
76 | |
77 // List of delegates which this profile is multiplexing to. | |
78 std::map<std::string, BluetoothProfileServiceProvider::Delegate*> delegates_; | |
79 | |
80 // The UUID that this profile represents. | |
81 const device::BluetoothUUID& uuid_; | |
82 | |
83 // Registered dbus object path for this profile. | |
armansito
2015/01/21 01:44:47
nit: s/dbus/D-Bus/
Or just be generally consisten
Marie Janssen
2015/01/22 21:55:33
Done.
| |
84 dbus::ObjectPath object_path_; | |
85 | |
86 // Profile D-Bus object for receiving profile method calls from BlueZ | |
87 scoped_ptr<BluetoothProfileServiceProvider> profile_; | |
88 | |
89 // Adapter that owns this profile. | |
90 BluetoothAdapterChromeOS* adapter_; | |
91 | |
92 // Note: This should remain the last member so it'll be destroyed and | |
93 // invalidate its weak pointers before any other members are destroyed. | |
94 base::WeakPtrFactory<BluetoothAdapterProfileChromeOS> weak_ptr_factory_; | |
95 | |
96 DISALLOW_COPY_AND_ASSIGN(BluetoothAdapterProfileChromeOS); | |
97 }; | |
98 | |
99 } // namespace chromeos | |
100 | |
101 #endif | |
OLD | NEW |