Remove chromeos==0 blacklist for test_isolation_mode.
[chromium-blink-merge.git] / device / bluetooth / bluetooth_adapter_android.h
blobe0625920bbe2f5bac98293ce40acfdc08a783468
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
3 // found in the LICENSE file.
5 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_ANDROID_H_
6 #define DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_ANDROID_H_
8 #include "base/android/jni_android.h"
9 #include "base/android/scoped_java_ref.h"
10 #include "base/memory/weak_ptr.h"
11 #include "device/bluetooth/bluetooth_adapter.h"
13 namespace base {
14 class SequencedTaskRunner;
15 } // namespace base
17 using base::android::ScopedJavaLocalRef;
19 namespace device {
21 // BluetoothAdapterAndroid, along with the Java class
22 // org.chromium.device.bluetooth.BluetoothAdapter, implement BluetoothAdapter.
24 // BluetoothAdapterAndroid is reference counted, and owns the lifetime of the
25 // Java class BluetoothAdapter via j_adapter_.
26 class DEVICE_BLUETOOTH_EXPORT BluetoothAdapterAndroid final
27 : public BluetoothAdapter {
28 public:
29 // Create a BluetoothAdapterAndroid instance.
31 // |java_bluetooth_adapter_wrapper| is optional. If it is NULL the adapter
32 // will return false for |IsPresent()| and not be functional.
34 // The BluetoothAdapterAndroid instance will indirectly hold a Java reference
35 // to |java_bluetooth_adapter_wrapper|.
36 static base::WeakPtr<BluetoothAdapterAndroid> Create(
37 jobject java_bluetooth_adapter_wrapper);
39 // Register C++ methods exposed to Java using JNI.
40 static bool RegisterJNI(JNIEnv* env);
42 // BluetoothAdapter:
43 std::string GetAddress() const override;
44 std::string GetName() const override;
45 void SetName(const std::string& name,
46 const base::Closure& callback,
47 const ErrorCallback& error_callback) override;
48 bool IsInitialized() const override;
49 bool IsPresent() const override;
50 bool IsPowered() const override;
51 void SetPowered(bool powered,
52 const base::Closure& callback,
53 const ErrorCallback& error_callback) override;
54 bool IsDiscoverable() const override;
55 void SetDiscoverable(bool discoverable,
56 const base::Closure& callback,
57 const ErrorCallback& error_callback) override;
58 bool IsDiscovering() const override;
59 void CreateRfcommService(
60 const BluetoothUUID& uuid,
61 const ServiceOptions& options,
62 const CreateServiceCallback& callback,
63 const CreateServiceErrorCallback& error_callback) override;
64 void CreateL2capService(
65 const BluetoothUUID& uuid,
66 const ServiceOptions& options,
67 const CreateServiceCallback& callback,
68 const CreateServiceErrorCallback& error_callback) override;
69 void RegisterAudioSink(
70 const BluetoothAudioSink::Options& options,
71 const AcquiredCallback& callback,
72 const BluetoothAudioSink::ErrorCallback& error_callback) override;
73 void RegisterAdvertisement(
74 scoped_ptr<BluetoothAdvertisement::Data> advertisement_data,
75 const CreateAdvertisementCallback& callback,
76 const CreateAdvertisementErrorCallback& error_callback) override;
78 protected:
79 BluetoothAdapterAndroid();
80 ~BluetoothAdapterAndroid() override;
82 // BluetoothAdapter:
83 void AddDiscoverySession(BluetoothDiscoveryFilter* discovery_filter,
84 const base::Closure& callback,
85 const ErrorCallback& error_callback) override;
86 void RemoveDiscoverySession(BluetoothDiscoveryFilter* discovery_filter,
87 const base::Closure& callback,
88 const ErrorCallback& error_callback) override;
89 void SetDiscoveryFilter(scoped_ptr<BluetoothDiscoveryFilter> discovery_filter,
90 const base::Closure& callback,
91 const ErrorCallback& error_callback) override;
92 void RemovePairingDelegateInternal(
93 BluetoothDevice::PairingDelegate* pairing_delegate) override;
95 // Java object org.chromium.device.bluetooth.ChromeBluetoothAdapter.
96 base::android::ScopedJavaGlobalRef<jobject> j_adapter_;
98 std::string address_;
99 std::string name_;
101 // Note: This should remain the last member so it'll be destroyed and
102 // invalidate its weak pointers before any other members are destroyed.
103 base::WeakPtrFactory<BluetoothAdapterAndroid> weak_ptr_factory_;
105 DISALLOW_COPY_AND_ASSIGN(BluetoothAdapterAndroid);
108 } // namespace device
110 #endif // DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_ANDROID_H_