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

Side by Side Diff: device/bluetooth/bluetooth_adapter.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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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.h" 5 #include "device/bluetooth/bluetooth_adapter.h"
6 6
7 #include "device/bluetooth/bluetooth_device.h" 7 #include "device/bluetooth/bluetooth_device.h"
8 8
9 namespace device { 9 namespace device {
10 10
11 BluetoothAdapter::BluetoothAdapter() { 11 BluetoothAdapter::BluetoothAdapter() {
12 } 12 }
13 13
14 BluetoothAdapter::~BluetoothAdapter() { 14 BluetoothAdapter::~BluetoothAdapter() {
15 } 15 }
16 16
17 const std::string& BluetoothAdapter::address() const { 17 const std::string& BluetoothAdapter::address() const {
18 return address_; 18 return address_;
19 } 19 }
20 20
21 const std::string& BluetoothAdapter::name() const { 21 const std::string& BluetoothAdapter::name() const {
22 return name_; 22 return name_;
23 } 23 }
24 24
25 void BluetoothAdapter::QueueAdapterCallback(const AdapterCallback& callback) {
26 adapter_callbacks_.push_back(callback);
27 }
28
29 BluetoothAdapter::DeviceList BluetoothAdapter::GetDevices() { 25 BluetoothAdapter::DeviceList BluetoothAdapter::GetDevices() {
30 ConstDeviceList const_devices = 26 ConstDeviceList const_devices =
31 const_cast<const BluetoothAdapter *>(this)->GetDevices(); 27 const_cast<const BluetoothAdapter *>(this)->GetDevices();
32 28
33 DeviceList devices; 29 DeviceList devices;
34 for (ConstDeviceList::const_iterator i = const_devices.begin(); 30 for (ConstDeviceList::const_iterator i = const_devices.begin();
35 i != const_devices.end(); ++i) 31 i != const_devices.end(); ++i)
36 devices.push_back(const_cast<BluetoothDevice *>(*i)); 32 devices.push_back(const_cast<BluetoothDevice *>(*i));
37 33
38 return devices; 34 return devices;
(...skipping 17 matching lines...) Expand all
56 const BluetoothDevice* BluetoothAdapter::GetDevice( 52 const BluetoothDevice* BluetoothAdapter::GetDevice(
57 const std::string& address) const { 53 const std::string& address) const {
58 DevicesMap::const_iterator iter = devices_.find(address); 54 DevicesMap::const_iterator iter = devices_.find(address);
59 if (iter != devices_.end()) 55 if (iter != devices_.end())
60 return iter->second; 56 return iter->second;
61 57
62 return NULL; 58 return NULL;
63 } 59 }
64 60
65 } // namespace device 61 } // namespace device
OLDNEW
« no previous file with comments | « device/bluetooth/bluetooth_adapter.h ('k') | device/bluetooth/bluetooth_adapter_chromeos_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698