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

Side by Side Diff: device/bluetooth/bluetooth_adapter_factory_wrapper.cc

Issue 2815793003: bluetooth: Introduce SetLowEnergyAvailableForTesting (Closed)
Patch Set: Created 3 years, 8 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
« no previous file with comments | « device/bluetooth/bluetooth_adapter_factory.cc ('k') | device/bluetooth/test/fake_bluetooth.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "device/bluetooth/bluetooth_adapter_factory_wrapper.h" 5 #include "device/bluetooth/bluetooth_adapter_factory_wrapper.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
(...skipping 22 matching lines...) Expand all
33 // static 33 // static
34 BluetoothAdapterFactoryWrapper& BluetoothAdapterFactoryWrapper::Get() { 34 BluetoothAdapterFactoryWrapper& BluetoothAdapterFactoryWrapper::Get() {
35 return g_singleton.Get(); 35 return g_singleton.Get();
36 } 36 }
37 37
38 bool BluetoothAdapterFactoryWrapper::IsLowEnergyAvailable() { 38 bool BluetoothAdapterFactoryWrapper::IsLowEnergyAvailable() {
39 DCHECK(thread_checker_.CalledOnValidThread()); 39 DCHECK(thread_checker_.CalledOnValidThread());
40 if (adapter_ != nullptr) { 40 if (adapter_ != nullptr) {
41 return true; 41 return true;
42 } 42 }
43 return BluetoothAdapterFactory::IsLowEnergyAvailable(); 43 return BluetoothAdapterFactory::Get().IsLowEnergyAvailable();
44 } 44 }
45 45
46 void BluetoothAdapterFactoryWrapper::AcquireAdapter( 46 void BluetoothAdapterFactoryWrapper::AcquireAdapter(
47 BluetoothAdapter::Observer* observer, 47 BluetoothAdapter::Observer* observer,
48 const AcquireAdapterCallback& callback) { 48 const AcquireAdapterCallback& callback) {
49 DCHECK(thread_checker_.CalledOnValidThread()); 49 DCHECK(thread_checker_.CalledOnValidThread());
50 DCHECK(!GetAdapter(observer)); 50 DCHECK(!GetAdapter(observer));
51 51
52 AddAdapterObserver(observer); 52 AddAdapterObserver(observer);
53 if (adapter_.get()) { 53 if (adapter_.get()) {
54 base::ThreadTaskRunnerHandle::Get()->PostTask( 54 base::ThreadTaskRunnerHandle::Get()->PostTask(
55 FROM_HERE, base::Bind(callback, base::Unretained(adapter_.get()))); 55 FROM_HERE, base::Bind(callback, base::Unretained(adapter_.get())));
56 return; 56 return;
57 } 57 }
58 58
59 DCHECK(BluetoothAdapterFactory::IsLowEnergyAvailable()); 59 DCHECK(BluetoothAdapterFactory::Get().IsLowEnergyAvailable());
60 BluetoothAdapterFactory::GetAdapter( 60 BluetoothAdapterFactory::GetAdapter(
61 base::Bind(&BluetoothAdapterFactoryWrapper::OnGetAdapter, 61 base::Bind(&BluetoothAdapterFactoryWrapper::OnGetAdapter,
62 weak_ptr_factory_.GetWeakPtr(), callback)); 62 weak_ptr_factory_.GetWeakPtr(), callback));
63 } 63 }
64 64
65 void BluetoothAdapterFactoryWrapper::ReleaseAdapter( 65 void BluetoothAdapterFactoryWrapper::ReleaseAdapter(
66 BluetoothAdapter::Observer* observer) { 66 BluetoothAdapter::Observer* observer) {
67 DCHECK(thread_checker_.CalledOnValidThread()); 67 DCHECK(thread_checker_.CalledOnValidThread());
68 if (!HasAdapter(observer)) { 68 if (!HasAdapter(observer)) {
69 return; 69 return;
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 } 142 }
143 adapter_ = adapter; 143 adapter_ = adapter;
144 if (adapter_.get()) { 144 if (adapter_.get()) {
145 for (BluetoothAdapter::Observer* observer : adapter_observers_) { 145 for (BluetoothAdapter::Observer* observer : adapter_observers_) {
146 adapter_->AddObserver(observer); 146 adapter_->AddObserver(observer);
147 } 147 }
148 } 148 }
149 } 149 }
150 150
151 } // namespace device 151 } // namespace device
OLDNEW
« no previous file with comments | « device/bluetooth/bluetooth_adapter_factory.cc ('k') | device/bluetooth/test/fake_bluetooth.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698