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

Unified Diff: chromeos/network/managed_state.cc

Issue 14876021: Re-factor network_event_log (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase with NetworkConnectionHandler Created 7 years, 7 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/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;
gauravsh 2013/05/14 23:01:20 I think you need to rebase since this is now part
+ 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

Powered by Google App Engine
This is Rietveld 408576698