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

Unified Diff: chrome/browser/extensions/api/bluetooth/bluetooth_extension_function.cc

Issue 11819007: Changed DefaultAdapter to RunCallbackOnAdapterReady function. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/api/bluetooth/bluetooth_extension_function.cc
diff --git a/chrome/browser/extensions/api/bluetooth/bluetooth_extension_function.cc b/chrome/browser/extensions/api/bluetooth/bluetooth_extension_function.cc
index eb88330326103cb61d1658307d5711e18a38ce52..2f2ae6a8d6325e4cb438ff77d85262e807d1ec19 100644
--- a/chrome/browser/extensions/api/bluetooth/bluetooth_extension_function.cc
+++ b/chrome/browser/extensions/api/bluetooth/bluetooth_extension_function.cc
@@ -16,10 +16,12 @@ namespace {
const char kPlatformNotSupported[] =
"This operation is not supported on your platform";
-scoped_refptr<device::BluetoothAdapter> GetAdapter(Profile* profile) {
+void RunCallbackOnAdapterReady(
+ const device::BluetoothAdapterFactory::AdapterCallback callback,
+ Profile* profile) {
extensions::ExtensionBluetoothEventRouter* event_router =
extensions::BluetoothAPI::Get(profile)->bluetooth_event_router();
- return event_router->GetAdapter();
+ event_router->RunCallbackOnAdapterReady(callback);
}
} // namespace
@@ -35,12 +37,15 @@ BluetoothExtensionFunction::~BluetoothExtensionFunction() {
}
bool BluetoothExtensionFunction::RunImpl() {
- scoped_refptr<device::BluetoothAdapter> adapter = GetAdapter(profile());
- if (!adapter) {
+ bool is_bluetooth_supported =
+ device::BluetoothAdapterFactory::IsBluetoothSupported();
+ RunCallbackOnAdapterReady(base::Bind(&BluetoothExtensionFunction::DoWork,
bryeung 2013/01/08 22:24:27 why do we try this when is_bluetooth_supported ==
youngki 2013/01/09 15:12:03 !! You are right. Done.
+ base::Unretained(this)),
+ profile());
+ if (!is_bluetooth_supported) {
SetError(kPlatformNotSupported);
return false;
}
- DoWork(adapter);
return true;
}

Powered by Google App Engine
This is Rietveld 408576698