Chromium Code Reviews| Index: components/arc/bluetooth/arc_bluetooth_bridge.cc |
| diff --git a/components/arc/bluetooth/arc_bluetooth_bridge.cc b/components/arc/bluetooth/arc_bluetooth_bridge.cc |
| index dbc6747b662299696c5c1ebb56d1a9f069e3b04c..865217d7b0454952532c7b218728b470451172f4 100644 |
| --- a/components/arc/bluetooth/arc_bluetooth_bridge.cc |
| +++ b/components/arc/bluetooth/arc_bluetooth_bridge.cc |
| @@ -179,14 +179,6 @@ namespace arc { |
| ArcBluetoothBridge::ArcBluetoothBridge(ArcBridgeService* bridge_service) |
| : ArcService(bridge_service), binding_(this), weak_factory_(this) { |
| - if (BluetoothAdapterFactory::IsBluetoothAdapterAvailable()) { |
| - VLOG(1) << "registering bluetooth adapter"; |
| - BluetoothAdapterFactory::GetAdapter(base::Bind( |
| - &ArcBluetoothBridge::OnAdapterInitialized, weak_factory_.GetWeakPtr())); |
| - } else { |
| - VLOG(1) << "no bluetooth adapter available"; |
| - } |
| - |
| arc_bridge_service()->bluetooth()->AddObserver(this); |
| } |
| @@ -208,6 +200,7 @@ void ArcBluetoothBridge::OnAdapterInitialized( |
| bluetooth_adapter_ = |
| static_cast<bluez::BluetoothAdapterBlueZ*>(adapter.get()); |
| bluetooth_adapter_->AddObserver(this); |
| + bluetooth_observer_flag_ = true; |
| } |
| void ArcBluetoothBridge::OnInstanceReady() { |
| @@ -219,6 +212,19 @@ void ArcBluetoothBridge::OnInstanceReady() { |
| return; |
| } |
| bluetooth_instance->Init(binding_.CreateInterfacePtrAndBind()); |
| + if (BluetoothAdapterFactory::IsBluetoothAdapterAvailable()) { |
| + VLOG(1) << "registering bluetooth adapter"; |
|
rkc
2016/08/08 21:08:12
VLOG(1) << "Registering Bluetooth adapter.";
puthik_chromium
2016/08/08 21:40:25
Done.
|
| + BluetoothAdapterFactory::GetAdapter(base::Bind( |
| + &ArcBluetoothBridge::OnAdapterInitialized, weak_factory_.GetWeakPtr())); |
| + } else { |
| + VLOG(1) << "no bluetooth adapter available"; |
|
rkc
2016/08/08 21:08:12
VLOG(1) << "No Bluetooth adapter available.";
puthik_chromium
2016/08/08 21:40:25
Done.
|
| + } |
| +} |
| + |
| +void ArcBluetoothBridge::OnInstanceClosed() { |
| + if (bluetooth_observer_flag_ && bluetooth_adapter_) |
| + bluetooth_adapter_->RemoveObserver(this); |
|
rkc
2016/08/08 21:08:12
You don't need the bluetooth_observer_flag_ flag.
puthik_chromium
2016/08/08 21:40:25
The flag is used to see that we should register ob
|
| + bluetooth_observer_flag_ = false; |
| } |
| void ArcBluetoothBridge::AdapterPoweredChanged(BluetoothAdapter* adapter, |