OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_DISCOVERY_SESSION_H_ | 5 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_DISCOVERY_SESSION_H_ |
6 #define DEVICE_BLUETOOTH_BLUETOOTH_DISCOVERY_SESSION_H_ | 6 #define DEVICE_BLUETOOTH_BLUETOOTH_DISCOVERY_SESSION_H_ |
7 | 7 |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
11 #include "device/bluetooth/bluetooth_export.h" | |
12 | 11 |
13 namespace device { | 12 namespace device { |
14 | 13 |
15 class BluetoothAdapter; | 14 class BluetoothAdapter; |
16 | 15 |
17 // BluetoothDiscoverySession represents a current active or inactive device | 16 // BluetoothDiscoverySession represents a current active or inactive device |
18 // discovery session. Instances of this class are obtained by calling | 17 // discovery session. Instances of this class are obtained by calling |
19 // BluetoothAdapter::StartDiscoverySession. The Bluetooth adapter will be | 18 // BluetoothAdapter::StartDiscoverySession. The Bluetooth adapter will be |
20 // constantly searching for nearby devices, as long as at least one instance | 19 // constantly searching for nearby devices, as long as at least one instance |
21 // of an active BluetoothDiscoverySession exists. A BluetoothDiscoverySession is | 20 // of an active BluetoothDiscoverySession exists. A BluetoothDiscoverySession is |
22 // considered active, as long as the adapter is discovering AND the owner of the | 21 // considered active, as long as the adapter is discovering AND the owner of the |
23 // instance has not called BluetoothDiscoverySession::Stop. A | 22 // instance has not called BluetoothDiscoverySession::Stop. A |
24 // BluetoothDiscoverySession might unexpectedly become inactive, if the adapter | 23 // BluetoothDiscoverySession might unexpectedly become inactive, if the adapter |
25 // unexpectedly stops discovery. Users can implement the | 24 // unexpectedly stops discovery. Users can implement the |
26 // AdapterDiscoveringChanged method of the BluetoothAdapter::Observer interface | 25 // AdapterDiscoveringChanged method of the BluetoothAdapter::Observer interface |
27 // to be notified of such a change and promptly request a new | 26 // to be notified of such a change and promptly request a new |
28 // BluetoothDiscoverySession if their existing sessions have become inactive. | 27 // BluetoothDiscoverySession if their existing sessions have become inactive. |
29 class DEVICE_BLUETOOTH_EXPORT BluetoothDiscoverySession { | 28 class BluetoothDiscoverySession { |
30 public: | 29 public: |
31 // The ErrorCallback is used by methods to asynchronously report errors. | 30 // The ErrorCallback is used by methods to asynchronously report errors. |
32 typedef base::Closure ErrorCallback; | 31 typedef base::Closure ErrorCallback; |
33 | 32 |
34 // Destructor automatically terminates the discovery session. If this | 33 // Destructor automatically terminates the discovery session. If this |
35 // results in a call to the underlying system to stop device discovery | 34 // results in a call to the underlying system to stop device discovery |
36 // (i.e. this instance represents the last active discovery session), | 35 // (i.e. this instance represents the last active discovery session), |
37 // the call may not always succeed. To be notified of such failures, | 36 // the call may not always succeed. To be notified of such failures, |
38 // users are highly encouraged to call BluetoothDiscoverySession::Stop, | 37 // users are highly encouraged to call BluetoothDiscoverySession::Stop, |
39 // instead of relying on the destructor. | 38 // instead of relying on the destructor. |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 // Note: This should remain the last member so it'll be destroyed and | 80 // Note: This should remain the last member so it'll be destroyed and |
82 // invalidate its weak pointers before any other members are destroyed. | 81 // invalidate its weak pointers before any other members are destroyed. |
83 base::WeakPtrFactory<BluetoothDiscoverySession> weak_ptr_factory_; | 82 base::WeakPtrFactory<BluetoothDiscoverySession> weak_ptr_factory_; |
84 | 83 |
85 DISALLOW_COPY_AND_ASSIGN(BluetoothDiscoverySession); | 84 DISALLOW_COPY_AND_ASSIGN(BluetoothDiscoverySession); |
86 }; | 85 }; |
87 | 86 |
88 } // namespace device | 87 } // namespace device |
89 | 88 |
90 #endif // DEVICE_BLUETOOTH_BLUETOOTH_DISCOVERY_SESSION_H_ | 89 #endif // DEVICE_BLUETOOTH_BLUETOOTH_DISCOVERY_SESSION_H_ |
OLD | NEW |