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

Unified Diff: chrome/browser/extensions/api/bluetooth/bluetooth_event_router.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_event_router.cc
diff --git a/chrome/browser/extensions/api/bluetooth/bluetooth_event_router.cc b/chrome/browser/extensions/api/bluetooth/bluetooth_event_router.cc
index bb0a492dc8c6b3c3fa4e9257786b90d981571394..1853b04f6951a7e3f30a3981f8e15d91a23ba5d1 100644
--- a/chrome/browser/extensions/api/bluetooth/bluetooth_event_router.cc
+++ b/chrome/browser/extensions/api/bluetooth/bluetooth_event_router.cc
@@ -41,12 +41,9 @@ ExtensionBluetoothEventRouter::~ExtensionBluetoothEventRouter() {
}
}
-scoped_refptr<device::BluetoothAdapter>
-ExtensionBluetoothEventRouter::GetAdapter() {
- if (adapter_)
- return adapter_;
-
- return device::BluetoothAdapterFactory::DefaultAdapter();
+void ExtensionBluetoothEventRouter::RunCallbackOnAdapterReady(
+ const device::BluetoothAdapterFactory::AdapterCallback& callback) {
+ device::BluetoothAdapterFactory::RunCallbackOnAdapterReady(callback);
bryeung 2013/01/08 22:24:27 Since this is just a pass-through method now...why
youngki 2013/01/09 15:12:03 We could.. But then we cannot mock the bluetooth a
bryeung 2013/01/09 15:28:01 Okay.
}
void ExtensionBluetoothEventRouter::OnListenerAdded() {
@@ -178,11 +175,19 @@ void ExtensionBluetoothEventRouter::DeviceAdded(
void ExtensionBluetoothEventRouter::InitializeAdapterIfNeeded() {
if (!adapter_) {
- adapter_ = GetAdapter();
- adapter_->AddObserver(this);
+ RunCallbackOnAdapterReady(
+ base::Bind(&ExtensionBluetoothEventRouter::InitializeAdapter,
+ base::Unretained(this)));
}
}
+bool ExtensionBluetoothEventRouter::InitializeAdapter(
+ scoped_refptr<device::BluetoothAdapter> adapter) {
+ adapter_ = adapter;
+ adapter_->AddObserver(this);
+ return true;
+}
+
void ExtensionBluetoothEventRouter::MaybeReleaseAdapter() {
if (adapter_ && num_event_listeners_ == 0) {
adapter_->RemoveObserver(this);

Powered by Google App Engine
This is Rietveld 408576698