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

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

Issue 1898643002: Refactor device::BluetoothGattXXX classes to split into remote/local. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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"
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 67
68 bool BluetoothRemoteGattDescriptorAndroid::IsLocal() const { 68 bool BluetoothRemoteGattDescriptorAndroid::IsLocal() const {
69 return false; 69 return false;
70 } 70 }
71 71
72 const std::vector<uint8_t>& BluetoothRemoteGattDescriptorAndroid::GetValue() 72 const std::vector<uint8_t>& BluetoothRemoteGattDescriptorAndroid::GetValue()
73 const { 73 const {
74 return value_; 74 return value_;
75 } 75 }
76 76
77 BluetoothGattCharacteristic* 77 BluetoothRemoteGattCharacteristic*
78 BluetoothRemoteGattDescriptorAndroid::GetCharacteristic() const { 78 BluetoothRemoteGattDescriptorAndroid::GetCharacteristic() const {
79 NOTIMPLEMENTED(); 79 NOTIMPLEMENTED();
80 return nullptr; 80 return nullptr;
81 } 81 }
82 82
83 BluetoothGattCharacteristic::Permissions 83 BluetoothRemoteGattCharacteristic::Permissions
84 BluetoothRemoteGattDescriptorAndroid::GetPermissions() const { 84 BluetoothRemoteGattDescriptorAndroid::GetPermissions() const {
85 NOTIMPLEMENTED(); 85 NOTIMPLEMENTED();
86 return 0; 86 return 0;
87 } 87 }
88 88
89 void BluetoothRemoteGattDescriptorAndroid::ReadRemoteDescriptor( 89 void BluetoothRemoteGattDescriptorAndroid::ReadRemoteDescriptor(
90 const ValueCallback& callback, 90 const ValueCallback& callback,
91 const ErrorCallback& error_callback) { 91 const ErrorCallback& error_callback) {
92 if (read_pending_ || write_pending_) { 92 if (read_pending_ || write_pending_) {
93 base::MessageLoop::current()->PostTask( 93 base::MessageLoop::current()->PostTask(
94 FROM_HERE, base::Bind(error_callback, 94 FROM_HERE,
95 BluetoothGattService::GATT_ERROR_IN_PROGRESS)); 95 base::Bind(error_callback,
96 BluetoothRemoteGattService::GATT_ERROR_IN_PROGRESS));
96 return; 97 return;
97 } 98 }
98 99
99 if (!Java_ChromeBluetoothRemoteGattDescriptor_readRemoteDescriptor( 100 if (!Java_ChromeBluetoothRemoteGattDescriptor_readRemoteDescriptor(
100 AttachCurrentThread(), j_descriptor_.obj())) { 101 AttachCurrentThread(), j_descriptor_.obj())) {
101 base::MessageLoop::current()->PostTask( 102 base::MessageLoop::current()->PostTask(
102 FROM_HERE, 103 FROM_HERE,
103 base::Bind(error_callback, 104 base::Bind(error_callback,
104 BluetoothRemoteGattServiceAndroid::GATT_ERROR_FAILED)); 105 BluetoothRemoteGattServiceAndroid::GATT_ERROR_FAILED));
105 return; 106 return;
106 } 107 }
107 108
108 read_pending_ = true; 109 read_pending_ = true;
109 read_callback_ = callback; 110 read_callback_ = callback;
110 read_error_callback_ = error_callback; 111 read_error_callback_ = error_callback;
111 } 112 }
112 113
113 void BluetoothRemoteGattDescriptorAndroid::WriteRemoteDescriptor( 114 void BluetoothRemoteGattDescriptorAndroid::WriteRemoteDescriptor(
114 const std::vector<uint8_t>& new_value, 115 const std::vector<uint8_t>& new_value,
115 const base::Closure& callback, 116 const base::Closure& callback,
116 const ErrorCallback& error_callback) { 117 const ErrorCallback& error_callback) {
117 if (read_pending_ || write_pending_) { 118 if (read_pending_ || write_pending_) {
118 base::MessageLoop::current()->PostTask( 119 base::MessageLoop::current()->PostTask(
119 FROM_HERE, base::Bind(error_callback, 120 FROM_HERE,
120 BluetoothGattService::GATT_ERROR_IN_PROGRESS)); 121 base::Bind(error_callback,
122 BluetoothRemoteGattService::GATT_ERROR_IN_PROGRESS));
121 return; 123 return;
122 } 124 }
123 125
124 JNIEnv* env = AttachCurrentThread(); 126 JNIEnv* env = AttachCurrentThread();
125 if (!Java_ChromeBluetoothRemoteGattDescriptor_writeRemoteDescriptor( 127 if (!Java_ChromeBluetoothRemoteGattDescriptor_writeRemoteDescriptor(
126 env, j_descriptor_.obj(), 128 env, j_descriptor_.obj(),
127 base::android::ToJavaByteArray(env, new_value).obj())) { 129 base::android::ToJavaByteArray(env, new_value).obj())) {
128 base::MessageLoop::current()->PostTask( 130 base::MessageLoop::current()->PostTask(
129 FROM_HERE, 131 FROM_HERE,
130 base::Bind(error_callback, 132 base::Bind(error_callback,
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 write_error_callback.Run( 183 write_error_callback.Run(
182 BluetoothRemoteGattServiceAndroid::GetGattErrorCode(status)); 184 BluetoothRemoteGattServiceAndroid::GetGattErrorCode(status));
183 } 185 }
184 } 186 }
185 187
186 BluetoothRemoteGattDescriptorAndroid::BluetoothRemoteGattDescriptorAndroid( 188 BluetoothRemoteGattDescriptorAndroid::BluetoothRemoteGattDescriptorAndroid(
187 const std::string& instance_id) 189 const std::string& instance_id)
188 : instance_id_(instance_id) {} 190 : instance_id_(instance_id) {}
189 191
190 } // namespace device 192 } // namespace device
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698