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

Unified Diff: device/bluetooth/bluetooth_task_manager_win.cc

Issue 476823003: Fix Bluetooth Classic device polling issue. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: device/bluetooth/bluetooth_task_manager_win.cc
diff --git a/device/bluetooth/bluetooth_task_manager_win.cc b/device/bluetooth/bluetooth_task_manager_win.cc
index db2540b12e77ddf41d8132c8b1ab5a904e590c6a..3f72ed83c603b62205306228bca4ec11556e901b 100644
--- a/device/bluetooth/bluetooth_task_manager_win.cc
+++ b/device/bluetooth/bluetooth_task_manager_win.cc
@@ -537,6 +537,7 @@ bool BluetoothTaskManagerWin::DiscoverClassicDeviceServices(
const GUID& protocol_uuid,
bool search_cached_services_only,
ScopedVector<ServiceRecordState>* service_record_states) {
+TryAgain:
// Bluetooth and WSAQUERYSET for Service Inquiry. See http://goo.gl/2v9pyt.
WSAQUERYSET sdp_query;
ZeroMemory(&sdp_query, sizeof(sdp_query));
@@ -562,7 +563,16 @@ bool BluetoothTaskManagerWin::DiscoverClassicDeviceServices(
HANDLE sdp_handle;
if (ERROR_SUCCESS !=
WSALookupServiceBegin(&sdp_query, control_flags, &sdp_handle)) {
- LogPollingError("Error calling WSALookupServiceBegin", WSAGetLastError());
+ int last_error = WSAGetLastError();
+ // If the device is "offline", no services are returned when specifying
+ // "LUP_FLUSHCACHE". Try again without flushing the cache so that the list
+ // of previously known services is returned.
+ if (!search_cached_services_only &&
+ (last_error == WSASERVICE_NOT_FOUND || last_error == WSANO_DATA)) {
+ search_cached_services_only = true;
+ goto TryAgain;
xiyuan 2014/08/14 19:35:29 Can we get rid of the "goto"?
rpaquay 2014/08/15 19:55:33 Done.
+ }
+ LogPollingError("Error calling WSALookupServiceBegin", last_error);
return false;
}
char sdp_buffer[kServiceDiscoveryResultBufferSize];
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698