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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chromeos/network/managed_state.h" 5 #include "chromeos/network/managed_state.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/values.h" 8 #include "base/values.h"
9 #include "chromeos/network/device_state.h" 9 #include "chromeos/network/device_state.h"
10 #include "chromeos/network/network_event_log.h"
10 #include "chromeos/network/network_state.h" 11 #include "chromeos/network/network_state.h"
11 #include "third_party/cros_system_api/dbus/service_constants.h" 12 #include "third_party/cros_system_api/dbus/service_constants.h"
12 13
13 namespace chromeos { 14 namespace chromeos {
14 15
15 ManagedState::ManagedState(ManagedType type, const std::string& path) 16 ManagedState::ManagedState(ManagedType type, const std::string& path)
16 : managed_type_(type), 17 : managed_type_(type),
17 path_(path), 18 path_(path),
18 is_observed_(false) { 19 is_observed_(false) {
19 } 20 }
20 21
21 ManagedState::~ManagedState() { 22 ManagedState::~ManagedState() {
22 } 23 }
23 24
24 ManagedState* ManagedState::Create(ManagedType type, const std::string& path) { 25 ManagedState* ManagedState::Create(ManagedType type, const std::string& path) {
25 switch(type) { 26 switch (type) {
26 case MANAGED_TYPE_NETWORK: 27 case MANAGED_TYPE_NETWORK:
27 return new NetworkState(path); 28 return new NetworkState(path);
28 case MANAGED_TYPE_DEVICE: 29 case MANAGED_TYPE_DEVICE:
29 return new DeviceState(path); 30 return new DeviceState(path);
30 } 31 }
31 return NULL; 32 return NULL;
32 } 33 }
33 34
34 NetworkState* ManagedState::AsNetworkState() { 35 NetworkState* ManagedState::AsNetworkState() {
35 if (managed_type() == MANAGED_TYPE_NETWORK) 36 if (managed_type() == MANAGED_TYPE_NETWORK)
(...skipping 16 matching lines...) Expand all
52 return GetStringValue(key, value, &name_); 53 return GetStringValue(key, value, &name_);
53 } else if (key == flimflam::kTypeProperty) { 54 } else if (key == flimflam::kTypeProperty) {
54 return GetStringValue(key, value, &type_); 55 return GetStringValue(key, value, &type_);
55 } 56 }
56 return false; 57 return false;
57 } 58 }
58 59
59 bool ManagedState::GetBooleanValue(const std::string& key, 60 bool ManagedState::GetBooleanValue(const std::string& key,
60 const base::Value& value, 61 const base::Value& value,
61 bool* out_value) { 62 bool* out_value) {
62 bool res = value.GetAsBoolean(out_value); 63 bool new_value;
gauravsh 2013/05/14 23:01:20 I think you need to rebase since this is now part
63 if (!res) 64 if (!value.GetAsBoolean(&new_value)) {
64 LOG(WARNING) << "Failed to parse boolean value for:" << key; 65 NET_LOG_ERROR("Error parsing state value", path() + "." + key);
65 return res; 66 return false;
67 }
68 if (*out_value == new_value)
69 return false;
70 *out_value = new_value;
71 return true;
66 } 72 }
67 73
68 bool ManagedState::GetIntegerValue(const std::string& key, 74 bool ManagedState::GetIntegerValue(const std::string& key,
69 const base::Value& value, 75 const base::Value& value,
70 int* out_value) { 76 int* out_value) {
71 bool res = value.GetAsInteger(out_value); 77 int new_value;
72 if (!res) 78 if (!value.GetAsInteger(&new_value)) {
73 LOG(WARNING) << "Failed to parse integer value for:" << key; 79 NET_LOG_ERROR("Error parsing state value", path() + "." + key);
74 return res; 80 return false;
81 }
82 if (*out_value == new_value)
83 return false;
84 *out_value = new_value;
85 return true;
75 } 86 }
76 87
77 bool ManagedState::GetStringValue(const std::string& key, 88 bool ManagedState::GetStringValue(const std::string& key,
78 const base::Value& value, 89 const base::Value& value,
79 std::string* out_value) { 90 std::string* out_value) {
80 bool res = value.GetAsString(out_value); 91 std::string new_value;
81 if (!res) 92 if (!value.GetAsString(&new_value)) {
82 LOG(WARNING) << "Failed to parse string value for:" << key; 93 NET_LOG_ERROR("Error parsing state value", path() + "." + key);
83 return res; 94 return false;
95 }
96 if (*out_value == new_value)
97 return false;
98 *out_value = new_value;
99 return true;
84 } 100 }
85 101
86 } // namespace chromeos 102 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698