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

Side by Side Diff: components/arc/bluetooth/arc_bluetooth_bridge.cc

Issue 2357053002: Always use arc::InstanceHolder<T>::GetInstanceForMethod (Closed)
Patch Set: review Created 4 years, 3 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/arc/bluetooth/arc_bluetooth_bridge.h" 5 #include "components/arc/bluetooth/arc_bluetooth_bridge.h"
6 6
7 #include <bluetooth/bluetooth.h> 7 #include <bluetooth/bluetooth.h>
8 #include <fcntl.h> 8 #include <fcntl.h>
9 #include <stddef.h> 9 #include <stddef.h>
10 #include <sys/socket.h> 10 #include <sys/socket.h>
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 275
276 // We can downcast here because we are always running on Chrome OS, and 276 // We can downcast here because we are always running on Chrome OS, and
277 // so our adapter uses BlueZ. 277 // so our adapter uses BlueZ.
278 bluetooth_adapter_ = 278 bluetooth_adapter_ =
279 static_cast<bluez::BluetoothAdapterBlueZ*>(adapter.get()); 279 static_cast<bluez::BluetoothAdapterBlueZ*>(adapter.get());
280 280
281 // The ARC instance was ready before the Bluetooth adapter, hence we didn't 281 // The ARC instance was ready before the Bluetooth adapter, hence we didn't
282 // register ourselves as an observer with it then. Since our adapter is 282 // register ourselves as an observer with it then. Since our adapter is
283 // ready, we should register it now. 283 // ready, we should register it now.
284 if (!bluetooth_adapter_->HasObserver(this) && 284 if (!bluetooth_adapter_->HasObserver(this) &&
285 arc_bridge_service()->bluetooth()->instance()) { 285 arc_bridge_service()->bluetooth()->HasInstance()) {
286 bluetooth_adapter_->AddObserver(this); 286 bluetooth_adapter_->AddObserver(this);
287 } 287 }
288 } 288 }
289 289
290 void ArcBluetoothBridge::OnInstanceReady() { 290 void ArcBluetoothBridge::OnInstanceReady() {
291 mojom::BluetoothInstance* bluetooth_instance = 291 mojom::BluetoothInstance* bluetooth_instance =
292 arc_bridge_service()->bluetooth()->instance(); 292 arc_bridge_service()->bluetooth()->GetInstanceForMethod("Init");
293 if (!bluetooth_instance) { 293 if (!bluetooth_instance)
294 LOG(ERROR) << "OnBluetoothInstanceReady called, "
295 << "but no bluetooth instance found";
296 return; 294 return;
297 }
298 295
299 bluetooth_instance->Init(binding_.CreateInterfacePtrAndBind()); 296 bluetooth_instance->Init(binding_.CreateInterfacePtrAndBind());
300 297
301 // The Bluetooth adapter was ready before the ARC instance, hence we didn't 298 // The Bluetooth adapter was ready before the ARC instance, hence we didn't
302 // register ourselves as an observer with it then. Since our instance is 299 // register ourselves as an observer with it then. Since our instance is
303 // ready, we should register it now. 300 // ready, we should register it now.
304 if (bluetooth_adapter_ && !bluetooth_adapter_->HasObserver(this)) 301 if (bluetooth_adapter_ && !bluetooth_adapter_->HasObserver(this))
305 bluetooth_adapter_->AddObserver(this); 302 bluetooth_adapter_->AddObserver(this);
306 } 303 }
307 304
(...skipping 1699 matching lines...) Expand 10 before | Expand all | Expand 10 after
2007 sdp_bluetooth_instance->OnGetSdpRecords( 2004 sdp_bluetooth_instance->OnGetSdpRecords(
2008 status, std::move(remote_addr), target_uuid, 2005 status, std::move(remote_addr), target_uuid,
2009 mojo::Array<mojom::BluetoothSdpRecordPtr>::New(0)); 2006 mojo::Array<mojom::BluetoothSdpRecordPtr>::New(0));
2010 } 2007 }
2011 2008
2012 bool ArcBluetoothBridge::CalledOnValidThread() { 2009 bool ArcBluetoothBridge::CalledOnValidThread() {
2013 return thread_checker_.CalledOnValidThread(); 2010 return thread_checker_.CalledOnValidThread();
2014 } 2011 }
2015 2012
2016 } // namespace arc 2013 } // namespace arc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698