OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_chromeos.h" | 5 #include "device/bluetooth/bluetooth_adapter_chromeos.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/location.h" | 10 #include "base/location.h" |
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
309 const device::BluetoothAdapter::AcquiredCallback& callback, | 309 const device::BluetoothAdapter::AcquiredCallback& callback, |
310 const BluetoothAudioSink::ErrorCallback& error_callback) { | 310 const BluetoothAudioSink::ErrorCallback& error_callback) { |
311 VLOG(1) << "Registering audio sink"; | 311 VLOG(1) << "Registering audio sink"; |
312 if (!this->IsPresent()) { | 312 if (!this->IsPresent()) { |
313 error_callback.Run(BluetoothAudioSink::ERROR_INVALID_ADAPTER); | 313 error_callback.Run(BluetoothAudioSink::ERROR_INVALID_ADAPTER); |
314 return; | 314 return; |
315 } | 315 } |
316 scoped_refptr<BluetoothAudioSinkChromeOS> audio_sink( | 316 scoped_refptr<BluetoothAudioSinkChromeOS> audio_sink( |
317 new BluetoothAudioSinkChromeOS(this)); | 317 new BluetoothAudioSinkChromeOS(this)); |
318 audio_sink->Register( | 318 audio_sink->Register( |
319 options, | 319 options, base::Bind(&BluetoothAdapterChromeOS::OnRegisterAudioSink, |
320 base::Bind(&BluetoothAdapterChromeOS::OnRegisterAudioSink, | 320 weak_ptr_factory_.GetWeakPtr(), callback, |
321 weak_ptr_factory_.GetWeakPtr(), callback, audio_sink), | 321 error_callback, audio_sink), |
322 error_callback); | 322 error_callback); |
323 } | 323 } |
324 | 324 |
325 void BluetoothAdapterChromeOS::RemovePairingDelegateInternal( | 325 void BluetoothAdapterChromeOS::RemovePairingDelegateInternal( |
326 BluetoothDevice::PairingDelegate* pairing_delegate) { | 326 BluetoothDevice::PairingDelegate* pairing_delegate) { |
327 DCHECK(IsPresent()); | |
328 // Before removing a pairing delegate make sure that there aren't any devices | 327 // Before removing a pairing delegate make sure that there aren't any devices |
329 // currently using it; if there are, clear the pairing context which will | 328 // currently using it; if there are, clear the pairing context which will |
330 // make any responses no-ops. | 329 // make any responses no-ops. |
331 for (DevicesMap::iterator iter = devices_.begin(); | 330 for (DevicesMap::iterator iter = devices_.begin(); |
332 iter != devices_.end(); ++iter) { | 331 iter != devices_.end(); ++iter) { |
333 BluetoothDeviceChromeOS* device_chromeos = | 332 BluetoothDeviceChromeOS* device_chromeos = |
334 static_cast<BluetoothDeviceChromeOS*>(iter->second); | 333 static_cast<BluetoothDeviceChromeOS*>(iter->second); |
335 | 334 |
336 BluetoothPairingChromeOS* pairing = device_chromeos->GetPairing(); | 335 BluetoothPairingChromeOS* pairing = device_chromeos->GetPairing(); |
337 if (pairing && pairing->GetPairingDelegate() == pairing_delegate) | 336 if (pairing && pairing->GetPairingDelegate() == pairing_delegate) |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
474 | 473 |
475 // Properties structure can be removed, which triggers a change in the | 474 // Properties structure can be removed, which triggers a change in the |
476 // BluetoothDevice::IsConnectable() property, as does a change in the | 475 // BluetoothDevice::IsConnectable() property, as does a change in the |
477 // actual reconnect_mode property. | 476 // actual reconnect_mode property. |
478 if (!properties || | 477 if (!properties || |
479 property_name == properties->reconnect_mode.name()) | 478 property_name == properties->reconnect_mode.name()) |
480 NotifyDeviceChanged(device_chromeos); | 479 NotifyDeviceChanged(device_chromeos); |
481 } | 480 } |
482 | 481 |
483 void BluetoothAdapterChromeOS::Released() { | 482 void BluetoothAdapterChromeOS::Released() { |
484 DCHECK(IsPresent()); | 483 VLOG(1) << "Release"; |
| 484 if (!IsPresent()) |
| 485 return; |
485 DCHECK(agent_.get()); | 486 DCHECK(agent_.get()); |
486 VLOG(1) << "Release"; | |
487 | 487 |
488 // Called after we unregister the pairing agent, e.g. when changing I/O | 488 // Called after we unregister the pairing agent, e.g. when changing I/O |
489 // capabilities. Nothing much to be done right now. | 489 // capabilities. Nothing much to be done right now. |
490 } | 490 } |
491 | 491 |
492 void BluetoothAdapterChromeOS::RequestPinCode( | 492 void BluetoothAdapterChromeOS::RequestPinCode( |
493 const dbus::ObjectPath& device_path, | 493 const dbus::ObjectPath& device_path, |
494 const PinCodeCallback& callback) { | 494 const PinCodeCallback& callback) { |
495 DCHECK(IsPresent()); | 495 DCHECK(IsPresent()); |
496 DCHECK(agent_.get()); | 496 DCHECK(agent_.get()); |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
617 callback.Run(REJECTED); | 617 callback.Run(REJECTED); |
618 } | 618 } |
619 | 619 |
620 void BluetoothAdapterChromeOS::Cancel() { | 620 void BluetoothAdapterChromeOS::Cancel() { |
621 DCHECK(IsPresent()); | 621 DCHECK(IsPresent()); |
622 DCHECK(agent_.get()); | 622 DCHECK(agent_.get()); |
623 VLOG(1) << "Cancel"; | 623 VLOG(1) << "Cancel"; |
624 } | 624 } |
625 | 625 |
626 void BluetoothAdapterChromeOS::OnRegisterAgent() { | 626 void BluetoothAdapterChromeOS::OnRegisterAgent() { |
627 DCHECK(IsPresent()); | |
628 VLOG(1) << "Pairing agent registered, requesting to be made default"; | 627 VLOG(1) << "Pairing agent registered, requesting to be made default"; |
629 | 628 |
630 DBusThreadManager::Get()->GetBluetoothAgentManagerClient()-> | 629 DBusThreadManager::Get()->GetBluetoothAgentManagerClient()-> |
631 RequestDefaultAgent( | 630 RequestDefaultAgent( |
632 dbus::ObjectPath(kAgentPath), | 631 dbus::ObjectPath(kAgentPath), |
633 base::Bind(&BluetoothAdapterChromeOS::OnRequestDefaultAgent, | 632 base::Bind(&BluetoothAdapterChromeOS::OnRequestDefaultAgent, |
634 weak_ptr_factory_.GetWeakPtr()), | 633 weak_ptr_factory_.GetWeakPtr()), |
635 base::Bind(&BluetoothAdapterChromeOS::OnRequestDefaultAgentError, | 634 base::Bind(&BluetoothAdapterChromeOS::OnRequestDefaultAgentError, |
636 weak_ptr_factory_.GetWeakPtr())); | 635 weak_ptr_factory_.GetWeakPtr())); |
637 } | 636 } |
638 | 637 |
639 void BluetoothAdapterChromeOS::OnRegisterAgentError( | 638 void BluetoothAdapterChromeOS::OnRegisterAgentError( |
640 const std::string& error_name, | 639 const std::string& error_name, |
641 const std::string& error_message) { | 640 const std::string& error_message) { |
642 DCHECK(IsPresent()); | |
643 // Our agent being already registered isn't an error. | 641 // Our agent being already registered isn't an error. |
644 if (error_name == bluetooth_agent_manager::kErrorAlreadyExists) | 642 if (error_name == bluetooth_agent_manager::kErrorAlreadyExists) |
645 return; | 643 return; |
646 | 644 |
647 LOG(WARNING) << ": Failed to register pairing agent: " | 645 LOG(WARNING) << ": Failed to register pairing agent: " |
648 << error_name << ": " << error_message; | 646 << error_name << ": " << error_message; |
649 } | 647 } |
650 | 648 |
651 void BluetoothAdapterChromeOS::OnRequestDefaultAgent() { | 649 void BluetoothAdapterChromeOS::OnRequestDefaultAgent() { |
652 DCHECK(IsPresent()); | |
653 VLOG(1) << "Pairing agent now default"; | 650 VLOG(1) << "Pairing agent now default"; |
654 } | 651 } |
655 | 652 |
656 void BluetoothAdapterChromeOS::OnRequestDefaultAgentError( | 653 void BluetoothAdapterChromeOS::OnRequestDefaultAgentError( |
657 const std::string& error_name, | 654 const std::string& error_name, |
658 const std::string& error_message) { | 655 const std::string& error_message) { |
659 DCHECK(IsPresent()); | |
660 LOG(WARNING) << ": Failed to make pairing agent default: " | 656 LOG(WARNING) << ": Failed to make pairing agent default: " |
661 << error_name << ": " << error_message; | 657 << error_name << ": " << error_message; |
662 } | 658 } |
663 | 659 |
664 void BluetoothAdapterChromeOS::OnRegisterAudioSink( | 660 void BluetoothAdapterChromeOS::OnRegisterAudioSink( |
665 const device::BluetoothAdapter::AcquiredCallback& callback, | 661 const device::BluetoothAdapter::AcquiredCallback& callback, |
| 662 const device::BluetoothAudioSink::ErrorCallback& error_callback, |
666 scoped_refptr<BluetoothAudioSink> audio_sink) { | 663 scoped_refptr<BluetoothAudioSink> audio_sink) { |
| 664 if (!IsPresent()) { |
| 665 VLOG(1) << "Failed to register audio sink, adapter not present"; |
| 666 error_callback.Run(BluetoothAudioSink::ERROR_INVALID_ADAPTER); |
| 667 return; |
| 668 } |
667 DCHECK(audio_sink.get()); | 669 DCHECK(audio_sink.get()); |
668 callback.Run(audio_sink); | 670 callback.Run(audio_sink); |
669 } | 671 } |
670 | 672 |
671 BluetoothDeviceChromeOS* | 673 BluetoothDeviceChromeOS* |
672 BluetoothAdapterChromeOS::GetDeviceWithPath( | 674 BluetoothAdapterChromeOS::GetDeviceWithPath( |
673 const dbus::ObjectPath& object_path) { | 675 const dbus::ObjectPath& object_path) { |
674 if (!IsPresent()) | 676 if (!IsPresent()) |
675 return NULL; | 677 return NULL; |
676 | 678 |
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1012 << ": Failed to register profile: " << error_name << ": " | 1014 << ": Failed to register profile: " << error_name << ": " |
1013 << error_message; | 1015 << error_message; |
1014 error_callback.Run(error_message); | 1016 error_callback.Run(error_message); |
1015 ReleaseProfile(uuid); | 1017 ReleaseProfile(uuid); |
1016 } | 1018 } |
1017 | 1019 |
1018 void BluetoothAdapterChromeOS::OnSetDiscoverable( | 1020 void BluetoothAdapterChromeOS::OnSetDiscoverable( |
1019 const base::Closure& callback, | 1021 const base::Closure& callback, |
1020 const ErrorCallback& error_callback, | 1022 const ErrorCallback& error_callback, |
1021 bool success) { | 1023 bool success) { |
1022 DCHECK(IsPresent()); | 1024 if (!IsPresent()) { |
| 1025 error_callback.Run(); |
| 1026 return; |
| 1027 } |
| 1028 |
1023 // Set the discoverable_timeout property to zero so the adapter remains | 1029 // Set the discoverable_timeout property to zero so the adapter remains |
1024 // discoverable forever. | 1030 // discoverable forever. |
1025 DBusThreadManager::Get()->GetBluetoothAdapterClient()-> | 1031 DBusThreadManager::Get()->GetBluetoothAdapterClient()-> |
1026 GetProperties(object_path_)->discoverable_timeout.Set( | 1032 GetProperties(object_path_)->discoverable_timeout.Set( |
1027 0, | 1033 0, |
1028 base::Bind(&BluetoothAdapterChromeOS::OnPropertyChangeCompleted, | 1034 base::Bind(&BluetoothAdapterChromeOS::OnPropertyChangeCompleted, |
1029 weak_ptr_factory_.GetWeakPtr(), | 1035 weak_ptr_factory_.GetWeakPtr(), |
1030 callback, | 1036 callback, |
1031 error_callback)); | 1037 error_callback)); |
1032 } | 1038 } |
1033 | 1039 |
1034 void BluetoothAdapterChromeOS::OnPropertyChangeCompleted( | 1040 void BluetoothAdapterChromeOS::OnPropertyChangeCompleted( |
1035 const base::Closure& callback, | 1041 const base::Closure& callback, |
1036 const ErrorCallback& error_callback, | 1042 const ErrorCallback& error_callback, |
1037 bool success) { | 1043 bool success) { |
1038 DCHECK(IsPresent()); | 1044 if (IsPresent() && success) |
1039 if (success) | |
1040 callback.Run(); | 1045 callback.Run(); |
1041 else | 1046 else |
1042 error_callback.Run(); | 1047 error_callback.Run(); |
1043 } | 1048 } |
1044 | 1049 |
1045 void BluetoothAdapterChromeOS::AddDiscoverySession( | 1050 void BluetoothAdapterChromeOS::AddDiscoverySession( |
1046 const base::Closure& callback, | 1051 const base::Closure& callback, |
1047 const ErrorCallback& error_callback) { | 1052 const ErrorCallback& error_callback) { |
1048 if (!IsPresent()) { | 1053 if (!IsPresent()) { |
1049 error_callback.Run(); | 1054 error_callback.Run(); |
(...skipping 17 matching lines...) Expand all Loading... |
1067 num_discovery_sessions_++; | 1072 num_discovery_sessions_++; |
1068 callback.Run(); | 1073 callback.Run(); |
1069 return; | 1074 return; |
1070 } | 1075 } |
1071 | 1076 |
1072 // There are no active discovery sessions. | 1077 // There are no active discovery sessions. |
1073 DCHECK_EQ(num_discovery_sessions_, 0); | 1078 DCHECK_EQ(num_discovery_sessions_, 0); |
1074 | 1079 |
1075 // This is the first request to start device discovery. | 1080 // This is the first request to start device discovery. |
1076 discovery_request_pending_ = true; | 1081 discovery_request_pending_ = true; |
1077 DBusThreadManager::Get()->GetBluetoothAdapterClient()-> | 1082 DBusThreadManager::Get()->GetBluetoothAdapterClient()->StartDiscovery( |
1078 StartDiscovery( | 1083 object_path_, |
1079 object_path_, | 1084 base::Bind(&BluetoothAdapterChromeOS::OnStartDiscovery, |
1080 base::Bind(&BluetoothAdapterChromeOS::OnStartDiscovery, | 1085 weak_ptr_factory_.GetWeakPtr(), callback, error_callback), |
1081 weak_ptr_factory_.GetWeakPtr(), | 1086 base::Bind(&BluetoothAdapterChromeOS::OnStartDiscoveryError, |
1082 callback), | 1087 weak_ptr_factory_.GetWeakPtr(), callback, error_callback)); |
1083 base::Bind(&BluetoothAdapterChromeOS::OnStartDiscoveryError, | |
1084 weak_ptr_factory_.GetWeakPtr(), | |
1085 callback, | |
1086 error_callback)); | |
1087 } | 1088 } |
1088 | 1089 |
1089 void BluetoothAdapterChromeOS::RemoveDiscoverySession( | 1090 void BluetoothAdapterChromeOS::RemoveDiscoverySession( |
1090 const base::Closure& callback, | 1091 const base::Closure& callback, |
1091 const ErrorCallback& error_callback) { | 1092 const ErrorCallback& error_callback) { |
1092 DCHECK(IsPresent()); | 1093 if (!IsPresent()) { |
| 1094 error_callback.Run(); |
| 1095 return; |
| 1096 } |
| 1097 |
1093 VLOG(1) << __func__; | 1098 VLOG(1) << __func__; |
1094 // There are active sessions other than the one currently being removed. | 1099 // There are active sessions other than the one currently being removed. |
1095 if (num_discovery_sessions_ > 1) { | 1100 if (num_discovery_sessions_ > 1) { |
1096 DCHECK(IsDiscovering()); | 1101 DCHECK(IsDiscovering()); |
1097 DCHECK(!discovery_request_pending_); | 1102 DCHECK(!discovery_request_pending_); |
1098 num_discovery_sessions_--; | 1103 num_discovery_sessions_--; |
1099 callback.Run(); | 1104 callback.Run(); |
1100 return; | 1105 return; |
1101 } | 1106 } |
1102 | 1107 |
(...skipping 23 matching lines...) Expand all Loading... |
1126 StopDiscovery( | 1131 StopDiscovery( |
1127 object_path_, | 1132 object_path_, |
1128 base::Bind(&BluetoothAdapterChromeOS::OnStopDiscovery, | 1133 base::Bind(&BluetoothAdapterChromeOS::OnStopDiscovery, |
1129 weak_ptr_factory_.GetWeakPtr(), | 1134 weak_ptr_factory_.GetWeakPtr(), |
1130 callback), | 1135 callback), |
1131 base::Bind(&BluetoothAdapterChromeOS::OnStopDiscoveryError, | 1136 base::Bind(&BluetoothAdapterChromeOS::OnStopDiscoveryError, |
1132 weak_ptr_factory_.GetWeakPtr(), | 1137 weak_ptr_factory_.GetWeakPtr(), |
1133 error_callback)); | 1138 error_callback)); |
1134 } | 1139 } |
1135 | 1140 |
1136 void BluetoothAdapterChromeOS::OnStartDiscovery(const base::Closure& callback) { | 1141 void BluetoothAdapterChromeOS::OnStartDiscovery( |
1137 DCHECK(IsPresent()); | 1142 const base::Closure& callback, |
| 1143 const ErrorCallback& error_callback) { |
1138 // Report success on the original request and increment the count. | 1144 // Report success on the original request and increment the count. |
1139 VLOG(1) << __func__; | 1145 VLOG(1) << __func__; |
1140 DCHECK(discovery_request_pending_); | 1146 DCHECK(discovery_request_pending_); |
1141 DCHECK_EQ(num_discovery_sessions_, 0); | 1147 DCHECK_EQ(num_discovery_sessions_, 0); |
1142 discovery_request_pending_ = false; | 1148 discovery_request_pending_ = false; |
1143 num_discovery_sessions_++; | 1149 num_discovery_sessions_++; |
1144 callback.Run(); | 1150 if (IsPresent()) |
| 1151 callback.Run(); |
| 1152 else |
| 1153 error_callback.Run(); |
1145 | 1154 |
1146 // Try to add a new discovery session for each queued request. | 1155 // Try to add a new discovery session for each queued request. |
1147 ProcessQueuedDiscoveryRequests(); | 1156 ProcessQueuedDiscoveryRequests(); |
1148 } | 1157 } |
1149 | 1158 |
1150 void BluetoothAdapterChromeOS::OnStartDiscoveryError( | 1159 void BluetoothAdapterChromeOS::OnStartDiscoveryError( |
1151 const base::Closure& callback, | 1160 const base::Closure& callback, |
1152 const ErrorCallback& error_callback, | 1161 const ErrorCallback& error_callback, |
1153 const std::string& error_name, | 1162 const std::string& error_name, |
1154 const std::string& error_message) { | 1163 const std::string& error_message) { |
1155 DCHECK(IsPresent()); | |
1156 LOG(WARNING) << object_path_.value() << ": Failed to start discovery: " | 1164 LOG(WARNING) << object_path_.value() << ": Failed to start discovery: " |
1157 << error_name << ": " << error_message; | 1165 << error_name << ": " << error_message; |
1158 | 1166 |
1159 // Failed to start discovery. This can only happen if the count is at 0. | 1167 // Failed to start discovery. This can only happen if the count is at 0. |
1160 DCHECK_EQ(num_discovery_sessions_, 0); | 1168 DCHECK_EQ(num_discovery_sessions_, 0); |
1161 DCHECK(discovery_request_pending_); | 1169 DCHECK(discovery_request_pending_); |
1162 discovery_request_pending_ = false; | 1170 discovery_request_pending_ = false; |
1163 | 1171 |
1164 // Discovery request may fail if discovery was previously initiated by Chrome, | 1172 // Discovery request may fail if discovery was previously initiated by Chrome, |
1165 // but the session were invalidated due to the discovery state unexpectedly | 1173 // but the session were invalidated due to the discovery state unexpectedly |
1166 // changing to false and then back to true. In this case, report success. | 1174 // changing to false and then back to true. In this case, report success. |
1167 if (error_name == bluetooth_device::kErrorInProgress && IsDiscovering()) { | 1175 if (IsPresent() && error_name == bluetooth_device::kErrorInProgress && |
| 1176 IsDiscovering()) { |
1168 VLOG(1) << "Discovery previously initiated. Reporting success."; | 1177 VLOG(1) << "Discovery previously initiated. Reporting success."; |
1169 num_discovery_sessions_++; | 1178 num_discovery_sessions_++; |
1170 callback.Run(); | 1179 callback.Run(); |
1171 } else { | 1180 } else { |
1172 error_callback.Run(); | 1181 error_callback.Run(); |
1173 } | 1182 } |
1174 | 1183 |
1175 // Try to add a new discovery session for each queued request. | 1184 // Try to add a new discovery session for each queued request. |
1176 ProcessQueuedDiscoveryRequests(); | 1185 ProcessQueuedDiscoveryRequests(); |
1177 } | 1186 } |
1178 | 1187 |
1179 void BluetoothAdapterChromeOS::OnStopDiscovery(const base::Closure& callback) { | 1188 void BluetoothAdapterChromeOS::OnStopDiscovery(const base::Closure& callback) { |
1180 DCHECK(IsPresent()); | |
1181 // Report success on the original request and decrement the count. | 1189 // Report success on the original request and decrement the count. |
1182 VLOG(1) << __func__; | 1190 VLOG(1) << __func__; |
1183 DCHECK(discovery_request_pending_); | 1191 DCHECK(discovery_request_pending_); |
1184 DCHECK_EQ(num_discovery_sessions_, 1); | 1192 DCHECK_EQ(num_discovery_sessions_, 1); |
1185 discovery_request_pending_ = false; | 1193 discovery_request_pending_ = false; |
1186 num_discovery_sessions_--; | 1194 num_discovery_sessions_--; |
1187 callback.Run(); | 1195 callback.Run(); |
1188 | 1196 |
1189 // Try to add a new discovery session for each queued request. | 1197 // Try to add a new discovery session for each queued request. |
1190 ProcessQueuedDiscoveryRequests(); | 1198 ProcessQueuedDiscoveryRequests(); |
1191 } | 1199 } |
1192 | 1200 |
1193 void BluetoothAdapterChromeOS::OnStopDiscoveryError( | 1201 void BluetoothAdapterChromeOS::OnStopDiscoveryError( |
1194 const ErrorCallback& error_callback, | 1202 const ErrorCallback& error_callback, |
1195 const std::string& error_name, | 1203 const std::string& error_name, |
1196 const std::string& error_message) { | 1204 const std::string& error_message) { |
1197 DCHECK(IsPresent()); | |
1198 LOG(WARNING) << object_path_.value() << ": Failed to stop discovery: " | 1205 LOG(WARNING) << object_path_.value() << ": Failed to stop discovery: " |
1199 << error_name << ": " << error_message; | 1206 << error_name << ": " << error_message; |
1200 | 1207 |
1201 // Failed to stop discovery. This can only happen if the count is at 1. | 1208 // Failed to stop discovery. This can only happen if the count is at 1. |
1202 DCHECK(discovery_request_pending_); | 1209 DCHECK(discovery_request_pending_); |
1203 DCHECK_EQ(num_discovery_sessions_, 1); | 1210 DCHECK_EQ(num_discovery_sessions_, 1); |
1204 discovery_request_pending_ = false; | 1211 discovery_request_pending_ = false; |
1205 error_callback.Run(); | 1212 error_callback.Run(); |
1206 | 1213 |
1207 // Try to add a new discovery session for each queued request. | 1214 // Try to add a new discovery session for each queued request. |
1208 ProcessQueuedDiscoveryRequests(); | 1215 ProcessQueuedDiscoveryRequests(); |
1209 } | 1216 } |
1210 | 1217 |
1211 void BluetoothAdapterChromeOS::ProcessQueuedDiscoveryRequests() { | 1218 void BluetoothAdapterChromeOS::ProcessQueuedDiscoveryRequests() { |
1212 while (!discovery_request_queue_.empty()) { | 1219 while (!discovery_request_queue_.empty()) { |
1213 VLOG(1) << "Process queued discovery request."; | 1220 VLOG(1) << "Process queued discovery request."; |
1214 DiscoveryCallbackPair callbacks = discovery_request_queue_.front(); | 1221 DiscoveryCallbackPair callbacks = discovery_request_queue_.front(); |
1215 discovery_request_queue_.pop(); | 1222 discovery_request_queue_.pop(); |
1216 AddDiscoverySession(callbacks.first, callbacks.second); | 1223 AddDiscoverySession(callbacks.first, callbacks.second); |
1217 | 1224 |
1218 // If the queued request resulted in a pending call, then let it | 1225 // If the queued request resulted in a pending call, then let it |
1219 // asynchonously process the remaining queued requests once the pending | 1226 // asynchonously process the remaining queued requests once the pending |
1220 // call returns. | 1227 // call returns. |
1221 if (discovery_request_pending_) | 1228 if (discovery_request_pending_) |
1222 return; | 1229 return; |
1223 } | 1230 } |
1224 } | 1231 } |
1225 | 1232 |
1226 } // namespace chromeos | 1233 } // namespace chromeos |
OLD | NEW |