| Index: chromeos/network/managed_state.cc
|
| diff --git a/chromeos/network/managed_state.cc b/chromeos/network/managed_state.cc
|
| index 5d9ffe3e82ac4e87a56de8a194593ba489992926..b91d4a022c38a7905ea7c24296205369b75e8a3d 100644
|
| --- a/chromeos/network/managed_state.cc
|
| +++ b/chromeos/network/managed_state.cc
|
| @@ -7,6 +7,7 @@
|
| #include "base/logging.h"
|
| #include "base/values.h"
|
| #include "chromeos/network/device_state.h"
|
| +#include "chromeos/network/network_event_log.h"
|
| #include "chromeos/network/network_state.h"
|
| #include "third_party/cros_system_api/dbus/service_constants.h"
|
|
|
| @@ -22,7 +23,7 @@ ManagedState::~ManagedState() {
|
| }
|
|
|
| ManagedState* ManagedState::Create(ManagedType type, const std::string& path) {
|
| - switch(type) {
|
| + switch (type) {
|
| case MANAGED_TYPE_NETWORK:
|
| return new NetworkState(path);
|
| case MANAGED_TYPE_DEVICE:
|
| @@ -59,28 +60,43 @@ bool ManagedState::ManagedStatePropertyChanged(const std::string& key,
|
| bool ManagedState::GetBooleanValue(const std::string& key,
|
| const base::Value& value,
|
| bool* out_value) {
|
| - bool res = value.GetAsBoolean(out_value);
|
| - if (!res)
|
| - LOG(WARNING) << "Failed to parse boolean value for:" << key;
|
| - return res;
|
| + bool new_value;
|
| + if (!value.GetAsBoolean(&new_value)) {
|
| + NET_LOG_ERROR("Error parsing state value", path() + "." + key);
|
| + return false;
|
| + }
|
| + if (*out_value == new_value)
|
| + return false;
|
| + *out_value = new_value;
|
| + return true;
|
| }
|
|
|
| bool ManagedState::GetIntegerValue(const std::string& key,
|
| const base::Value& value,
|
| int* out_value) {
|
| - bool res = value.GetAsInteger(out_value);
|
| - if (!res)
|
| - LOG(WARNING) << "Failed to parse integer value for:" << key;
|
| - return res;
|
| + int new_value;
|
| + if (!value.GetAsInteger(&new_value)) {
|
| + NET_LOG_ERROR("Error parsing state value", path() + "." + key);
|
| + return false;
|
| + }
|
| + if (*out_value == new_value)
|
| + return false;
|
| + *out_value = new_value;
|
| + return true;
|
| }
|
|
|
| bool ManagedState::GetStringValue(const std::string& key,
|
| const base::Value& value,
|
| std::string* out_value) {
|
| - bool res = value.GetAsString(out_value);
|
| - if (!res)
|
| - LOG(WARNING) << "Failed to parse string value for:" << key;
|
| - return res;
|
| + std::string new_value;
|
| + if (!value.GetAsString(&new_value)) {
|
| + NET_LOG_ERROR("Error parsing state value", path() + "." + key);
|
| + return false;
|
| + }
|
| + if (*out_value == new_value)
|
| + return false;
|
| + *out_value = new_value;
|
| + return true;
|
| }
|
|
|
| } // namespace chromeos
|
|
|