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

Unified Diff: chrome/browser/extensions/api/bluetooth/bluetooth_event_router.h

Issue 11819007: Changed DefaultAdapter to RunCallbackOnAdapterReady function. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created IsBluetoothSupported in BluetoothEventRouter to fix browser_tests. 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.h
diff --git a/chrome/browser/extensions/api/bluetooth/bluetooth_event_router.h b/chrome/browser/extensions/api/bluetooth/bluetooth_event_router.h
index b93858acd9943e434d52af68d934e05f268c9b89..c722f651cb1648a2e8c98808b259fe66ba7dacbd 100644
--- a/chrome/browser/extensions/api/bluetooth/bluetooth_event_router.h
+++ b/chrome/browser/extensions/api/bluetooth/bluetooth_event_router.h
@@ -9,8 +9,10 @@
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_vector.h"
+#include "base/memory/weak_ptr.h"
#include "chrome/common/extensions/api/bluetooth.h"
#include "device/bluetooth/bluetooth_adapter.h"
+#include "device/bluetooth/bluetooth_adapter_factory.h"
#include "device/bluetooth/bluetooth_socket.h"
class Profile;
@@ -23,9 +25,12 @@ class ExtensionBluetoothEventRouter
explicit ExtensionBluetoothEventRouter(Profile* profile);
virtual ~ExtensionBluetoothEventRouter();
- // GetAdapter will return NULL if the bluetooth adapter is not
- // supported in the current platform.
- scoped_refptr<device::BluetoothAdapter> GetAdapter();
+ // Returns true if adapter_ has been initialized for testing or bluetooth
+ // adapter is available for the current platform.
+ bool IsBluetoothSupported() const;
+
+ void RunCallbackOnAdapterReady(
+ const device::BluetoothAdapterFactory::AdapterCallback& callback);
// Called when a bluetooth event listener is added.
void OnListenerAdded();
@@ -74,6 +79,7 @@ class ExtensionBluetoothEventRouter
}
private:
void InitializeAdapterIfNeeded();
+ void InitializeAdapter(scoped_refptr<device::BluetoothAdapter> adapter);
void MaybeReleaseAdapter();
void DispatchAdapterStateEvent();
@@ -97,6 +103,8 @@ class ExtensionBluetoothEventRouter
DeviceList;
DeviceList discovered_devices_;
+ base::WeakPtrFactory<ExtensionBluetoothEventRouter> weak_ptr_factory_;
+
DISALLOW_COPY_AND_ASSIGN(ExtensionBluetoothEventRouter);
};

Powered by Google App Engine
This is Rietveld 408576698