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

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: Fix components_unittests 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
« no previous file with comments | « chromeos/dbus/fake_shill_device_client.h ('k') | chromeos/network/managed_network_configuration_handler.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..a856bb297dd0f921d3a3847d8ff502dcece94e91 100644
--- a/chromeos/dbus/fake_shill_device_client.cc
+++ b/chromeos/dbus/fake_shill_device_client.cc
@@ -26,6 +26,7 @@ namespace chromeos {
namespace {
std::string kSimPin = "1111";
+std::string kFailedMessage = "Failed";
void ErrorFunction(const std::string& device_path,
const std::string& error_name,
@@ -34,12 +35,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, kFailedMessage));
+}
+
+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 +101,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);
+ SetPropertyInternal(device_path, name, value, callback, error_callback);
+}
+
+void FakeShillDeviceClient::SetPropertyInternal(
+ 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 +245,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);
+ SetPropertyInternal(device_path, shill::kCarrierProperty,
+ base::StringValue(carrier), callback, error_callback);
}
void FakeShillDeviceClient::Reset(const dbus::ObjectPath& device_path,
« no previous file with comments | « chromeos/dbus/fake_shill_device_client.h ('k') | chromeos/network/managed_network_configuration_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698