Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(796)

Side by Side Diff: chrome/utility/wifi/wifi_service_mock.cc

Issue 30753002: Move GetVisibleNetworks network type filtering to WiFiService interface. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "chrome/utility/wifi/wifi_service.h" 5 #include "chrome/utility/wifi/wifi_service.h"
6 #include "base/message_loop/message_loop.h" 6 #include "base/message_loop/message_loop.h"
7 #include "components/onc/onc_constants.h" 7 #include "components/onc/onc_constants.h"
8 8
9 namespace wifi { 9 namespace wifi {
10 10
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 if (network_properties != networks_.end() && 106 if (network_properties != networks_.end() &&
107 network_properties->UpdateFromValue(properties)) { 107 network_properties->UpdateFromValue(properties)) {
108 callback.Run(network_guid); 108 callback.Run(network_guid);
109 } else { 109 } else {
110 scoped_ptr<base::DictionaryValue> error_data(new base::DictionaryValue); 110 scoped_ptr<base::DictionaryValue> error_data(new base::DictionaryValue);
111 error_callback.Run("Error.DBusFailed", error_data.Pass()); 111 error_callback.Run("Error.DBusFailed", error_data.Pass());
112 } 112 }
113 } 113 }
114 114
115 virtual void GetVisibleNetworks( 115 virtual void GetVisibleNetworks(
116 const std::string& network_type,
116 const NetworkListCallback& callback, 117 const NetworkListCallback& callback,
117 const ErrorCallback& error_callback) OVERRIDE { 118 const ErrorCallback& error_callback) OVERRIDE {
118 callback.Run(networks_); 119 if (network_type.empty() || network_type == onc::network_type::kAllTypes) {
120 callback.Run(networks_);
121 } else {
122 NetworkList filtered_networks;
123 for (NetworkList::iterator it = networks_.begin(); it != networks_.end();
124 ++it) {
tbarzic 2013/10/23 00:30:24 align ++it with NetworkList
mef 2013/10/23 13:00:24 Done.
125 if (it->type == network_type)
126 filtered_networks.push_back(*it);
127 }
128 callback.Run(filtered_networks);
129 }
119 } 130 }
120 131
121 virtual void RequestNetworkScan() OVERRIDE {} 132 virtual void RequestNetworkScan() OVERRIDE {}
122 133
123 virtual void StartConnect(const std::string& network_guid, 134 virtual void StartConnect(const std::string& network_guid,
124 const StringResultCallback& callback, 135 const StringResultCallback& callback,
125 const ErrorCallback& error_callback) OVERRIDE { 136 const ErrorCallback& error_callback) OVERRIDE {
126 NetworkList::iterator network_properties = FindNetwork(network_guid); 137 NetworkList::iterator network_properties = FindNetwork(network_guid);
127 if (network_properties != networks_.end()) { 138 if (network_properties != networks_.end()) {
128 DisconnectAllNetworksOfType(network_properties->type); 139 DisconnectAllNetworksOfType(network_properties->type);
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 216
206 NetworkList networks_; 217 NetworkList networks_;
207 NetworkGuidListCallback networks_changed_observer_; 218 NetworkGuidListCallback networks_changed_observer_;
208 NetworkGuidListCallback network_list_changed_observer_; 219 NetworkGuidListCallback network_list_changed_observer_;
209 }; 220 };
210 221
211 WiFiService* WiFiService::CreateServiceMock() { return new WiFiServiceMock(); } 222 WiFiService* WiFiService::CreateServiceMock() { return new WiFiServiceMock(); }
212 WiFiService* WiFiService::CreateService() { return new WiFiServiceMock(); } 223 WiFiService* WiFiService::CreateService() { return new WiFiServiceMock(); }
213 224
214 } // namespace wifi 225 } // namespace wifi
OLDNEW
« chrome/common/networking_private_messages.h ('K') | « chrome/utility/wifi/wifi_service.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698