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

Side by Side Diff: device/bluetooth/bluetooth_adapter_profile_chromeos.h

Issue 1347193004: Refactor DBusThreadManager to split away BT clients. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 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 2015 The Chromium Authors. All rights reserved. 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 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 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_PROFILE_CHROMEOS_H_ 5 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_PROFILE_CHROMEOS_H_
6 #define DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_PROFILE_CHROMEOS_H_ 6 #define DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_PROFILE_CHROMEOS_H_
7 7
8 #include "base/memory/weak_ptr.h" 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_adapter_chromeos.h" 9 #include "device/bluetooth/bluetooth_adapter_chromeos.h"
12 #include "device/bluetooth/bluetooth_export.h" 10 #include "device/bluetooth/bluetooth_export.h"
11 #include "device/bluetooth/dbus/bluetooth_profile_manager_client.h"
12 #include "device/bluetooth/dbus/bluetooth_profile_service_provider.h"
13 13
14 namespace device { 14 namespace device {
15 class BluetoothUUID; 15 class BluetoothUUID;
16 } // namespace device 16 } // namespace device
17 17
18 namespace chromeos { 18 namespace chromeos {
19 19
20 // The BluetoothAdapterProfileChromeOS class implements a multiplexing 20 // The BluetoothAdapterProfileChromeOS class implements a multiplexing
21 // profile for custom Bluetooth services managed by a BluetoothAdapter. 21 // profile for custom Bluetooth services managed by a BluetoothAdapter.
22 // Maintains a list of delegates which may serve the profile. 22 // Maintains a list of delegates which may serve the profile.
23 // One delegate is allowed for each device. 23 // One delegate is allowed for each device.
24 // 24 //
25 // This class is not thread-safe, but is only called from the dbus origin 25 // This class is not thread-safe, but is only called from the dbus origin
26 // thread. 26 // thread.
27 // 27 //
28 // BluetoothAdapterProfileChromeOS objects are owned by the 28 // BluetoothAdapterProfileChromeOS objects are owned by the
29 // BluetoothAdapterChromeOS and allocated through Register() 29 // BluetoothAdapterChromeOS and allocated through Register()
30 class DEVICE_BLUETOOTH_EXPORT BluetoothAdapterProfileChromeOS 30 class DEVICE_BLUETOOTH_EXPORT BluetoothAdapterProfileChromeOS
31 : public chromeos::BluetoothProfileServiceProvider::Delegate { 31 : public bluez::BluetoothProfileServiceProvider::Delegate {
32 public: 32 public:
33 typedef base::Callback<void(scoped_ptr<BluetoothAdapterProfileChromeOS> 33 typedef base::Callback<void(scoped_ptr<BluetoothAdapterProfileChromeOS>
34 profile)> ProfileRegisteredCallback; 34 profile)> ProfileRegisteredCallback;
35 35
36 // Registers a profile with the BlueZ server for |uuid| with the 36 // Registers a profile with the BlueZ server for |uuid| with the
37 // options |options|. |success_callback| is provided with a newly 37 // options |options|. |success_callback| is provided with a newly
38 // allocated profile if registration is successful, otherwise |error_callback| 38 // allocated profile if registration is successful, otherwise |error_callback|
39 // will be called. 39 // will be called.
40 static void Register( 40 static void Register(
41 const device::BluetoothUUID& uuid, 41 const device::BluetoothUUID& uuid,
42 const BluetoothProfileManagerClient::Options& options, 42 const bluez::BluetoothProfileManagerClient::Options& options,
43 const ProfileRegisteredCallback& success_callback, 43 const ProfileRegisteredCallback& success_callback,
44 const BluetoothProfileManagerClient::ErrorCallback& error_callback); 44 const bluez::BluetoothProfileManagerClient::ErrorCallback&
45 error_callback);
45 46
46 ~BluetoothAdapterProfileChromeOS() override; 47 ~BluetoothAdapterProfileChromeOS() override;
47 48
48 // The object path of the profile. 49 // The object path of the profile.
49 const dbus::ObjectPath& object_path() const { return object_path_; } 50 const dbus::ObjectPath& object_path() const { return object_path_; }
50 51
51 // Returns the UUID of the profile 52 // Returns the UUID of the profile
52 const device::BluetoothUUID& uuid() const { return uuid_; } 53 const device::BluetoothUUID& uuid() const { return uuid_; }
53 54
54 // Add a delegate for a device associated with this profile. 55 // Add a delegate for a device associated with this profile.
55 // An empty |device_path| indicates a local listening service. 56 // An empty |device_path| indicates a local listening service.
56 // Returns true if the delegate was set, and false if the |device_path| 57 // Returns true if the delegate was set, and false if the |device_path|
57 // already had a delegate set. 58 // already had a delegate set.
58 bool SetDelegate(const dbus::ObjectPath& device_path, 59 bool SetDelegate(const dbus::ObjectPath& device_path,
59 BluetoothProfileServiceProvider::Delegate* delegate); 60 bluez::BluetoothProfileServiceProvider::Delegate* delegate);
60 61
61 // Remove the delegate for a device. |unregistered_callback| will be called 62 // Remove the delegate for a device. |unregistered_callback| will be called
62 // if this unregisters the profile. 63 // if this unregisters the profile.
63 void RemoveDelegate(const dbus::ObjectPath& device_path, 64 void RemoveDelegate(const dbus::ObjectPath& device_path,
64 const base::Closure& unregistered_callback); 65 const base::Closure& unregistered_callback);
65 66
66 // Returns the number of delegates for this profile. 67 // Returns the number of delegates for this profile.
67 size_t DelegateCount() const { return delegates_.size(); } 68 size_t DelegateCount() const { return delegates_.size(); }
68 69
69 private: 70 private:
70 BluetoothAdapterProfileChromeOS(const device::BluetoothUUID& uuid); 71 BluetoothAdapterProfileChromeOS(const device::BluetoothUUID& uuid);
71 72
72 // BluetoothProfileServiceProvider::Delegate: 73 // bluez::BluetoothProfileServiceProvider::Delegate:
73 void Released() override; 74 void Released() override;
74 void NewConnection( 75 void NewConnection(
75 const dbus::ObjectPath& device_path, 76 const dbus::ObjectPath& device_path,
76 scoped_ptr<dbus::FileDescriptor> fd, 77 scoped_ptr<dbus::FileDescriptor> fd,
77 const BluetoothProfileServiceProvider::Delegate::Options& options, 78 const bluez::BluetoothProfileServiceProvider::Delegate::Options& options,
78 const ConfirmationCallback& callback) override; 79 const ConfirmationCallback& callback) override;
79 void RequestDisconnection(const dbus::ObjectPath& device_path, 80 void RequestDisconnection(const dbus::ObjectPath& device_path,
80 const ConfirmationCallback& callback) override; 81 const ConfirmationCallback& callback) override;
81 void Cancel() override; 82 void Cancel() override;
82 83
83 // Called by dbus:: on completion of the D-Bus method to unregister a profile. 84 // Called by dbus:: on completion of the D-Bus method to unregister a profile.
84 void OnUnregisterProfileError(const base::Closure& unregistered_callback, 85 void OnUnregisterProfileError(const base::Closure& unregistered_callback,
85 const std::string& error_name, 86 const std::string& error_name,
86 const std::string& error_message); 87 const std::string& error_message);
87 88
88 // List of delegates which this profile is multiplexing to. 89 // List of delegates which this profile is multiplexing to.
89 std::map<std::string, BluetoothProfileServiceProvider::Delegate*> delegates_; 90 std::map<std::string, bluez::BluetoothProfileServiceProvider::Delegate*>
91 delegates_;
90 92
91 // The UUID that this profile represents. 93 // The UUID that this profile represents.
92 const device::BluetoothUUID& uuid_; 94 const device::BluetoothUUID& uuid_;
93 95
94 // Registered dbus object path for this profile. 96 // Registered dbus object path for this profile.
95 dbus::ObjectPath object_path_; 97 dbus::ObjectPath object_path_;
96 98
97 // Profile dbus object for receiving profile method calls from BlueZ 99 // Profile dbus object for receiving profile method calls from BlueZ
98 scoped_ptr<BluetoothProfileServiceProvider> profile_; 100 scoped_ptr<bluez::BluetoothProfileServiceProvider> profile_;
99 101
100 // Note: This should remain the last member so it'll be destroyed and 102 // Note: This should remain the last member so it'll be destroyed and
101 // invalidate its weak pointers before any other members are destroyed. 103 // invalidate its weak pointers before any other members are destroyed.
102 base::WeakPtrFactory<BluetoothAdapterProfileChromeOS> weak_ptr_factory_; 104 base::WeakPtrFactory<BluetoothAdapterProfileChromeOS> weak_ptr_factory_;
103 105
104 DISALLOW_COPY_AND_ASSIGN(BluetoothAdapterProfileChromeOS); 106 DISALLOW_COPY_AND_ASSIGN(BluetoothAdapterProfileChromeOS);
105 }; 107 };
106 108
107 } // namespace chromeos 109 } // namespace chromeos
108 110
109 #endif // DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_PROFILE_CHROMEOS_H_ 111 #endif // DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_PROFILE_CHROMEOS_H_
OLDNEW
« no previous file with comments | « device/bluetooth/bluetooth_adapter_chromeos.cc ('k') | device/bluetooth/bluetooth_adapter_profile_chromeos.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698