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

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

Issue 1119113002: bluetooth: Initial JNI setup for device/bluetooth. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Merge GN files, removes circular includes. Created 5 years, 7 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/memory/weak_ptr.h" 9 #include "base/memory/weak_ptr.h"
9 #include "device/bluetooth/bluetooth_adapter.h" 10 #include "device/bluetooth/bluetooth_adapter.h"
10 11
11 namespace base { 12 namespace base {
12 class SequencedTaskRunner; 13 class SequencedTaskRunner;
13 } // namespace base 14 } // namespace base
14 15
15 namespace device { 16 namespace device {
16 17
17 // The BluetoothAdapterAndroid class implements BluetoothAdapter for the 18 // The BluetoothAdapterAndroid class implements BluetoothAdapter for the
18 // Android platform. 19 // Android platform.
19 class DEVICE_BLUETOOTH_EXPORT BluetoothAdapterAndroid final 20 class DEVICE_BLUETOOTH_EXPORT BluetoothAdapterAndroid final
20 : public BluetoothAdapter { 21 : public BluetoothAdapter {
21 public: 22 public:
22 static base::WeakPtr<BluetoothAdapter> CreateAdapter(); 23 // Create a BluetoothAdapterAndroid instance.
24 static base::WeakPtr<BluetoothAdapterAndroid> CreateAdapter();
25
26 // Register C++ methods exposed to Java using JNI.
27 static bool RegisterJNI(JNIEnv* env);
28
29 // True if this app has android permissions necessary for Bluetooth.
30 bool HasBluetoothPermission() const;
23 31
24 // BluetoothAdapter: 32 // BluetoothAdapter:
25 std::string GetAddress() const override; 33 std::string GetAddress() const override;
26 std::string GetName() const override; 34 std::string GetName() const override;
27 void SetName(const std::string& name, 35 void SetName(const std::string& name,
28 const base::Closure& callback, 36 const base::Closure& callback,
29 const ErrorCallback& error_callback) override; 37 const ErrorCallback& error_callback) override;
30 bool IsInitialized() const override; 38 bool IsInitialized() const override;
31 bool IsPresent() const override; 39 bool IsPresent() const override;
32 bool IsPowered() const override; 40 bool IsPowered() const override;
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 const ErrorCallback& error_callback) override; 75 const ErrorCallback& error_callback) override;
68 void RemoveDiscoverySession(BluetoothDiscoveryFilter* discovery_filter, 76 void RemoveDiscoverySession(BluetoothDiscoveryFilter* discovery_filter,
69 const base::Closure& callback, 77 const base::Closure& callback,
70 const ErrorCallback& error_callback) override; 78 const ErrorCallback& error_callback) override;
71 void SetDiscoveryFilter(scoped_ptr<BluetoothDiscoveryFilter> discovery_filter, 79 void SetDiscoveryFilter(scoped_ptr<BluetoothDiscoveryFilter> discovery_filter,
72 const base::Closure& callback, 80 const base::Closure& callback,
73 const ErrorCallback& error_callback) override; 81 const ErrorCallback& error_callback) override;
74 void RemovePairingDelegateInternal( 82 void RemovePairingDelegateInternal(
75 BluetoothDevice::PairingDelegate* pairing_delegate) override; 83 BluetoothDevice::PairingDelegate* pairing_delegate) override;
76 84
85 // Java object org.chromium.device.bluetooth.BluetoothAdapter.
86 base::android::ScopedJavaGlobalRef<jobject> j_bluetooth_adapter_;
87
77 std::string address_; 88 std::string address_;
78 std::string name_; 89 std::string name_;
79 90
80 // Note: This should remain the last member so it'll be destroyed and 91 // Note: This should remain the last member so it'll be destroyed and
81 // invalidate its weak pointers before any other members are destroyed. 92 // invalidate its weak pointers before any other members are destroyed.
82 base::WeakPtrFactory<BluetoothAdapterAndroid> weak_ptr_factory_; 93 base::WeakPtrFactory<BluetoothAdapterAndroid> weak_ptr_factory_;
83 94
84 DISALLOW_COPY_AND_ASSIGN(BluetoothAdapterAndroid); 95 DISALLOW_COPY_AND_ASSIGN(BluetoothAdapterAndroid);
85 }; 96 };
86 97
87 } // namespace device 98 } // namespace device
88 99
89 #endif // DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_ANDROID_H_ 100 #endif // DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_ANDROID_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698