OLD | NEW |
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_factory.h" | 5 #include "device/bluetooth/bluetooth_adapter_factory.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 namespace device { | 61 namespace device { |
62 | 62 |
63 // static | 63 // static |
64 bool BluetoothAdapterFactory::IsBluetoothAdapterAvailable() { | 64 bool BluetoothAdapterFactory::IsBluetoothAdapterAvailable() { |
65 #if defined(OS_CHROMEOS) | 65 #if defined(OS_CHROMEOS) |
66 return true; | 66 return true; |
67 #elif defined(OS_WIN) | 67 #elif defined(OS_WIN) |
68 return true; | 68 return true; |
69 #elif defined(OS_MACOSX) | 69 #elif defined(OS_MACOSX) |
70 return base::mac::IsOSLionOrLater(); | 70 return base::mac::IsOSLionOrLater(); |
| 71 #else |
| 72 return false; |
71 #endif | 73 #endif |
72 return false; | |
73 } | 74 } |
74 | 75 |
75 // static | 76 // static |
76 void BluetoothAdapterFactory::GetAdapter(const AdapterCallback& callback) { | 77 void BluetoothAdapterFactory::GetAdapter(const AdapterCallback& callback) { |
77 if (!default_adapter.Get().get()) { | 78 if (!default_adapter.Get().get()) { |
78 #if defined(OS_CHROMEOS) | 79 #if defined(OS_CHROMEOS) |
79 chromeos::BluetoothAdapterChromeOS* new_adapter = | 80 chromeos::BluetoothAdapterChromeOS* new_adapter = |
80 new chromeos::BluetoothAdapterChromeOS(); | 81 new chromeos::BluetoothAdapterChromeOS(); |
81 default_adapter.Get() = new_adapter->weak_ptr_factory_.GetWeakPtr(); | 82 default_adapter.Get() = new_adapter->weak_ptr_factory_.GetWeakPtr(); |
82 #elif defined(OS_WIN) | 83 #elif defined(OS_WIN) |
(...skipping 14 matching lines...) Expand all Loading... |
97 adapter_callbacks.Get().push_back(callback); | 98 adapter_callbacks.Get().push_back(callback); |
98 } | 99 } |
99 } | 100 } |
100 | 101 |
101 // static | 102 // static |
102 scoped_refptr<BluetoothAdapter> BluetoothAdapterFactory::MaybeGetAdapter() { | 103 scoped_refptr<BluetoothAdapter> BluetoothAdapterFactory::MaybeGetAdapter() { |
103 return scoped_refptr<BluetoothAdapter>(default_adapter.Get().get()); | 104 return scoped_refptr<BluetoothAdapter>(default_adapter.Get().get()); |
104 } | 105 } |
105 | 106 |
106 } // namespace device | 107 } // namespace device |
OLD | NEW |