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

Unified Diff: trunk/src/chrome/browser/extensions/api/bluetooth/bluetooth_api.cc

Issue 188663003: Revert 255262 "Migrate chrome.bluetooth API backend to use devic..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 6 years, 9 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 | trunk/src/chrome/browser/extensions/api/bluetooth/bluetooth_apitest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: trunk/src/chrome/browser/extensions/api/bluetooth/bluetooth_api.cc
===================================================================
--- trunk/src/chrome/browser/extensions/api/bluetooth/bluetooth_api.cc (revision 255369)
+++ trunk/src/chrome/browser/extensions/api/bluetooth/bluetooth_api.cc (working copy)
@@ -636,19 +636,25 @@
void BluetoothStartDiscoveryFunction::OnErrorCallback() {
SetError(kStartDiscoveryFailed);
+ GetEventRouter(browser_context())->SetResponsibleForDiscovery(false);
SendResponse(false);
GetEventRouter(browser_context())->OnListenerRemoved();
}
bool BluetoothStartDiscoveryFunction::DoWork(
scoped_refptr<BluetoothAdapter> adapter) {
- GetEventRouter(browser_context())->OnListenerAdded();
- GetEventRouter(browser_context())->StartDiscoverySession(
- adapter,
- extension_id(),
- base::Bind(&BluetoothStartDiscoveryFunction::OnSuccessCallback, this),
- base::Bind(&BluetoothStartDiscoveryFunction::OnErrorCallback, this));
+ GetEventRouter(browser_context())->SetSendDiscoveryEvents(true);
+ // If this profile is already discovering devices, there should be nothing
+ // else to do.
+ if (!GetEventRouter(browser_context())->IsResponsibleForDiscovery()) {
+ GetEventRouter(browser_context())->SetResponsibleForDiscovery(true);
+ GetEventRouter(browser_context())->OnListenerAdded();
+ adapter->StartDiscovering(
+ base::Bind(&BluetoothStartDiscoveryFunction::OnSuccessCallback, this),
+ base::Bind(&BluetoothStartDiscoveryFunction::OnErrorCallback, this));
+ }
+
return true;
}
@@ -659,17 +665,19 @@
void BluetoothStopDiscoveryFunction::OnErrorCallback() {
SetError(kStopDiscoveryFailed);
+ GetEventRouter(browser_context())->SetResponsibleForDiscovery(true);
SendResponse(false);
GetEventRouter(browser_context())->OnListenerRemoved();
}
bool BluetoothStopDiscoveryFunction::DoWork(
scoped_refptr<BluetoothAdapter> adapter) {
- GetEventRouter(browser_context())->StopDiscoverySession(
- adapter,
- extension_id(),
- base::Bind(&BluetoothStopDiscoveryFunction::OnSuccessCallback, this),
- base::Bind(&BluetoothStopDiscoveryFunction::OnErrorCallback, this));
+ GetEventRouter(browser_context())->SetSendDiscoveryEvents(false);
+ if (GetEventRouter(browser_context())->IsResponsibleForDiscovery()) {
+ adapter->StopDiscovering(
+ base::Bind(&BluetoothStopDiscoveryFunction::OnSuccessCallback, this),
+ base::Bind(&BluetoothStopDiscoveryFunction::OnErrorCallback, this));
+ }
return true;
}
« no previous file with comments | « no previous file | trunk/src/chrome/browser/extensions/api/bluetooth/bluetooth_apitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698