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

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

Issue 2031743005: Remove use of deprecated MessageLoop methods in device. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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_remote_gatt_descriptor_android.h" 5 #include "device/bluetooth/bluetooth_remote_gatt_descriptor_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/logging.h" 14 #include "base/logging.h"
14 #include "base/message_loop/message_loop.h" 15 #include "base/single_thread_task_runner.h"
16 #include "base/threading/thread_task_runner_handle.h"
15 #include "device/bluetooth/bluetooth_gatt_notify_session_android.h" 17 #include "device/bluetooth/bluetooth_gatt_notify_session_android.h"
16 #include "device/bluetooth/bluetooth_remote_gatt_service_android.h" 18 #include "device/bluetooth/bluetooth_remote_gatt_service_android.h"
17 #include "jni/ChromeBluetoothRemoteGattDescriptor_jni.h" 19 #include "jni/ChromeBluetoothRemoteGattDescriptor_jni.h"
18 20
19 using base::android::AttachCurrentThread; 21 using base::android::AttachCurrentThread;
20 22
21 namespace device { 23 namespace device {
22 24
23 // static 25 // static
24 std::unique_ptr<BluetoothRemoteGattDescriptorAndroid> 26 std::unique_ptr<BluetoothRemoteGattDescriptorAndroid>
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 BluetoothRemoteGattCharacteristic::Permissions 81 BluetoothRemoteGattCharacteristic::Permissions
80 BluetoothRemoteGattDescriptorAndroid::GetPermissions() const { 82 BluetoothRemoteGattDescriptorAndroid::GetPermissions() const {
81 NOTIMPLEMENTED(); 83 NOTIMPLEMENTED();
82 return 0; 84 return 0;
83 } 85 }
84 86
85 void BluetoothRemoteGattDescriptorAndroid::ReadRemoteDescriptor( 87 void BluetoothRemoteGattDescriptorAndroid::ReadRemoteDescriptor(
86 const ValueCallback& callback, 88 const ValueCallback& callback,
87 const ErrorCallback& error_callback) { 89 const ErrorCallback& error_callback) {
88 if (read_pending_ || write_pending_) { 90 if (read_pending_ || write_pending_) {
89 base::MessageLoop::current()->PostTask( 91 base::ThreadTaskRunnerHandle::Get()->PostTask(
90 FROM_HERE, 92 FROM_HERE,
91 base::Bind(error_callback, 93 base::Bind(error_callback,
92 BluetoothRemoteGattService::GATT_ERROR_IN_PROGRESS)); 94 BluetoothRemoteGattService::GATT_ERROR_IN_PROGRESS));
93 return; 95 return;
94 } 96 }
95 97
96 if (!Java_ChromeBluetoothRemoteGattDescriptor_readRemoteDescriptor( 98 if (!Java_ChromeBluetoothRemoteGattDescriptor_readRemoteDescriptor(
97 AttachCurrentThread(), j_descriptor_.obj())) { 99 AttachCurrentThread(), j_descriptor_.obj())) {
98 base::MessageLoop::current()->PostTask( 100 base::ThreadTaskRunnerHandle::Get()->PostTask(
99 FROM_HERE, 101 FROM_HERE,
100 base::Bind(error_callback, 102 base::Bind(error_callback,
101 BluetoothRemoteGattServiceAndroid::GATT_ERROR_FAILED)); 103 BluetoothRemoteGattServiceAndroid::GATT_ERROR_FAILED));
102 return; 104 return;
103 } 105 }
104 106
105 read_pending_ = true; 107 read_pending_ = true;
106 read_callback_ = callback; 108 read_callback_ = callback;
107 read_error_callback_ = error_callback; 109 read_error_callback_ = error_callback;
108 } 110 }
109 111
110 void BluetoothRemoteGattDescriptorAndroid::WriteRemoteDescriptor( 112 void BluetoothRemoteGattDescriptorAndroid::WriteRemoteDescriptor(
111 const std::vector<uint8_t>& new_value, 113 const std::vector<uint8_t>& new_value,
112 const base::Closure& callback, 114 const base::Closure& callback,
113 const ErrorCallback& error_callback) { 115 const ErrorCallback& error_callback) {
114 if (read_pending_ || write_pending_) { 116 if (read_pending_ || write_pending_) {
115 base::MessageLoop::current()->PostTask( 117 base::ThreadTaskRunnerHandle::Get()->PostTask(
116 FROM_HERE, 118 FROM_HERE,
117 base::Bind(error_callback, 119 base::Bind(error_callback,
118 BluetoothRemoteGattService::GATT_ERROR_IN_PROGRESS)); 120 BluetoothRemoteGattService::GATT_ERROR_IN_PROGRESS));
119 return; 121 return;
120 } 122 }
121 123
122 JNIEnv* env = AttachCurrentThread(); 124 JNIEnv* env = AttachCurrentThread();
123 if (!Java_ChromeBluetoothRemoteGattDescriptor_writeRemoteDescriptor( 125 if (!Java_ChromeBluetoothRemoteGattDescriptor_writeRemoteDescriptor(
124 env, j_descriptor_.obj(), 126 env, j_descriptor_.obj(),
125 base::android::ToJavaByteArray(env, new_value).obj())) { 127 base::android::ToJavaByteArray(env, new_value).obj())) {
126 base::MessageLoop::current()->PostTask( 128 base::ThreadTaskRunnerHandle::Get()->PostTask(
127 FROM_HERE, 129 FROM_HERE,
128 base::Bind(error_callback, 130 base::Bind(error_callback,
129 BluetoothRemoteGattServiceAndroid::GATT_ERROR_FAILED)); 131 BluetoothRemoteGattServiceAndroid::GATT_ERROR_FAILED));
130 return; 132 return;
131 } 133 }
132 134
133 write_pending_ = true; 135 write_pending_ = true;
134 write_callback_ = callback; 136 write_callback_ = callback;
135 write_error_callback_ = error_callback; 137 write_error_callback_ = error_callback;
136 } 138 }
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 write_error_callback.Run( 181 write_error_callback.Run(
180 BluetoothRemoteGattServiceAndroid::GetGattErrorCode(status)); 182 BluetoothRemoteGattServiceAndroid::GetGattErrorCode(status));
181 } 183 }
182 } 184 }
183 185
184 BluetoothRemoteGattDescriptorAndroid::BluetoothRemoteGattDescriptorAndroid( 186 BluetoothRemoteGattDescriptorAndroid::BluetoothRemoteGattDescriptorAndroid(
185 const std::string& instance_id) 187 const std::string& instance_id)
186 : instance_id_(instance_id) {} 188 : instance_id_(instance_id) {}
187 189
188 } // namespace device 190 } // namespace device
OLDNEW
« no previous file with comments | « device/bluetooth/bluetooth_remote_gatt_characteristic_android.cc ('k') | device/bluetooth/bluez/bluetooth_socket_bluez.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698