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

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

Issue 982593002: Fix BluetoothAdapterProfileChromeOS lifecycle management (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address nits, remove test debug logging Created 5 years, 9 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 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> 8 #include <map>
9 #include <queue> 9 #include <queue>
10 #include <string> 10 #include <string>
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 // successfully registered, |success_callback| will be called with a pointer 138 // successfully registered, |success_callback| will be called with a pointer
139 // to the profile which is managed by BluetoothAdapterChromeOS. On failure, 139 // to the profile which is managed by BluetoothAdapterChromeOS. On failure,
140 // |error_callback| will be called. 140 // |error_callback| will be called.
141 void UseProfile(const device::BluetoothUUID& uuid, 141 void UseProfile(const device::BluetoothUUID& uuid,
142 const dbus::ObjectPath& device_path, 142 const dbus::ObjectPath& device_path,
143 const BluetoothProfileManagerClient::Options& options, 143 const BluetoothProfileManagerClient::Options& options,
144 BluetoothProfileServiceProvider::Delegate* delegate, 144 BluetoothProfileServiceProvider::Delegate* delegate,
145 const ProfileRegisteredCallback& success_callback, 145 const ProfileRegisteredCallback& success_callback,
146 const ErrorCompletionCallback& error_callback); 146 const ErrorCompletionCallback& error_callback);
147 147
148 // Releases the profile associated with |uuid| 148 // Release use of a profile by a device.
149 void ReleaseProfile(const device::BluetoothUUID& uuid); 149 void ReleaseProfile(const dbus::ObjectPath& device_path,
150 BluetoothAdapterProfileChromeOS* profile);
150 151
151 protected: 152 protected:
152 // BluetoothAdapter: 153 // BluetoothAdapter:
153 void RemovePairingDelegateInternal( 154 void RemovePairingDelegateInternal(
154 device::BluetoothDevice::PairingDelegate* pairing_delegate) override; 155 device::BluetoothDevice::PairingDelegate* pairing_delegate) override;
155 156
156 private: 157 private:
157 friend class base::DeleteHelper<BluetoothAdapterChromeOS>; 158 friend class base::DeleteHelper<BluetoothAdapterChromeOS>;
158 friend class BluetoothChromeOSTest; 159 friend class BluetoothChromeOSTest;
159 friend class BluetoothChromeOSTest_Shutdown_Test; 160 friend class BluetoothChromeOSTest_Shutdown_Test;
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 const std::string& error_message); 277 const std::string& error_message);
277 278
278 // Called by dbus:: on completion of the D-Bus method call to stop discovery. 279 // Called by dbus:: on completion of the D-Bus method call to stop discovery.
279 void OnStopDiscovery(const base::Closure& callback); 280 void OnStopDiscovery(const base::Closure& callback);
280 void OnStopDiscoveryError(const ErrorCallback& error_callback, 281 void OnStopDiscoveryError(const ErrorCallback& error_callback,
281 const std::string& error_name, 282 const std::string& error_name,
282 const std::string& error_message); 283 const std::string& error_message);
283 284
284 // Called by dbus:: on completion of the D-Bus method to register a profile. 285 // Called by dbus:: on completion of the D-Bus method to register a profile.
285 void OnRegisterProfile(const device::BluetoothUUID& uuid, 286 void OnRegisterProfile(const device::BluetoothUUID& uuid,
286 const dbus::ObjectPath& device_path, 287 scoped_ptr<BluetoothAdapterProfileChromeOS> profile);
287 BluetoothProfileServiceProvider::Delegate* delegate, 288
288 const ProfileRegisteredCallback& success_callback, 289 void SetProfileDelegate(const device::BluetoothUUID& uuid,
289 const ErrorCompletionCallback& error_callback);
290 bool SetProfileDelegate(const device::BluetoothUUID& uuid,
291 const dbus::ObjectPath& device_path, 290 const dbus::ObjectPath& device_path,
292 BluetoothProfileServiceProvider::Delegate* delegate, 291 BluetoothProfileServiceProvider::Delegate* delegate,
293 const ProfileRegisteredCallback& success_callback, 292 const ProfileRegisteredCallback& success_callback,
294 const ErrorCompletionCallback& error_callback); 293 const ErrorCompletionCallback& error_callback);
295 void OnRegisterProfileError(const device::BluetoothUUID& uuid, 294 void OnRegisterProfileError(const device::BluetoothUUID& uuid,
296 const ErrorCompletionCallback& error_callback,
297 const std::string& error_name, 295 const std::string& error_name,
298 const std::string& error_message); 296 const std::string& error_message);
299 297
298 // Called by BluetoothAdapterProfileChromeOS when no users of a profile
299 // remain.
300 void RemoveProfile(const device::BluetoothUUID& uuid);
301
300 // Processes the queued discovery requests. For each DiscoveryCallbackPair in 302 // Processes the queued discovery requests. For each DiscoveryCallbackPair in
301 // the queue, this method will try to add a new discovery session. This method 303 // the queue, this method will try to add a new discovery session. This method
302 // is called whenever a pending D-Bus call to start or stop discovery has 304 // is called whenever a pending D-Bus call to start or stop discovery has
303 // ended (with either success or failure). 305 // ended (with either success or failure).
304 void ProcessQueuedDiscoveryRequests(); 306 void ProcessQueuedDiscoveryRequests();
305 307
306 // Set in |Shutdown()|, makes IsPresent()| return false. 308 // Set in |Shutdown()|, makes IsPresent()| return false.
307 bool dbus_is_shutdown_; 309 bool dbus_is_shutdown_;
308 310
309 // Number of discovery sessions that have been added. 311 // Number of discovery sessions that have been added.
(...skipping 23 matching lines...) Expand all
333 // our own class as its delegate. 335 // our own class as its delegate.
334 scoped_ptr<BluetoothAgentServiceProvider> agent_; 336 scoped_ptr<BluetoothAgentServiceProvider> agent_;
335 337
336 // UI thread task runner and socket thread object used to create sockets. 338 // UI thread task runner and socket thread object used to create sockets.
337 scoped_refptr<base::SequencedTaskRunner> ui_task_runner_; 339 scoped_refptr<base::SequencedTaskRunner> ui_task_runner_;
338 scoped_refptr<device::BluetoothSocketThread> socket_thread_; 340 scoped_refptr<device::BluetoothSocketThread> socket_thread_;
339 341
340 // The profiles we have registered with the bluetooth daemon. 342 // The profiles we have registered with the bluetooth daemon.
341 std::map<device::BluetoothUUID, BluetoothAdapterProfileChromeOS*> profiles_; 343 std::map<device::BluetoothUUID, BluetoothAdapterProfileChromeOS*> profiles_;
342 344
345 // Callback pair for the profile registration queue.
346 typedef std::pair<base::Closure, ErrorCompletionCallback>
347 RegisterProfileCompletionPair;
348
349 // Queue of delegates waiting for a profile to register.
350 std::map<device::BluetoothUUID, std::vector<RegisterProfileCompletionPair>*>
351 profile_queues_;
352
343 // Note: This should remain the last member so it'll be destroyed and 353 // Note: This should remain the last member so it'll be destroyed and
344 // invalidate its weak pointers before any other members are destroyed. 354 // invalidate its weak pointers before any other members are destroyed.
345 base::WeakPtrFactory<BluetoothAdapterChromeOS> weak_ptr_factory_; 355 base::WeakPtrFactory<BluetoothAdapterChromeOS> weak_ptr_factory_;
346 356
347 DISALLOW_COPY_AND_ASSIGN(BluetoothAdapterChromeOS); 357 DISALLOW_COPY_AND_ASSIGN(BluetoothAdapterChromeOS);
348 }; 358 };
349 359
350 } // namespace chromeos 360 } // namespace chromeos
351 361
352 #endif // DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_CHROMEOS_H_ 362 #endif // DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_CHROMEOS_H_
OLDNEW
« no previous file with comments | « chromeos/dbus/fake_bluetooth_profile_manager_client.cc ('k') | device/bluetooth/bluetooth_adapter_chromeos.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698