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

Unified Diff: device/bluetooth/bluetooth_adapter.h

Issue 188473002: device/bluetooth: Remove BluetoothAdapter::Start|StopDiscovering. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed BluetoothAdapterWinTest compile errors. Created 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | device/bluetooth/bluetooth_adapter.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: device/bluetooth/bluetooth_adapter.h
diff --git a/device/bluetooth/bluetooth_adapter.h b/device/bluetooth/bluetooth_adapter.h
index badcccdec41e275614ac56a4ed91bdc2c6d98f3b..e713ff496befeeecac963358e8b3a465bdf99019 100644
--- a/device/bluetooth/bluetooth_adapter.h
+++ b/device/bluetooth/bluetooth_adapter.h
@@ -145,34 +145,22 @@ class BluetoothAdapter : public base::RefCounted<BluetoothAdapter> {
// The returned BluetoothDiscoverySession is owned by the caller and it's the
// owner's responsibility to properly clean it up and stop the session when
// device discovery is no longer needed.
+ //
+ // If clients desire device discovery to run, they should always call this
+ // method and never make it conditional on the value of IsDiscovering(), as
+ // another client might cause discovery to stop unexpectedly. Hence, clients
+ // should always obtain a BluetoothDiscoverySession and call
+ // BluetoothDiscoverySession::Stop when done. When this method gets called,
+ // device discovery may actually be in progress. Clients can call GetDevices()
+ // and check for those with IsPaired() as false to obtain the list of devices
+ // that have been discovered so far. Otherwise, clients can be notified of all
+ // new and lost devices can by implementing the Observer methods "DeviceAdded"
+ // and "DeviceRemoved".
typedef base::Callback<void(scoped_ptr<BluetoothDiscoverySession>)>
DiscoverySessionCallback;
virtual void StartDiscoverySession(const DiscoverySessionCallback& callback,
const ErrorCallback& error_callback);
- // DEPRECATED: Use StartDiscoverySession instead.
- // Requests that the adapter begin discovering new devices, code must
- // always call this method if they require the adapter be in discovery
- // and should not make it conditional on the value of IsDiscovering()
- // as other adapter users may be making the same request. Code must also
- // call StopDiscovering() when done. On success |callback| will be called,
- // on failure |error_callback| will be called instead.
- //
- // Since discovery may already be in progress when this method is called,
- // callers should retrieve the current set of discovered devices by calling
- // GetDevices() and checking for those with IsPaired() as false.
- virtual void StartDiscovering(const base::Closure& callback,
- const ErrorCallback& error_callback);
-
- // DEPRECATED: Use BluetoothDiscoverySession::Stop instead.
- // Requests that an earlier call to StartDiscovering() be cancelled; the
- // adapter may not actually cease discovering devices if other callers
- // have called StartDiscovering() and not yet called this method. On
- // success |callback| will be called, on failure |error_callback| will be
- // called instead.
- virtual void StopDiscovering(const base::Closure& callback,
- const ErrorCallback& error_callback);
-
// Requests the list of devices from the adapter, all are returned
// including those currently connected and those paired. Use the
// returned device pointers to determine which they are.
@@ -275,13 +263,10 @@ class BluetoothAdapter : public base::RefCounted<BluetoothAdapter> {
void MarkDiscoverySessionsAsInactive();
// Removes |discovery_session| from |discovery_sessions_|, if its in there.
- // Called by DiscoverySession when an instance is destroyed.
- void DiscoverySessionDestroyed(BluetoothDiscoverySession* discovery_session);
-
- // List of all DiscoverySession objects. We keep raw pointers, with the
- // assumption that a DiscoverySession will remove itself from this list when
- // it gets destroyed.
- std::set<BluetoothDiscoverySession*> discovery_sessions_;
+ // Called by DiscoverySession when an instance is destroyed or becomes
+ // inactive.
+ void DiscoverySessionBecameInactive(
+ BluetoothDiscoverySession* discovery_session);
// Devices paired with, connected to, discovered by, or visible to the
// adapter. The key is the Bluetooth address of the device and the value
@@ -296,6 +281,14 @@ class BluetoothAdapter : public base::RefCounted<BluetoothAdapter> {
std::list<PairingDelegatePair> pairing_delegates_;
private:
+ // List of active DiscoverySession objects. This is used to notify sessions to
+ // become inactive in case of an unexpected change to the adapter discovery
+ // state. We keep raw pointers, with the invariant that a DiscoverySession
+ // will remove itself from this list when it gets destroyed or becomes
+ // inactive by calling DiscoverySessionBecameInactive(), hence no pointers to
+ // deallocated sessions are kept.
+ std::set<BluetoothDiscoverySession*> discovery_sessions_;
+
// Note: This should remain the last member so it'll be destroyed and
// invalidate its weak pointers before any other members are destroyed.
base::WeakPtrFactory<BluetoothAdapter> weak_ptr_factory_;
« no previous file with comments | « no previous file | device/bluetooth/bluetooth_adapter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698