OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "components/wifi/fake_wifi_service.h" | 5 #include "components/wifi/fake_wifi_service.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
| 8 #include <utility> |
8 | 9 |
9 #include "base/bind.h" | 10 #include "base/bind.h" |
10 #include "base/message_loop/message_loop.h" | 11 #include "base/message_loop/message_loop.h" |
| 12 #include "base/values.h" |
11 #include "components/onc/onc_constants.h" | 13 #include "components/onc/onc_constants.h" |
12 | 14 |
13 namespace wifi { | 15 namespace wifi { |
14 | 16 |
15 FakeWiFiService::FakeWiFiService() { | 17 FakeWiFiService::FakeWiFiService() { |
16 // Populate data expected by unit test. | 18 // Populate data expected by unit test. |
17 { | 19 { |
18 NetworkProperties network_properties; | 20 NetworkProperties network_properties; |
19 network_properties.connection_state = onc::connection_state::kConnected; | 21 network_properties.connection_state = onc::connection_state::kConnected; |
20 network_properties.guid = "stub_wifi1_guid"; | 22 network_properties.guid = "stub_wifi1_guid"; |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 void FakeWiFiService::GetVisibleNetworks(const std::string& network_type, | 113 void FakeWiFiService::GetVisibleNetworks(const std::string& network_type, |
112 base::ListValue* network_list, | 114 base::ListValue* network_list, |
113 bool include_details) { | 115 bool include_details) { |
114 for (NetworkList::const_iterator it = networks_.begin(); | 116 for (NetworkList::const_iterator it = networks_.begin(); |
115 it != networks_.end(); | 117 it != networks_.end(); |
116 ++it) { | 118 ++it) { |
117 if (network_type.empty() || network_type == onc::network_type::kAllTypes || | 119 if (network_type.empty() || network_type == onc::network_type::kAllTypes || |
118 it->type == network_type) { | 120 it->type == network_type) { |
119 std::unique_ptr<base::DictionaryValue> network( | 121 std::unique_ptr<base::DictionaryValue> network( |
120 it->ToValue(!include_details)); | 122 it->ToValue(!include_details)); |
121 network_list->Append(network.release()); | 123 network_list->Append(std::move(network)); |
122 } | 124 } |
123 } | 125 } |
124 } | 126 } |
125 | 127 |
126 void FakeWiFiService::RequestNetworkScan() { | 128 void FakeWiFiService::RequestNetworkScan() { |
127 NotifyNetworkListChanged(networks_); | 129 NotifyNetworkListChanged(networks_); |
128 } | 130 } |
129 | 131 |
130 void FakeWiFiService::StartConnect(const std::string& network_guid, | 132 void FakeWiFiService::StartConnect(const std::string& network_guid, |
131 std::string* error) { | 133 std::string* error) { |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 FROM_HERE, base::Bind(network_list_changed_observer_, current_networks)); | 215 FROM_HERE, base::Bind(network_list_changed_observer_, current_networks)); |
214 } | 216 } |
215 | 217 |
216 void FakeWiFiService::NotifyNetworkChanged(const std::string& network_guid) { | 218 void FakeWiFiService::NotifyNetworkChanged(const std::string& network_guid) { |
217 WiFiService::NetworkGuidList changed_networks(1, network_guid); | 219 WiFiService::NetworkGuidList changed_networks(1, network_guid); |
218 task_runner_->PostTask( | 220 task_runner_->PostTask( |
219 FROM_HERE, base::Bind(networks_changed_observer_, changed_networks)); | 221 FROM_HERE, base::Bind(networks_changed_observer_, changed_networks)); |
220 } | 222 } |
221 | 223 |
222 } // namespace wifi | 224 } // namespace wifi |
OLD | NEW |