OLD | NEW |
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_ANDROID_H_ | 5 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_ANDROID_H_ |
6 #define DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_ANDROID_H_ | 6 #define DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_ANDROID_H_ |
7 | 7 |
8 #include "base/android/jni_android.h" | 8 #include "base/android/jni_android.h" |
9 #include "base/android/scoped_java_ref.h" | 9 #include "base/android/scoped_java_ref.h" |
10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
11 #include "device/bluetooth/bluetooth_adapter.h" | 11 #include "device/bluetooth/bluetooth_adapter.h" |
12 | 12 |
13 namespace base { | 13 namespace base { |
14 class SequencedTaskRunner; | 14 class SequencedTaskRunner; |
15 } // namespace base | 15 } // namespace base |
16 | 16 |
17 using base::android::ScopedJavaLocalRef; | 17 using base::android::ScopedJavaLocalRef; |
18 | 18 |
19 namespace device { | 19 namespace device { |
20 | 20 |
21 // BluetoothAdapterAndroid, along with the Java class | 21 // BluetoothAdapterAndroid, along with the Java class |
22 // org.chromium.device.bluetooth.BluetoothAdapter, implement BluetoothAdapter. | 22 // org.chromium.device.bluetooth.BluetoothAdapter, implement BluetoothAdapter. |
23 // | 23 // |
24 // The GATT Profile over Low Energy is supported, but not Classic Bluetooth at | |
25 // this time. LE GATT support has been initially built out to support Web | |
26 // Bluetooth, which does not need other Bluetooth features. There is no | |
27 // technical reason they can not be supported should a need arrise. | |
28 // | |
29 // BluetoothAdapterAndroid is reference counted, and owns the lifetime of the | 24 // BluetoothAdapterAndroid is reference counted, and owns the lifetime of the |
30 // Java class BluetoothAdapter via j_adapter_. | 25 // Java class BluetoothAdapter via j_adapter_. |
31 class DEVICE_BLUETOOTH_EXPORT BluetoothAdapterAndroid final | 26 class DEVICE_BLUETOOTH_EXPORT BluetoothAdapterAndroid final |
32 : public BluetoothAdapter { | 27 : public BluetoothAdapter { |
33 public: | 28 public: |
34 // Create a BluetoothAdapterAndroid instance. | 29 // Create a BluetoothAdapterAndroid instance. |
35 // | 30 // |
36 // |java_bluetooth_adapter_wrapper| is optional. If it is NULL the adapter | 31 // |java_bluetooth_adapter_wrapper| is optional. If it is NULL the adapter |
37 // will return false for |IsPresent()| and not be functional. | 32 // will return false for |IsPresent()| and not be functional. |
38 // | 33 // |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 const CreateServiceErrorCallback& error_callback) override; | 68 const CreateServiceErrorCallback& error_callback) override; |
74 void RegisterAudioSink( | 69 void RegisterAudioSink( |
75 const BluetoothAudioSink::Options& options, | 70 const BluetoothAudioSink::Options& options, |
76 const AcquiredCallback& callback, | 71 const AcquiredCallback& callback, |
77 const BluetoothAudioSink::ErrorCallback& error_callback) override; | 72 const BluetoothAudioSink::ErrorCallback& error_callback) override; |
78 void RegisterAdvertisement( | 73 void RegisterAdvertisement( |
79 scoped_ptr<BluetoothAdvertisement::Data> advertisement_data, | 74 scoped_ptr<BluetoothAdvertisement::Data> advertisement_data, |
80 const CreateAdvertisementCallback& callback, | 75 const CreateAdvertisementCallback& callback, |
81 const CreateAdvertisementErrorCallback& error_callback) override; | 76 const CreateAdvertisementErrorCallback& error_callback) override; |
82 | 77 |
83 // Handles a scan error event by invalidating all discovery sessions. | |
84 void OnScanFailed(JNIEnv* env, jobject obj); | |
85 | |
86 protected: | 78 protected: |
87 BluetoothAdapterAndroid(); | 79 BluetoothAdapterAndroid(); |
88 ~BluetoothAdapterAndroid() override; | 80 ~BluetoothAdapterAndroid() override; |
89 | 81 |
90 // BluetoothAdapter: | 82 // BluetoothAdapter: |
91 void AddDiscoverySession(BluetoothDiscoveryFilter* discovery_filter, | 83 void AddDiscoverySession(BluetoothDiscoveryFilter* discovery_filter, |
92 const base::Closure& callback, | 84 const base::Closure& callback, |
93 const ErrorCallback& error_callback) override; | 85 const ErrorCallback& error_callback) override; |
94 void RemoveDiscoverySession(BluetoothDiscoveryFilter* discovery_filter, | 86 void RemoveDiscoverySession(BluetoothDiscoveryFilter* discovery_filter, |
95 const base::Closure& callback, | 87 const base::Closure& callback, |
(...skipping 13 matching lines...) Expand all Loading... |
109 // Note: This should remain the last member so it'll be destroyed and | 101 // Note: This should remain the last member so it'll be destroyed and |
110 // invalidate its weak pointers before any other members are destroyed. | 102 // invalidate its weak pointers before any other members are destroyed. |
111 base::WeakPtrFactory<BluetoothAdapterAndroid> weak_ptr_factory_; | 103 base::WeakPtrFactory<BluetoothAdapterAndroid> weak_ptr_factory_; |
112 | 104 |
113 DISALLOW_COPY_AND_ASSIGN(BluetoothAdapterAndroid); | 105 DISALLOW_COPY_AND_ASSIGN(BluetoothAdapterAndroid); |
114 }; | 106 }; |
115 | 107 |
116 } // namespace device | 108 } // namespace device |
117 | 109 |
118 #endif // DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_ANDROID_H_ | 110 #endif // DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_ANDROID_H_ |
OLD | NEW |