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

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

Issue 12018024: Implemented Asynchronous Initialization of BluetoothAdapter. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Turned adapter_callbacks to a lazy instance. 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 ed63f8af38e0f3e19793ca275efc4fd8e5d074b5..3b6baa8097536f212c5811e724be5c85787af83c 100644
--- a/chrome/browser/extensions/api/bluetooth/bluetooth_extension_function.cc
+++ b/chrome/browser/extensions/api/bluetooth/bluetooth_extension_function.cc
@@ -24,10 +24,10 @@ bool IsBluetoothSupported(Profile* profile) {
return GetEventRouter(profile)->IsBluetoothSupported();
}
-void RunCallbackOnAdapterReady(
- const device::BluetoothAdapter::AdapterCallback callback,
+void GetAdapter(
+ const device::BluetoothAdapterFactory::AdapterCallback callback,
Profile* profile) {
- GetEventRouter(profile)->RunCallbackOnAdapterReady(callback);
+ GetEventRouter(profile)->GetAdapter(callback);
}
} // namespace
@@ -36,8 +36,7 @@ namespace extensions {
namespace api {
-BluetoothExtensionFunction::BluetoothExtensionFunction()
- : ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) {
+BluetoothExtensionFunction::BluetoothExtensionFunction() {
}
BluetoothExtensionFunction::~BluetoothExtensionFunction() {
@@ -48,10 +47,9 @@ bool BluetoothExtensionFunction::RunImpl() {
SetError(kPlatformNotSupported);
return false;
}
- RunCallbackOnAdapterReady(
- base::Bind(&BluetoothExtensionFunction::RunOnAdapterReady,
- weak_ptr_factory_.GetWeakPtr()),
- profile());
+ GetAdapter(base::Bind(&BluetoothExtensionFunction::RunOnAdapterReady, this),
+ profile());
+
return true;
}

Powered by Google App Engine
This is Rietveld 408576698