| 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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 adapter_callbacks.Get().clear(); | 55 adapter_callbacks.Get().clear(); |
| 56 } | 56 } |
| 57 #endif // defined(OS_WIN) | 57 #endif // defined(OS_WIN) |
| 58 | 58 |
| 59 } // namespace | 59 } // namespace |
| 60 | 60 |
| 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) || defined(OS_WIN) |
| 66 return true; | |
| 67 #elif defined(OS_WIN) | |
| 68 return true; | 66 return true; |
| 69 #elif defined(OS_MACOSX) | 67 #elif defined(OS_MACOSX) |
| 70 return base::mac::IsOSLionOrLater(); | 68 return base::mac::IsOSLionOrLater(); |
| 69 #else |
| 70 return false; |
| 71 #endif | 71 #endif |
| 72 return false; | |
| 73 } | 72 } |
| 74 | 73 |
| 75 // static | 74 // static |
| 76 void BluetoothAdapterFactory::GetAdapter(const AdapterCallback& callback) { | 75 void BluetoothAdapterFactory::GetAdapter(const AdapterCallback& callback) { |
| 77 if (!default_adapter.Get().get()) { | 76 if (!default_adapter.Get().get()) { |
| 78 #if defined(OS_CHROMEOS) | 77 #if defined(OS_CHROMEOS) |
| 79 chromeos::BluetoothAdapterChromeOS* new_adapter = | 78 chromeos::BluetoothAdapterChromeOS* new_adapter = |
| 80 new chromeos::BluetoothAdapterChromeOS(); | 79 new chromeos::BluetoothAdapterChromeOS(); |
| 81 default_adapter.Get() = new_adapter->weak_ptr_factory_.GetWeakPtr(); | 80 default_adapter.Get() = new_adapter->weak_ptr_factory_.GetWeakPtr(); |
| 82 #elif defined(OS_WIN) | 81 #elif defined(OS_WIN) |
| (...skipping 14 matching lines...) Expand all Loading... |
| 97 adapter_callbacks.Get().push_back(callback); | 96 adapter_callbacks.Get().push_back(callback); |
| 98 } | 97 } |
| 99 } | 98 } |
| 100 | 99 |
| 101 // static | 100 // static |
| 102 scoped_refptr<BluetoothAdapter> BluetoothAdapterFactory::MaybeGetAdapter() { | 101 scoped_refptr<BluetoothAdapter> BluetoothAdapterFactory::MaybeGetAdapter() { |
| 103 return scoped_refptr<BluetoothAdapter>(default_adapter.Get().get()); | 102 return scoped_refptr<BluetoothAdapter>(default_adapter.Get().get()); |
| 104 } | 103 } |
| 105 | 104 |
| 106 } // namespace device | 105 } // namespace device |
| OLD | NEW |