| OLD | NEW |
| 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 <stdint.h> |
| 8 |
| 7 #include "base/logging.h" | 9 #include "base/logging.h" |
| 8 #include "base/values.h" | 10 #include "base/values.h" |
| 9 #include "chromeos/network/device_state.h" | 11 #include "chromeos/network/device_state.h" |
| 10 #include "chromeos/network/network_event_log.h" | 12 #include "chromeos/network/network_event_log.h" |
| 11 #include "chromeos/network/network_state.h" | 13 #include "chromeos/network/network_state.h" |
| 12 #include "chromeos/network/network_type_pattern.h" | 14 #include "chromeos/network/network_type_pattern.h" |
| 13 #include "third_party/cros_system_api/dbus/service_constants.h" | 15 #include "third_party/cros_system_api/dbus/service_constants.h" |
| 14 | 16 |
| 15 namespace chromeos { | 17 namespace chromeos { |
| 16 | 18 |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 return false; | 120 return false; |
| 119 } | 121 } |
| 120 if (*out_value == new_value) | 122 if (*out_value == new_value) |
| 121 return false; | 123 return false; |
| 122 *out_value = new_value; | 124 *out_value = new_value; |
| 123 return true; | 125 return true; |
| 124 } | 126 } |
| 125 | 127 |
| 126 bool ManagedState::GetUInt32Value(const std::string& key, | 128 bool ManagedState::GetUInt32Value(const std::string& key, |
| 127 const base::Value& value, | 129 const base::Value& value, |
| 128 uint32* out_value) { | 130 uint32_t* out_value) { |
| 129 // base::Value restricts the number types to BOOL, INTEGER, and DOUBLE only. | 131 // base::Value restricts the number types to BOOL, INTEGER, and DOUBLE only. |
| 130 // uint32 will automatically get converted to a double, which is why we try | 132 // uint32_t will automatically get converted to a double, which is why we try |
| 131 // to obtain the value as a double (see dbus/values_util.h). | 133 // to obtain the value as a double (see dbus/values_util.h). |
| 132 uint32 new_value; | 134 uint32_t new_value; |
| 133 double double_value; | 135 double double_value; |
| 134 if (!value.GetAsDouble(&double_value) || double_value < 0) { | 136 if (!value.GetAsDouble(&double_value) || double_value < 0) { |
| 135 NET_LOG_ERROR("Error parsing state value", path() + "." + key); | 137 NET_LOG_ERROR("Error parsing state value", path() + "." + key); |
| 136 return false; | 138 return false; |
| 137 } | 139 } |
| 138 new_value = static_cast<uint32>(double_value); | 140 new_value = static_cast<uint32_t>(double_value); |
| 139 if (*out_value == new_value) | 141 if (*out_value == new_value) |
| 140 return false; | 142 return false; |
| 141 *out_value = new_value; | 143 *out_value = new_value; |
| 142 return true; | 144 return true; |
| 143 } | 145 } |
| 144 | 146 |
| 145 } // namespace chromeos | 147 } // namespace chromeos |
| OLD | NEW |