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 24 matching lines...) Expand all Loading... |
35 | 35 |
36 typedef std::vector<BluetoothAdapterFactory::AdapterCallback> | 36 typedef std::vector<BluetoothAdapterFactory::AdapterCallback> |
37 AdapterCallbackList; | 37 AdapterCallbackList; |
38 | 38 |
39 // List of adapter callbacks to be called once the adapter is initialized. | 39 // List of adapter callbacks to be called once the adapter is initialized. |
40 // Since Google C++ Style (and clang's static analyzer) forbids us having | 40 // Since Google C++ Style (and clang's static analyzer) forbids us having |
41 // exit-time destructors we use a lazy instance for it. | 41 // exit-time destructors we use a lazy instance for it. |
42 base::LazyInstance<AdapterCallbackList> adapter_callbacks = | 42 base::LazyInstance<AdapterCallbackList> adapter_callbacks = |
43 LAZY_INSTANCE_INITIALIZER; | 43 LAZY_INSTANCE_INITIALIZER; |
44 | 44 |
| 45 #if defined(OS_WIN) |
45 void RunAdapterCallbacks() { | 46 void RunAdapterCallbacks() { |
46 CHECK(default_adapter.Get().get()); | 47 CHECK(default_adapter.Get().get()); |
47 scoped_refptr<BluetoothAdapter> adapter(default_adapter.Get().get()); | 48 scoped_refptr<BluetoothAdapter> adapter(default_adapter.Get().get()); |
48 for (std::vector<BluetoothAdapterFactory::AdapterCallback>::const_iterator | 49 for (std::vector<BluetoothAdapterFactory::AdapterCallback>::const_iterator |
49 iter = adapter_callbacks.Get().begin(); | 50 iter = adapter_callbacks.Get().begin(); |
50 iter != adapter_callbacks.Get().end(); | 51 iter != adapter_callbacks.Get().end(); |
51 ++iter) { | 52 ++iter) { |
52 iter->Run(adapter); | 53 iter->Run(adapter); |
53 } | 54 } |
54 adapter_callbacks.Get().clear(); | 55 adapter_callbacks.Get().clear(); |
55 } | 56 } |
| 57 #endif // defined(OS_WIN) |
56 | 58 |
57 } // namespace | 59 } // namespace |
58 | 60 |
59 namespace device { | 61 namespace device { |
60 | 62 |
61 // static | 63 // static |
62 bool BluetoothAdapterFactory::IsBluetoothAdapterAvailable() { | 64 bool BluetoothAdapterFactory::IsBluetoothAdapterAvailable() { |
63 #if defined(OS_CHROMEOS) | 65 #if defined(OS_CHROMEOS) |
64 return true; | 66 return true; |
65 #elif defined(OS_WIN) | 67 #elif defined(OS_WIN) |
(...skipping 29 matching lines...) Expand all Loading... |
95 adapter_callbacks.Get().push_back(callback); | 97 adapter_callbacks.Get().push_back(callback); |
96 } | 98 } |
97 } | 99 } |
98 | 100 |
99 // static | 101 // static |
100 scoped_refptr<BluetoothAdapter> BluetoothAdapterFactory::MaybeGetAdapter() { | 102 scoped_refptr<BluetoothAdapter> BluetoothAdapterFactory::MaybeGetAdapter() { |
101 return scoped_refptr<BluetoothAdapter>(default_adapter.Get().get()); | 103 return scoped_refptr<BluetoothAdapter>(default_adapter.Get().get()); |
102 } | 104 } |
103 | 105 |
104 } // namespace device | 106 } // namespace device |
OLD | NEW |