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

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

Issue 868753006: Revert of Manage profiles in BluetoothAdapter on ChromeOS (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 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
« no previous file with comments | « device/bluetooth/bluetooth.gyp ('k') | device/bluetooth/bluetooth_adapter_chromeos.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_CHROMEOS_H_ 5 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_CHROMEOS_H_
6 #define DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_CHROMEOS_H_ 6 #define DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_CHROMEOS_H_
7 7
8 #include <map>
9 #include <queue> 8 #include <queue>
10 #include <string> 9 #include <string>
11 #include <utility> 10 #include <utility>
12 #include <vector> 11 #include <vector>
13 12
14 #include "base/memory/weak_ptr.h" 13 #include "base/memory/weak_ptr.h"
15 #include "base/sequenced_task_runner.h" 14 #include "base/sequenced_task_runner.h"
16 #include "chromeos/dbus/bluetooth_adapter_client.h" 15 #include "chromeos/dbus/bluetooth_adapter_client.h"
17 #include "chromeos/dbus/bluetooth_agent_service_provider.h" 16 #include "chromeos/dbus/bluetooth_agent_service_provider.h"
18 #include "chromeos/dbus/bluetooth_device_client.h" 17 #include "chromeos/dbus/bluetooth_device_client.h"
19 #include "chromeos/dbus/bluetooth_input_client.h" 18 #include "chromeos/dbus/bluetooth_input_client.h"
20 #include "chromeos/dbus/bluetooth_profile_manager_client.h"
21 #include "chromeos/dbus/bluetooth_profile_service_provider.h"
22 #include "dbus/object_path.h" 19 #include "dbus/object_path.h"
23 #include "device/bluetooth/bluetooth_adapter.h" 20 #include "device/bluetooth/bluetooth_adapter.h"
24 #include "device/bluetooth/bluetooth_audio_sink.h" 21 #include "device/bluetooth/bluetooth_audio_sink.h"
25 #include "device/bluetooth/bluetooth_device.h" 22 #include "device/bluetooth/bluetooth_device.h"
26 #include "device/bluetooth/bluetooth_export.h" 23 #include "device/bluetooth/bluetooth_export.h"
27 24
28 namespace device { 25 namespace device {
29 class BluetoothSocketThread; 26 class BluetoothSocketThread;
30 } // namespace device 27 } // namespace device
31 28
32 namespace chromeos { 29 namespace chromeos {
33 30
34 class BluetoothChromeOSTest; 31 class BluetoothChromeOSTest;
35 class BluetoothAdapterProfileChromeOS;
36 class BluetoothDeviceChromeOS; 32 class BluetoothDeviceChromeOS;
37 class BluetoothPairingChromeOS; 33 class BluetoothPairingChromeOS;
38 class BluetoothRemoteGattCharacteristicChromeOS; 34 class BluetoothRemoteGattCharacteristicChromeOS;
39 class BluetoothRemoteGattDescriptorChromeOS; 35 class BluetoothRemoteGattDescriptorChromeOS;
40 class BluetoothRemoteGattServiceChromeOS; 36 class BluetoothRemoteGattServiceChromeOS;
41 37
42 // The BluetoothAdapterChromeOS class implements BluetoothAdapter for the 38 // The BluetoothAdapterChromeOS class implements BluetoothAdapter for the
43 // Chrome OS platform. 39 // Chrome OS platform.
44 class DEVICE_BLUETOOTH_EXPORT BluetoothAdapterChromeOS 40 class DEVICE_BLUETOOTH_EXPORT BluetoothAdapterChromeOS
45 : public device::BluetoothAdapter, 41 : public device::BluetoothAdapter,
46 public chromeos::BluetoothAdapterClient::Observer, 42 public chromeos::BluetoothAdapterClient::Observer,
47 public chromeos::BluetoothDeviceClient::Observer, 43 public chromeos::BluetoothDeviceClient::Observer,
48 public chromeos::BluetoothInputClient::Observer, 44 public chromeos::BluetoothInputClient::Observer,
49 public chromeos::BluetoothAgentServiceProvider::Delegate { 45 public chromeos::BluetoothAgentServiceProvider::Delegate {
50 public: 46 public:
51 typedef base::Callback<void(const std::string& error_message)>
52 ErrorCompletionCallback;
53 typedef base::Callback<void(BluetoothAdapterProfileChromeOS* profile)>
54 ProfileRegisteredCallback;
55
56 static base::WeakPtr<BluetoothAdapter> CreateAdapter(); 47 static base::WeakPtr<BluetoothAdapter> CreateAdapter();
57 48
58 // BluetoothAdapter: 49 // BluetoothAdapter:
59 void Shutdown() override; 50 void Shutdown() override;
60 void DeleteOnCorrectThread() const override; 51 void DeleteOnCorrectThread() const override;
61 void AddObserver(device::BluetoothAdapter::Observer* observer) override; 52 void AddObserver(device::BluetoothAdapter::Observer* observer) override;
62 void RemoveObserver(device::BluetoothAdapter::Observer* observer) override; 53 void RemoveObserver(device::BluetoothAdapter::Observer* observer) override;
63 std::string GetAddress() const override; 54 std::string GetAddress() const override;
64 std::string GetName() const override; 55 std::string GetName() const override;
65 void SetName(const std::string& name, 56 void SetName(const std::string& name,
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 void NotifyGattCharacteristicValueChanged( 108 void NotifyGattCharacteristicValueChanged(
118 BluetoothRemoteGattCharacteristicChromeOS* characteristic, 109 BluetoothRemoteGattCharacteristicChromeOS* characteristic,
119 const std::vector<uint8>& value); 110 const std::vector<uint8>& value);
120 void NotifyGattDescriptorValueChanged( 111 void NotifyGattDescriptorValueChanged(
121 BluetoothRemoteGattDescriptorChromeOS* descriptor, 112 BluetoothRemoteGattDescriptorChromeOS* descriptor,
122 const std::vector<uint8>& value); 113 const std::vector<uint8>& value);
123 114
124 // Returns the object path of the adapter. 115 // Returns the object path of the adapter.
125 const dbus::ObjectPath& object_path() const { return object_path_; } 116 const dbus::ObjectPath& object_path() const { return object_path_; }
126 117
127 // Request a profile on the adapter for a custom service with a
128 // specific UUID for the device at |device_path| to be sent to |delegate|.
129 // If |device_path| is the empty string, incoming connections will be
130 // assigned to |delegate|. When the profile is
131 // successfully registered, |success_callback| will be called with a pointer
132 // to the profile which is managed by BluetoothAdapterChromeOS. On failure,
133 // |error_callback| will be called.
134 void UseProfile(const device::BluetoothUUID& uuid,
135 const dbus::ObjectPath& device_path,
136 const BluetoothProfileManagerClient::Options& options,
137 BluetoothProfileServiceProvider::Delegate* delegate,
138 const ProfileRegisteredCallback& success_callback,
139 const ErrorCompletionCallback& error_callback);
140
141 // Releases the profile associated with |uuid|
142 void ReleaseProfile(const device::BluetoothUUID& uuid);
143
144 protected: 118 protected:
145 // BluetoothAdapter: 119 // BluetoothAdapter:
146 void RemovePairingDelegateInternal( 120 void RemovePairingDelegateInternal(
147 device::BluetoothDevice::PairingDelegate* pairing_delegate) override; 121 device::BluetoothDevice::PairingDelegate* pairing_delegate) override;
148 122
149 private: 123 private:
150 friend class base::DeleteHelper<BluetoothAdapterChromeOS>; 124 friend class base::DeleteHelper<BluetoothAdapterChromeOS>;
151 friend class BluetoothChromeOSTest; 125 friend class BluetoothChromeOSTest;
152 126
153 // typedef for callback parameters that are passed to AddDiscoverySession 127 // typedef for callback parameters that are passed to AddDiscoverySession
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 const ErrorCallback& error_callback, 228 const ErrorCallback& error_callback,
255 const std::string& error_name, 229 const std::string& error_name,
256 const std::string& error_message); 230 const std::string& error_message);
257 231
258 // Called by dbus:: on completion of the D-Bus method call to stop discovery. 232 // Called by dbus:: on completion of the D-Bus method call to stop discovery.
259 void OnStopDiscovery(const base::Closure& callback); 233 void OnStopDiscovery(const base::Closure& callback);
260 void OnStopDiscoveryError(const ErrorCallback& error_callback, 234 void OnStopDiscoveryError(const ErrorCallback& error_callback,
261 const std::string& error_name, 235 const std::string& error_name,
262 const std::string& error_message); 236 const std::string& error_message);
263 237
264 // Called by dbus:: on completion of the D-Bus method to register a profile.
265 void OnRegisterProfile(const device::BluetoothUUID& uuid,
266 const dbus::ObjectPath& device_path,
267 BluetoothProfileServiceProvider::Delegate* delegate,
268 const ProfileRegisteredCallback& success_callback,
269 const ErrorCompletionCallback& error_callback);
270 bool SetProfileDelegate(const device::BluetoothUUID& uuid,
271 const dbus::ObjectPath& device_path,
272 BluetoothProfileServiceProvider::Delegate* delegate,
273 const ProfileRegisteredCallback& success_callback,
274 const ErrorCompletionCallback& error_callback);
275 void OnRegisterProfileError(const device::BluetoothUUID& uuid,
276 const ErrorCompletionCallback& error_callback,
277 const std::string& error_name,
278 const std::string& error_message);
279
280 // Processes the queued discovery requests. For each DiscoveryCallbackPair in 238 // Processes the queued discovery requests. For each DiscoveryCallbackPair in
281 // the queue, this method will try to add a new discovery session. This method 239 // the queue, this method will try to add a new discovery session. This method
282 // is called whenever a pending D-Bus call to start or stop discovery has 240 // is called whenever a pending D-Bus call to start or stop discovery has
283 // ended (with either success or failure). 241 // ended (with either success or failure).
284 void ProcessQueuedDiscoveryRequests(); 242 void ProcessQueuedDiscoveryRequests();
285 243
286 // Set in |Shutdown()|, makes IsPresent()| return false. 244 // Set in |Shutdown()|, makes IsPresent()| return false.
287 bool dbus_is_shutdown_; 245 bool dbus_is_shutdown_;
288 246
289 // Number of discovery sessions that have been added. 247 // Number of discovery sessions that have been added.
(...skipping 20 matching lines...) Expand all
310 ObserverList<device::BluetoothAdapter::Observer> observers_; 268 ObserverList<device::BluetoothAdapter::Observer> observers_;
311 269
312 // Instance of the D-Bus agent object used for pairing, initialized with 270 // Instance of the D-Bus agent object used for pairing, initialized with
313 // our own class as its delegate. 271 // our own class as its delegate.
314 scoped_ptr<BluetoothAgentServiceProvider> agent_; 272 scoped_ptr<BluetoothAgentServiceProvider> agent_;
315 273
316 // UI thread task runner and socket thread object used to create sockets. 274 // UI thread task runner and socket thread object used to create sockets.
317 scoped_refptr<base::SequencedTaskRunner> ui_task_runner_; 275 scoped_refptr<base::SequencedTaskRunner> ui_task_runner_;
318 scoped_refptr<device::BluetoothSocketThread> socket_thread_; 276 scoped_refptr<device::BluetoothSocketThread> socket_thread_;
319 277
320 // The profiles we have registered with the bluetooth daemon.
321 std::map<device::BluetoothUUID, BluetoothAdapterProfileChromeOS*> profiles_;
322
323 // Note: This should remain the last member so it'll be destroyed and 278 // Note: This should remain the last member so it'll be destroyed and
324 // invalidate its weak pointers before any other members are destroyed. 279 // invalidate its weak pointers before any other members are destroyed.
325 base::WeakPtrFactory<BluetoothAdapterChromeOS> weak_ptr_factory_; 280 base::WeakPtrFactory<BluetoothAdapterChromeOS> weak_ptr_factory_;
326 281
327 DISALLOW_COPY_AND_ASSIGN(BluetoothAdapterChromeOS); 282 DISALLOW_COPY_AND_ASSIGN(BluetoothAdapterChromeOS);
328 }; 283 };
329 284
330 } // namespace chromeos 285 } // namespace chromeos
331 286
332 #endif // DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_CHROMEOS_H_ 287 #endif // DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_CHROMEOS_H_
OLDNEW
« no previous file with comments | « device/bluetooth/bluetooth.gyp ('k') | device/bluetooth/bluetooth_adapter_chromeos.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698