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

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

Issue 2313413002: Pass JavaRef to Java methods in device/bluetooth. (Closed)
Patch Set: Switch comments to a different form that clang-format will fit in 80 chars Created 4 years, 3 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 #include "device/bluetooth/bluetooth_adapter_android.h" 5 #include "device/bluetooth/bluetooth_adapter_android.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/android/jni_android.h" 9 #include "base/android/jni_android.h"
10 #include "base/android/jni_array.h" 10 #include "base/android/jni_array.h"
11 #include "base/android/jni_string.h" 11 #include "base/android/jni_string.h"
12 #include "base/bind.h" 12 #include "base/bind.h"
13 #include "base/location.h" 13 #include "base/location.h"
14 #include "base/sequenced_task_runner.h" 14 #include "base/sequenced_task_runner.h"
15 #include "base/single_thread_task_runner.h" 15 #include "base/single_thread_task_runner.h"
16 #include "base/threading/thread_task_runner_handle.h" 16 #include "base/threading/thread_task_runner_handle.h"
17 #include "device/bluetooth/android/wrappers.h" 17 #include "device/bluetooth/android/wrappers.h"
18 #include "device/bluetooth/bluetooth_advertisement.h" 18 #include "device/bluetooth/bluetooth_advertisement.h"
19 #include "device/bluetooth/bluetooth_device_android.h" 19 #include "device/bluetooth/bluetooth_device_android.h"
20 #include "device/bluetooth/bluetooth_discovery_session_outcome.h" 20 #include "device/bluetooth/bluetooth_discovery_session_outcome.h"
21 #include "jni/ChromeBluetoothAdapter_jni.h" 21 #include "jni/ChromeBluetoothAdapter_jni.h"
22 22
23 using base::android::AttachCurrentThread; 23 using base::android::AttachCurrentThread;
24 using base::android::ConvertJavaStringToUTF8; 24 using base::android::ConvertJavaStringToUTF8;
25 using base::android::AppendJavaStringArrayToStringVector; 25 using base::android::AppendJavaStringArrayToStringVector;
26 using base::android::JavaParamRef; 26 using base::android::JavaParamRef;
27 using base::android::JavaRef;
27 28
28 namespace { 29 namespace {
29 // The poll interval in ms when there is no active discovery. This 30 // The poll interval in ms when there is no active discovery. This
30 // matches the max allowed advertisting interval for connectable 31 // matches the max allowed advertisting interval for connectable
31 // devices. 32 // devices.
32 enum { kPassivePollInterval = 11000 }; 33 enum { kPassivePollInterval = 11000 };
33 // The poll interval in ms when there is an active discovery. 34 // The poll interval in ms when there is an active discovery.
34 enum { kActivePollInterval = 1000 }; 35 enum { kActivePollInterval = 1000 };
35 // The delay in ms to wait before purging devices when a scan starts. 36 // The delay in ms to wait before purging devices when a scan starts.
36 enum { kPurgeDelay = 500 }; 37 enum { kPurgeDelay = 500 };
37 } 38 }
38 39
39 namespace device { 40 namespace device {
40 41
41 // static 42 // static
42 base::WeakPtr<BluetoothAdapter> BluetoothAdapter::CreateAdapter( 43 base::WeakPtr<BluetoothAdapter> BluetoothAdapter::CreateAdapter(
43 const InitCallback& init_callback) { 44 const InitCallback& init_callback) {
44 return BluetoothAdapterAndroid::Create( 45 return BluetoothAdapterAndroid::Create(
45 BluetoothAdapterWrapper_CreateWithDefaultAdapter().obj()); 46 BluetoothAdapterWrapper_CreateWithDefaultAdapter());
46 } 47 }
47 48
48 // static 49 // static
49 base::WeakPtr<BluetoothAdapterAndroid> BluetoothAdapterAndroid::Create( 50 base::WeakPtr<BluetoothAdapterAndroid> BluetoothAdapterAndroid::Create(
50 jobject bluetooth_adapter_wrapper) { // Java Type: bluetoothAdapterWrapper 51 const JavaRef<jobject>&
52 bluetooth_adapter_wrapper) { // Java Type: bluetoothAdapterWrapper
51 BluetoothAdapterAndroid* adapter = new BluetoothAdapterAndroid(); 53 BluetoothAdapterAndroid* adapter = new BluetoothAdapterAndroid();
52 54
53 adapter->j_adapter_.Reset(Java_ChromeBluetoothAdapter_create( 55 adapter->j_adapter_.Reset(Java_ChromeBluetoothAdapter_create(
54 AttachCurrentThread(), reinterpret_cast<intptr_t>(adapter), 56 AttachCurrentThread(), reinterpret_cast<intptr_t>(adapter),
55 bluetooth_adapter_wrapper)); 57 bluetooth_adapter_wrapper));
56 58
57 adapter->ui_task_runner_ = base::ThreadTaskRunnerHandle::Get(); 59 adapter->ui_task_runner_ = base::ThreadTaskRunnerHandle::Get();
58 60
59 return adapter->weak_ptr_factory_.GetWeakPtr(); 61 return adapter->weak_ptr_factory_.GetWeakPtr();
60 } 62 }
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 // TODO(scheib): Support filters crbug.com/490401 332 // TODO(scheib): Support filters crbug.com/490401
331 NOTIMPLEMENTED(); 333 NOTIMPLEMENTED();
332 error_callback.Run(UMABluetoothDiscoverySessionOutcome::NOT_IMPLEMENTED); 334 error_callback.Run(UMABluetoothDiscoverySessionOutcome::NOT_IMPLEMENTED);
333 } 335 }
334 336
335 void BluetoothAdapterAndroid::RemovePairingDelegateInternal( 337 void BluetoothAdapterAndroid::RemovePairingDelegateInternal(
336 device::BluetoothDevice::PairingDelegate* pairing_delegate) { 338 device::BluetoothDevice::PairingDelegate* pairing_delegate) {
337 } 339 }
338 340
339 } // namespace device 341 } // namespace device
OLDNEW
« no previous file with comments | « device/bluetooth/bluetooth_adapter_android.h ('k') | device/bluetooth/bluetooth_device_android.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698