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

Side by Side Diff: chromeos/dbus/shill_manager_client_stub.cc

Issue 12676017: Adding policy support to the new network configuration stack. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed clang errors. Created 7 years, 8 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
« no previous file with comments | « chromeos/dbus/shill_manager_client_stub.h ('k') | chromeos/dbus/shill_profile_client.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 "chromeos/dbus/shill_manager_client_stub.h" 5 #include "chromeos/dbus/shill_manager_client_stub.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/chromeos/chromeos_version.h" 8 #include "base/chromeos/chromeos_version.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
11 #include "base/values.h" 11 #include "base/values.h"
12 #include "chromeos/chromeos_switches.h" 12 #include "chromeos/chromeos_switches.h"
13 #include "chromeos/dbus/dbus_thread_manager.h" 13 #include "chromeos/dbus/dbus_thread_manager.h"
14 #include "chromeos/dbus/shill_device_client.h" 14 #include "chromeos/dbus/shill_device_client.h"
15 #include "chromeos/dbus/shill_profile_client.h"
15 #include "chromeos/dbus/shill_property_changed_observer.h" 16 #include "chromeos/dbus/shill_property_changed_observer.h"
16 #include "chromeos/dbus/shill_service_client.h" 17 #include "chromeos/dbus/shill_service_client.h"
17 #include "dbus/bus.h" 18 #include "dbus/bus.h"
18 #include "dbus/message.h" 19 #include "dbus/message.h"
19 #include "dbus/object_path.h" 20 #include "dbus/object_path.h"
20 #include "dbus/object_proxy.h" 21 #include "dbus/object_proxy.h"
21 #include "dbus/values_util.h" 22 #include "dbus/values_util.h"
22 #include "third_party/cros_system_api/dbus/service_constants.h" 23 #include "third_party/cros_system_api/dbus/service_constants.h"
23 24
24 namespace chromeos { 25 namespace chromeos {
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 } 176 }
176 } 177 }
177 178
178 void ShillManagerClientStub::ConfigureService( 179 void ShillManagerClientStub::ConfigureService(
179 const base::DictionaryValue& properties, 180 const base::DictionaryValue& properties,
180 const ObjectPathCallback& callback, 181 const ObjectPathCallback& callback,
181 const ErrorCallback& error_callback) { 182 const ErrorCallback& error_callback) {
182 if (callback.is_null()) 183 if (callback.is_null())
183 return; 184 return;
184 185
185 // For the purposes of this stub, we're going to assume that the GUID property
186 // is set to the service path because we don't want to re-implement Shill's
187 // property matching magic here.
188 ShillServiceClient::TestInterface* service_client = 186 ShillServiceClient::TestInterface* service_client =
189 DBusThreadManager::Get()->GetShillServiceClient()->GetTestInterface(); 187 DBusThreadManager::Get()->GetShillServiceClient()->GetTestInterface();
190 188
191 std::string guid; 189 std::string guid;
192 std::string type; 190 std::string type;
193 if (!properties.GetString(flimflam::kGuidProperty, &guid) || 191 if (!properties.GetString(flimflam::kGuidProperty, &guid) ||
194 !properties.GetString(flimflam::kTypeProperty, &type)) { 192 !properties.GetString(flimflam::kTypeProperty, &type)) {
195 // If the properties aren't filled out completely, then just return an empty 193 // If the properties aren't filled out completely, then just return an empty
196 // object path. 194 // object path.
197 MessageLoop::current()->PostTask( 195 MessageLoop::current()->PostTask(
198 FROM_HERE, base::Bind(callback, dbus::ObjectPath())); 196 FROM_HERE, base::Bind(callback, dbus::ObjectPath()));
199 return; 197 return;
200 } 198 }
201 199
200 // For the purposes of this stub, we're going to assume that the GUID property
201 // is set to the service path because we don't want to re-implement Shill's
202 // property matching magic here.
203 std::string service_path = guid;
204
202 std::string ipconfig_path; 205 std::string ipconfig_path;
203 properties.GetString(shill::kIPConfigProperty, &ipconfig_path); 206 properties.GetString(shill::kIPConfigProperty, &ipconfig_path);
204 207
205 // Add the service to the service client stub if not already there.
206 service_client->AddServiceWithIPConfig(guid, guid, type, flimflam::kStateIdle,
207 ipconfig_path, true);
208 208
209 // Merge the new properties with existing properties, if any. 209 // Merge the new properties with existing properties, if any.
210 scoped_ptr<base::DictionaryValue> merged_properties;
211 const base::DictionaryValue* existing_properties = 210 const base::DictionaryValue* existing_properties =
212 service_client->GetServiceProperties(guid); 211 service_client->GetServiceProperties(service_path);
213 if (existing_properties) { 212 if (!existing_properties) {
214 merged_properties.reset(existing_properties->DeepCopy()); 213 // Add a new service to the service client stub because none exists, yet.
215 } else { 214 service_client->AddServiceWithIPConfig(service_path, guid, type,
216 merged_properties.reset(new base::DictionaryValue); 215 flimflam::kStateIdle, ipconfig_path,
216 true); // Add service to watch list.
217 existing_properties = service_client->GetServiceProperties(service_path);
217 } 218 }
219
220 scoped_ptr<base::DictionaryValue> merged_properties(
221 existing_properties->DeepCopy());
218 merged_properties->MergeDictionary(&properties); 222 merged_properties->MergeDictionary(&properties);
219 223
220 // Now set all the properties. 224 // Now set all the properties.
221 for (base::DictionaryValue::Iterator iter(*merged_properties); 225 for (base::DictionaryValue::Iterator iter(*merged_properties);
222 !iter.IsAtEnd(); iter.Advance()) { 226 !iter.IsAtEnd(); iter.Advance()) {
223 service_client->SetServiceProperty(guid, iter.key(), iter.value()); 227 service_client->SetServiceProperty(service_path, iter.key(), iter.value());
224 } 228 }
225 229
230 ShillProfileClient::TestInterface* profile_test =
231 DBusThreadManager::Get()->GetShillProfileClient()->GetTestInterface();
232 profile_test->AddService(service_path);
233
226 MessageLoop::current()->PostTask( 234 MessageLoop::current()->PostTask(
227 FROM_HERE, base::Bind(callback, dbus::ObjectPath(guid))); 235 FROM_HERE, base::Bind(callback, dbus::ObjectPath(service_path)));
228 } 236 }
229 237
238 void ShillManagerClientStub::ConfigureServiceForProfile(
239 const dbus::ObjectPath& profile_path,
240 const base::DictionaryValue& properties,
241 const ObjectPathCallback& callback,
242 const ErrorCallback& error_callback) {
243 std::string profile_property;
244 properties.GetStringWithoutPathExpansion(flimflam::kProfileProperty,
245 &profile_property);
246 CHECK(profile_property == profile_path.value());
247 ConfigureService(properties, callback, error_callback);
248 }
249
250
230 void ShillManagerClientStub::GetService( 251 void ShillManagerClientStub::GetService(
231 const base::DictionaryValue& properties, 252 const base::DictionaryValue& properties,
232 const ObjectPathCallback& callback, 253 const ObjectPathCallback& callback,
233 const ErrorCallback& error_callback) { 254 const ErrorCallback& error_callback) {
234 if (callback.is_null()) 255 if (callback.is_null())
235 return; 256 return;
236 MessageLoop::current()->PostTask( 257 MessageLoop::current()->PostTask(
237 FROM_HERE, base::Bind(callback, dbus::ObjectPath())); 258 FROM_HERE, base::Bind(callback, dbus::ObjectPath()));
238 } 259 }
239 260
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after
586 base::FundamentalValue(false)); 607 base::FundamentalValue(false));
587 } 608 }
588 CallNotifyObserversPropertyChanged(flimflam::kServicesProperty, 0); 609 CallNotifyObserversPropertyChanged(flimflam::kServicesProperty, 0);
589 CallNotifyObserversPropertyChanged(flimflam::kServiceWatchListProperty, 610 CallNotifyObserversPropertyChanged(flimflam::kServiceWatchListProperty,
590 0); 611 0);
591 if (!callback.is_null()) 612 if (!callback.is_null())
592 MessageLoop::current()->PostTask(FROM_HERE, callback); 613 MessageLoop::current()->PostTask(FROM_HERE, callback);
593 } 614 }
594 615
595 } // namespace chromeos 616 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/dbus/shill_manager_client_stub.h ('k') | chromeos/dbus/shill_profile_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698