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

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

Issue 2638753002: Revert of Bluetooth: macOS: BluetoothRemoteGattCharacteristicMac::SubscribeToNotifications (Closed)
Patch Set: Created 3 years, 11 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
« no previous file with comments | « no previous file | device/bluetooth/bluetooth_remote_gatt_characteristic_mac.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_characteristic.h" 5 #include "device/bluetooth/bluetooth_remote_gatt_characteristic.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "base/single_thread_task_runner.h" 9 #include "base/single_thread_task_runner.h"
10 #include "base/threading/thread_task_runner_handle.h" 10 #include "base/threading/thread_task_runner_handle.h"
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 &BluetoothRemoteGattCharacteristic::OnStartNotifySessionSuccess, 138 &BluetoothRemoteGattCharacteristic::OnStartNotifySessionSuccess,
139 GetWeakPtr(), callback)); 139 GetWeakPtr(), callback));
140 return; 140 return;
141 } 141 }
142 142
143 // After we migrate each platform to the new way of starting and stopping 143 // After we migrate each platform to the new way of starting and stopping
144 // notifications, we can remove them from this #if check. The goal is to get 144 // notifications, we can remove them from this #if check. The goal is to get
145 // rid of the entire check, and run SubscribeToNotifications on all 145 // rid of the entire check, and run SubscribeToNotifications on all
146 // platforms. 146 // platforms.
147 // 147 //
148 // TODO(http://crbug.com/633191): Remove OS_MACOSX from this check.
148 // TODO(http://crbug.com/636270): Remove OS_WIN from this check. 149 // TODO(http://crbug.com/636270): Remove OS_WIN from this check.
149 #if defined(OS_WIN) 150 #if defined(OS_MACOSX) || defined(OS_WIN)
150 base::ThreadTaskRunnerHandle::Get()->PostTask( 151 base::ThreadTaskRunnerHandle::Get()->PostTask(
151 FROM_HERE, 152 FROM_HERE,
152 base::Bind(&BluetoothRemoteGattCharacteristic::OnStartNotifySessionError, 153 base::Bind(&BluetoothRemoteGattCharacteristic::OnStartNotifySessionError,
153 GetWeakPtr(), error_callback, 154 GetWeakPtr(), error_callback,
154 BluetoothRemoteGattService::GATT_ERROR_NOT_SUPPORTED)); 155 BluetoothRemoteGattService::GATT_ERROR_NOT_SUPPORTED));
155 #else // defined(OS_WIN)) 156 #else // !(defined(OS_MACOSX) || defined(OS_WIN))
156 // Find the Client Characteristic Configuration descriptor. 157 // Find the Client Characteristic Configuration descriptor.
157 std::vector<BluetoothRemoteGattDescriptor*> ccc_descriptor = 158 std::vector<BluetoothRemoteGattDescriptor*> ccc_descriptor =
158 GetDescriptorsByUUID(BluetoothRemoteGattDescriptor:: 159 GetDescriptorsByUUID(BluetoothRemoteGattDescriptor::
159 ClientCharacteristicConfigurationUuid()); 160 ClientCharacteristicConfigurationUuid());
160 161
161 if (ccc_descriptor.size() != 1u) { 162 if (ccc_descriptor.size() != 1u) {
162 LOG(ERROR) << "Found " << ccc_descriptor.size() 163 LOG(ERROR) << "Found " << ccc_descriptor.size()
163 << " client characteristic configuration descriptors."; 164 << " client characteristic configuration descriptors.";
164 base::ThreadTaskRunnerHandle::Get()->PostTask( 165 base::ThreadTaskRunnerHandle::Get()->PostTask(
165 FROM_HERE, 166 FROM_HERE,
166 base::Bind( 167 base::Bind(
167 &BluetoothRemoteGattCharacteristic::OnStartNotifySessionError, 168 &BluetoothRemoteGattCharacteristic::OnStartNotifySessionError,
168 GetWeakPtr(), error_callback, 169 GetWeakPtr(), error_callback,
169 (ccc_descriptor.size() == 0) 170 (ccc_descriptor.size() == 0)
170 ? BluetoothRemoteGattService::GATT_ERROR_NOT_SUPPORTED 171 ? BluetoothRemoteGattService::GATT_ERROR_NOT_SUPPORTED
171 : BluetoothRemoteGattService::GATT_ERROR_FAILED)); 172 : BluetoothRemoteGattService::GATT_ERROR_FAILED));
172 return; 173 return;
173 } 174 }
174 175
175 // Pass the Client Characteristic Configuration descriptor to 176 // Pass the Client Characteristic Configuration descriptor to
176 // SubscribetoNotifications, which will write the correct value to it, and 177 // SubscribetoNotifications, which will write the correct value to it, and
177 // do whatever else is needed to get the notifications flowing. 178 // do whatever else is needed to get the notifications flowing.
178 SubscribeToNotifications( 179 SubscribeToNotifications(
179 ccc_descriptor[0], 180 ccc_descriptor[0],
180 base::Bind( 181 base::Bind(
181 &BluetoothRemoteGattCharacteristic::OnStartNotifySessionSuccess, 182 &BluetoothRemoteGattCharacteristic::OnStartNotifySessionSuccess,
182 GetWeakPtr(), callback), 183 GetWeakPtr(), callback),
183 base::Bind(&BluetoothRemoteGattCharacteristic::OnStartNotifySessionError, 184 base::Bind(&BluetoothRemoteGattCharacteristic::OnStartNotifySessionError,
184 GetWeakPtr(), error_callback)); 185 GetWeakPtr(), error_callback));
185 #endif // defined(OS_WIN) 186 #endif // defined(OS_MACOSX) || defined(OS_WIN)
186 } 187 }
187 188
188 void BluetoothRemoteGattCharacteristic::CancelStartNotifySession( 189 void BluetoothRemoteGattCharacteristic::CancelStartNotifySession(
189 base::Closure callback) { 190 base::Closure callback) {
190 std::unique_ptr<NotifySessionCommand> command = 191 std::unique_ptr<NotifySessionCommand> command =
191 std::move(pending_notify_commands_.front()); 192 std::move(pending_notify_commands_.front());
192 pending_notify_commands_.pop(); 193 pending_notify_commands_.pop();
193 callback.Run(); 194 callback.Run();
194 } 195 }
195 196
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 352
352 pending_notify_commands_.pop(); 353 pending_notify_commands_.pop();
353 if (!pending_notify_commands_.empty()) { 354 if (!pending_notify_commands_.empty()) {
354 pending_notify_commands_.front()->Execute( 355 pending_notify_commands_.front()->Execute(
355 NotifySessionCommand::COMMAND_STOP, NotifySessionCommand::RESULT_ERROR, 356 NotifySessionCommand::COMMAND_STOP, NotifySessionCommand::RESULT_ERROR,
356 error); 357 error);
357 } 358 }
358 } 359 }
359 360
360 } // namespace device 361 } // namespace device
OLDNEW
« no previous file with comments | « no previous file | device/bluetooth/bluetooth_remote_gatt_characteristic_mac.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698