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

Unified Diff: chromeos/dbus/fake_shill_device_client.cc

Issue 1028243007: Call Device.SetCarrier when the ONC Carrier property is specified. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@onc_clang
Patch Set: . Created 5 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: chromeos/dbus/fake_shill_device_client.cc
diff --git a/chromeos/dbus/fake_shill_device_client.cc b/chromeos/dbus/fake_shill_device_client.cc
index 5475fd8a62dcf36612e8fa6d4bb6f624ad7e35e6..549d06f4a66103c01a5ff3f24e3e73674f662152 100644
--- a/chromeos/dbus/fake_shill_device_client.cc
+++ b/chromeos/dbus/fake_shill_device_client.cc
@@ -34,12 +34,20 @@ void ErrorFunction(const std::string& device_path,
<< ": " << error_name << " : " << error_message;
}
-void PostNotFoundError(
- const ShillDeviceClient::ErrorCallback& error_callback) {
- std::string error_message("Failed");
+void PostError(const std::string& error,
+ const ShillDeviceClient::ErrorCallback& error_callback) {
base::MessageLoop::current()->PostTask(
- FROM_HERE,
- base::Bind(error_callback, shill::kErrorResultNotFound, error_message));
+ FROM_HERE, base::Bind(error_callback, error, "Failed"));
pneubeck (no reviews) 2015/03/27 18:26:46 I don't feel particularly confident in Bind + cons
stevenjb 2015/03/27 23:18:04 I'm pretty sure it will get converted to a string,
+}
+
+void PostNotFoundError(const ShillDeviceClient::ErrorCallback& error_callback) {
+ PostError(shill::kErrorResultNotFound, error_callback);
+}
+
+bool IsReadOnlyProperty(const std::string& name) {
+ if (name == shill::kCarrierProperty)
+ return true;
+ return false;
}
} // namespace
@@ -92,6 +100,17 @@ void FakeShillDeviceClient::SetProperty(const dbus::ObjectPath& device_path,
const base::Value& value,
const base::Closure& callback,
const ErrorCallback& error_callback) {
+ if (IsReadOnlyProperty(name))
+ PostError(shill::kErrorResultInvalidArguments, error_callback);
+ AlwaysSetProperty(device_path, name, value, callback, error_callback);
+}
+
+void FakeShillDeviceClient::AlwaysSetProperty(
+ const dbus::ObjectPath& device_path,
+ const std::string& name,
+ const base::Value& value,
+ const base::Closure& callback,
+ const ErrorCallback& error_callback) {
base::DictionaryValue* device_properties = NULL;
if (!stub_devices_.GetDictionaryWithoutPathExpansion(device_path.value(),
&device_properties)) {
@@ -225,11 +244,8 @@ void FakeShillDeviceClient::SetCarrier(const dbus::ObjectPath& device_path,
const std::string& carrier,
const base::Closure& callback,
const ErrorCallback& error_callback) {
- if (!stub_devices_.HasKey(device_path.value())) {
- PostNotFoundError(error_callback);
- return;
- }
- base::MessageLoop::current()->PostTask(FROM_HERE, callback);
+ AlwaysSetProperty(device_path, shill::kCarrierProperty,
+ base::StringValue(carrier), callback, error_callback);
}
void FakeShillDeviceClient::Reset(const dbus::ObjectPath& device_path,

Powered by Google App Engine
This is Rietveld 408576698