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

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

Issue 1150833002: bluetooth: android: Initial Low Energy Discovery Sessions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bta-manifest-
Patch Set: Add tests Created 5 years, 5 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 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 //
24 // BluetoothAdapterAndroid is reference counted, and owns the lifetime of the 29 // BluetoothAdapterAndroid is reference counted, and owns the lifetime of the
25 // Java class BluetoothAdapter via j_adapter_. 30 // Java class BluetoothAdapter via j_adapter_.
26 class DEVICE_BLUETOOTH_EXPORT BluetoothAdapterAndroid final 31 class DEVICE_BLUETOOTH_EXPORT BluetoothAdapterAndroid final
27 : public BluetoothAdapter { 32 : public BluetoothAdapter {
28 public: 33 public:
29 // Create a BluetoothAdapterAndroid instance. 34 // Create a BluetoothAdapterAndroid instance.
30 // 35 //
31 // |java_bluetooth_adapter_wrapper| is optional. If it is NULL the adapter 36 // |java_bluetooth_adapter_wrapper| is optional. If it is NULL the adapter
32 // will return false for |IsPresent()| and not be functional. 37 // will return false for |IsPresent()| and not be functional.
33 // 38 //
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 const CreateServiceErrorCallback& error_callback) override; 73 const CreateServiceErrorCallback& error_callback) override;
69 void RegisterAudioSink( 74 void RegisterAudioSink(
70 const BluetoothAudioSink::Options& options, 75 const BluetoothAudioSink::Options& options,
71 const AcquiredCallback& callback, 76 const AcquiredCallback& callback,
72 const BluetoothAudioSink::ErrorCallback& error_callback) override; 77 const BluetoothAudioSink::ErrorCallback& error_callback) override;
73 void RegisterAdvertisement( 78 void RegisterAdvertisement(
74 scoped_ptr<BluetoothAdvertisement::Data> advertisement_data, 79 scoped_ptr<BluetoothAdvertisement::Data> advertisement_data,
75 const CreateAdvertisementCallback& callback, 80 const CreateAdvertisementCallback& callback,
76 const CreateAdvertisementErrorCallback& error_callback) override; 81 const CreateAdvertisementErrorCallback& error_callback) override;
77 82
83 // Handles a scan error event by invalidating all discovery sessions.
84 void OnScanFailed(JNIEnv* env, jobject obj);
85
78 protected: 86 protected:
79 BluetoothAdapterAndroid(); 87 BluetoothAdapterAndroid();
80 ~BluetoothAdapterAndroid() override; 88 ~BluetoothAdapterAndroid() override;
81 89
82 // BluetoothAdapter: 90 // BluetoothAdapter:
83 void AddDiscoverySession(BluetoothDiscoveryFilter* discovery_filter, 91 void AddDiscoverySession(BluetoothDiscoveryFilter* discovery_filter,
84 const base::Closure& callback, 92 const base::Closure& callback,
85 const ErrorCallback& error_callback) override; 93 const ErrorCallback& error_callback) override;
86 void RemoveDiscoverySession(BluetoothDiscoveryFilter* discovery_filter, 94 void RemoveDiscoverySession(BluetoothDiscoveryFilter* discovery_filter,
87 const base::Closure& callback, 95 const base::Closure& callback,
(...skipping 13 matching lines...) Expand all
101 // Note: This should remain the last member so it'll be destroyed and 109 // Note: This should remain the last member so it'll be destroyed and
102 // invalidate its weak pointers before any other members are destroyed. 110 // invalidate its weak pointers before any other members are destroyed.
103 base::WeakPtrFactory<BluetoothAdapterAndroid> weak_ptr_factory_; 111 base::WeakPtrFactory<BluetoothAdapterAndroid> weak_ptr_factory_;
104 112
105 DISALLOW_COPY_AND_ASSIGN(BluetoothAdapterAndroid); 113 DISALLOW_COPY_AND_ASSIGN(BluetoothAdapterAndroid);
106 }; 114 };
107 115
108 } // namespace device 116 } // namespace device
109 117
110 #endif // DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_ANDROID_H_ 118 #endif // DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_ANDROID_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698