Index: chromeos/dbus/shill_manager_client.cc |
diff --git a/chromeos/dbus/shill_manager_client.cc b/chromeos/dbus/shill_manager_client.cc |
index 1be4bf22b04a1801d286489a89bb41974afb0ec4..563e219aafbe36a01252ea00fc568c32e60b563c 100644 |
--- a/chromeos/dbus/shill_manager_client.cc |
+++ b/chromeos/dbus/shill_manager_client.cc |
@@ -21,13 +21,41 @@ namespace chromeos { |
namespace { |
+const char kIncompleteServiceProperties[] = "Error.IncompleteServiceProperties"; |
+const char kIncompleteServicePropertiesMessage[] = |
+ "Service properties are incomplete."; |
+ |
// Returns whether the properties have the required keys or not. |
-bool AreServicePropertiesValid(const base::DictionaryValue& properties) { |
- if (properties.HasKey(flimflam::kGuidProperty)) |
+bool AreServicePropertiesValidWithMode( |
+ const base::DictionaryValue& properties, |
+ const ShillManagerClient::ErrorCallback& error_callback) { |
+ if (properties.HasKey(flimflam::kGuidProperty) || |
+ (properties.HasKey(flimflam::kTypeProperty) && |
+ properties.HasKey(flimflam::kSecurityProperty) && |
+ properties.HasKey(flimflam::kModeProperty) && |
+ properties.HasKey(flimflam::kSSIDProperty))) { |
return true; |
- return properties.HasKey(flimflam::kTypeProperty) && |
- properties.HasKey(flimflam::kSecurityProperty) && |
- properties.HasKey(flimflam::kSSIDProperty); |
+ } |
+ error_callback.Run(kIncompleteServiceProperties, |
+ kIncompleteServicePropertiesMessage); |
+ return false; |
+} |
+ |
+// DEPRECATED: Keep this only for backward compatibility with NetworkLibrary. |
+// Returns whether the properties have the required keys or not. |
+// TODO(pneubeck): remove this once NetworkLibrary is gone (crbug/230799). |
+bool AreServicePropertiesValid( |
+ const base::DictionaryValue& properties, |
+ const ShillManagerClient::ErrorCallback& error_callback) { |
+ if (properties.HasKey(flimflam::kGuidProperty) || |
+ (properties.HasKey(flimflam::kTypeProperty) && |
+ properties.HasKey(flimflam::kSecurityProperty) && |
+ properties.HasKey(flimflam::kSSIDProperty))) { |
+ return true; |
+ } |
+ error_callback.Run(kIncompleteServiceProperties, |
+ kIncompleteServicePropertiesMessage); |
+ return false; |
} |
// Appends a string-to-variant dictionary to the writer. |
@@ -146,7 +174,10 @@ class ShillManagerClientImpl : public ShillManagerClient { |
const base::DictionaryValue& properties, |
const ObjectPathCallback& callback, |
const ErrorCallback& error_callback) OVERRIDE { |
- DCHECK(AreServicePropertiesValid(properties)); |
+ if (!AreServicePropertiesValid(properties, error_callback)) { |
+ LOG(ERROR) << kIncompleteServicePropertiesMessage; |
+ return; |
+ } |
dbus::MethodCall method_call(flimflam::kFlimflamManagerInterface, |
flimflam::kConfigureServiceFunction); |
dbus::MessageWriter writer(&method_call); |
@@ -156,6 +187,25 @@ class ShillManagerClientImpl : public ShillManagerClient { |
error_callback); |
} |
+ virtual void ConfigureServiceForProfile( |
+ const dbus::ObjectPath& profile_path, |
+ const base::DictionaryValue& properties, |
+ const ObjectPathCallback& callback, |
+ const ErrorCallback& error_callback) OVERRIDE { |
+ if (!AreServicePropertiesValidWithMode(properties, error_callback)) { |
+ LOG(ERROR) << kIncompleteServicePropertiesMessage; |
pastarmovj
2013/04/16 11:31:18
You can make this NOTREACHED - it is like a DCHECK
pneubeck (no reviews)
2013/04/16 14:56:28
Done.
|
+ return; |
+ } |
+ dbus::MethodCall method_call(flimflam::kFlimflamManagerInterface, |
+ shill::kConfigureServiceForProfileFunction); |
+ dbus::MessageWriter writer(&method_call); |
+ writer.AppendObjectPath(dbus::ObjectPath(profile_path)); |
+ AppendServicePropertiesDictionary(&writer, properties); |
+ helper_.CallObjectPathMethodWithErrorCallback(&method_call, |
+ callback, |
+ error_callback); |
+ } |
+ |
virtual void GetService( |
const base::DictionaryValue& properties, |
const ObjectPathCallback& callback, |