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

Unified Diff: device/bluetooth/bluetooth_adapter_win.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
« no previous file with comments | « device/bluetooth/bluetooth_adapter_win.h ('k') | device/bluetooth/bluetooth_adapter_win_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: device/bluetooth/bluetooth_adapter_win.cc
diff --git a/device/bluetooth/bluetooth_adapter_win.cc b/device/bluetooth/bluetooth_adapter_win.cc
index 530835c290ae3621a065b828992ba097130e2a41..128ccb371ffe541cd38666edb146ffa1bb3a6480 100644
--- a/device/bluetooth/bluetooth_adapter_win.cc
+++ b/device/bluetooth/bluetooth_adapter_win.cc
@@ -14,8 +14,10 @@
namespace device {
-BluetoothAdapterWin::BluetoothAdapterWin()
+BluetoothAdapterWin::BluetoothAdapterWin(const InitCallback& init_callback)
: BluetoothAdapter(),
+ init_callback_(init_callback),
+ initialized_(false),
powered_(false),
ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) {
}
@@ -40,7 +42,7 @@ void BluetoothAdapterWin::RemoveObserver(BluetoothAdapter::Observer* observer) {
// TODO(youngki): Return true when |task_manager_| initializes the adapter
// state.
bool BluetoothAdapterWin::IsInitialized() const {
- return true;
+ return initialized_;
}
bool BluetoothAdapterWin::IsPresent() const {
@@ -98,6 +100,10 @@ void BluetoothAdapterWin::AdapterStateChanged(
name_ = state.name;
address_ = state.address;
powered_ = state.powered;
+ if (!initialized_) {
+ init_callback_.Run();
+ }
+ initialized_ = true;
}
void BluetoothAdapterWin::TrackDefaultAdapter() {
« no previous file with comments | « device/bluetooth/bluetooth_adapter_win.h ('k') | device/bluetooth/bluetooth_adapter_win_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698