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 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_WIN_H_ | 5 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_WIN_H_ |
6 #define DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_WIN_H_ | 6 #define DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_WIN_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <utility> | 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
| 12 #include "base/hash_tables.h" |
12 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
13 #include "base/memory/scoped_vector.h" | 14 #include "base/memory/scoped_vector.h" |
14 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
15 #include "base/threading/thread_checker.h" | 16 #include "base/threading/thread_checker.h" |
16 #include "device/bluetooth/bluetooth_adapter.h" | 17 #include "device/bluetooth/bluetooth_adapter.h" |
17 #include "device/bluetooth/bluetooth_task_manager_win.h" | 18 #include "device/bluetooth/bluetooth_task_manager_win.h" |
18 | 19 |
19 namespace base { | 20 namespace base { |
20 | 21 |
21 class SequencedTaskRunner; | 22 class SequencedTaskRunner; |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 | 60 |
60 // BluetoothTaskManagerWin::Observer override | 61 // BluetoothTaskManagerWin::Observer override |
61 virtual void AdapterStateChanged( | 62 virtual void AdapterStateChanged( |
62 const BluetoothTaskManagerWin::AdapterState& state) OVERRIDE; | 63 const BluetoothTaskManagerWin::AdapterState& state) OVERRIDE; |
63 virtual void DiscoveryStarted(bool success) OVERRIDE; | 64 virtual void DiscoveryStarted(bool success) OVERRIDE; |
64 virtual void DiscoveryStopped() OVERRIDE; | 65 virtual void DiscoveryStopped() OVERRIDE; |
65 virtual void DevicesDiscovered( | 66 virtual void DevicesDiscovered( |
66 const ScopedVector<BluetoothTaskManagerWin::DeviceState>& devices) | 67 const ScopedVector<BluetoothTaskManagerWin::DeviceState>& devices) |
67 OVERRIDE; | 68 OVERRIDE; |
68 | 69 |
| 70 virtual void DevicesUpdated( |
| 71 const ScopedVector<BluetoothTaskManagerWin::DeviceState>& devices) |
| 72 OVERRIDE; |
| 73 |
69 private: | 74 private: |
70 friend class BluetoothAdapterFactory; | 75 friend class BluetoothAdapterFactory; |
71 friend class BluetoothAdapterWinTest; | 76 friend class BluetoothAdapterWinTest; |
72 | 77 |
73 enum DiscoveryStatus { | 78 enum DiscoveryStatus { |
74 NOT_DISCOVERING, | 79 NOT_DISCOVERING, |
75 DISCOVERY_STARTING, | 80 DISCOVERY_STARTING, |
76 DISCOVERING, | 81 DISCOVERING, |
77 DISCOVERY_STOPPING | 82 DISCOVERY_STOPPING |
78 }; | 83 }; |
79 | 84 |
80 explicit BluetoothAdapterWin(const InitCallback& init_callback); | 85 explicit BluetoothAdapterWin(const InitCallback& init_callback); |
81 virtual ~BluetoothAdapterWin(); | 86 virtual ~BluetoothAdapterWin(); |
82 | 87 |
83 void Init(); | 88 void Init(); |
84 void InitForTest( | 89 void InitForTest( |
85 scoped_refptr<base::SequencedTaskRunner> ui_task_runner, | 90 scoped_refptr<base::SequencedTaskRunner> ui_task_runner, |
86 scoped_refptr<base::SequencedTaskRunner> bluetooth_task_runner); | 91 scoped_refptr<base::SequencedTaskRunner> bluetooth_task_runner); |
87 | 92 |
88 void MaybePostStartDiscoveryTask(); | 93 void MaybePostStartDiscoveryTask(); |
89 void MaybePostStopDiscoveryTask(); | 94 void MaybePostStopDiscoveryTask(); |
90 | 95 |
91 InitCallback init_callback_; | 96 InitCallback init_callback_; |
92 std::string address_; | 97 std::string address_; |
93 std::string name_; | 98 std::string name_; |
94 bool initialized_; | 99 bool initialized_; |
95 bool powered_; | 100 bool powered_; |
96 DiscoveryStatus discovery_status_; | 101 DiscoveryStatus discovery_status_; |
| 102 base::hash_set<std::string> discovered_devices_; |
97 | 103 |
98 std::vector<std::pair<base::Closure, ErrorCallback> > | 104 std::vector<std::pair<base::Closure, ErrorCallback> > |
99 on_start_discovery_callbacks_; | 105 on_start_discovery_callbacks_; |
100 std::vector<base::Closure> on_stop_discovery_callbacks_; | 106 std::vector<base::Closure> on_stop_discovery_callbacks_; |
101 size_t num_discovery_listeners_; | 107 size_t num_discovery_listeners_; |
102 | 108 |
103 scoped_refptr<base::SequencedTaskRunner> ui_task_runner_; | 109 scoped_refptr<base::SequencedTaskRunner> ui_task_runner_; |
104 scoped_refptr<BluetoothTaskManagerWin> task_manager_; | 110 scoped_refptr<BluetoothTaskManagerWin> task_manager_; |
105 | 111 |
106 base::ThreadChecker thread_checker_; | 112 base::ThreadChecker thread_checker_; |
107 | 113 |
108 // List of observers interested in event notifications from us. | 114 // List of observers interested in event notifications from us. |
109 ObserverList<BluetoothAdapter::Observer> observers_; | 115 ObserverList<BluetoothAdapter::Observer> observers_; |
110 | 116 |
111 // NOTE: This should remain the last member so it'll be destroyed and | 117 // NOTE: This should remain the last member so it'll be destroyed and |
112 // invalidate its weak pointers before any other members are destroyed. | 118 // invalidate its weak pointers before any other members are destroyed. |
113 base::WeakPtrFactory<BluetoothAdapterWin> weak_ptr_factory_; | 119 base::WeakPtrFactory<BluetoothAdapterWin> weak_ptr_factory_; |
114 | 120 |
115 DISALLOW_COPY_AND_ASSIGN(BluetoothAdapterWin); | 121 DISALLOW_COPY_AND_ASSIGN(BluetoothAdapterWin); |
116 }; | 122 }; |
117 | 123 |
118 } // namespace device | 124 } // namespace device |
119 | 125 |
120 #endif // DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_WIN_H_ | 126 #endif // DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_WIN_H_ |
OLD | NEW |