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

Side by Side Diff: dbus/values_util.cc

Issue 2476493003: Remove FundamentalValue
Patch Set: Fix Created 4 years, 1 month 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
« no previous file with comments | « content/shell/browser/shell_devtools_frontend.cc ('k') | dbus/values_util_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "dbus/values_util.h" 5 #include "dbus/values_util.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/json/json_writer.h" 9 #include "base/json/json_writer.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 91
92 std::unique_ptr<base::Value> PopDataAsValue(MessageReader* reader) { 92 std::unique_ptr<base::Value> PopDataAsValue(MessageReader* reader) {
93 std::unique_ptr<base::Value> result; 93 std::unique_ptr<base::Value> result;
94 switch (reader->GetDataType()) { 94 switch (reader->GetDataType()) {
95 case Message::INVALID_DATA: 95 case Message::INVALID_DATA:
96 // Do nothing. 96 // Do nothing.
97 break; 97 break;
98 case Message::BYTE: { 98 case Message::BYTE: {
99 uint8_t value = 0; 99 uint8_t value = 0;
100 if (reader->PopByte(&value)) 100 if (reader->PopByte(&value))
101 result = base::MakeUnique<base::FundamentalValue>(value); 101 result = base::MakeUnique<base::Value>(value);
102 break; 102 break;
103 } 103 }
104 case Message::BOOL: { 104 case Message::BOOL: {
105 bool value = false; 105 bool value = false;
106 if (reader->PopBool(&value)) 106 if (reader->PopBool(&value))
107 result = base::MakeUnique<base::FundamentalValue>(value); 107 result = base::MakeUnique<base::Value>(value);
108 break; 108 break;
109 } 109 }
110 case Message::INT16: { 110 case Message::INT16: {
111 int16_t value = 0; 111 int16_t value = 0;
112 if (reader->PopInt16(&value)) 112 if (reader->PopInt16(&value))
113 result = base::MakeUnique<base::FundamentalValue>(value); 113 result = base::MakeUnique<base::Value>(value);
114 break; 114 break;
115 } 115 }
116 case Message::UINT16: { 116 case Message::UINT16: {
117 uint16_t value = 0; 117 uint16_t value = 0;
118 if (reader->PopUint16(&value)) 118 if (reader->PopUint16(&value))
119 result = base::MakeUnique<base::FundamentalValue>(value); 119 result = base::MakeUnique<base::Value>(value);
120 break; 120 break;
121 } 121 }
122 case Message::INT32: { 122 case Message::INT32: {
123 int32_t value = 0; 123 int32_t value = 0;
124 if (reader->PopInt32(&value)) 124 if (reader->PopInt32(&value))
125 result = base::MakeUnique<base::FundamentalValue>(value); 125 result = base::MakeUnique<base::Value>(value);
126 break; 126 break;
127 } 127 }
128 case Message::UINT32: { 128 case Message::UINT32: {
129 uint32_t value = 0; 129 uint32_t value = 0;
130 if (reader->PopUint32(&value)) { 130 if (reader->PopUint32(&value)) {
131 result = base::MakeUnique<base::FundamentalValue>( 131 result = base::MakeUnique<base::Value>(
132 static_cast<double>(value)); 132 static_cast<double>(value));
133 } 133 }
134 break; 134 break;
135 } 135 }
136 case Message::INT64: { 136 case Message::INT64: {
137 int64_t value = 0; 137 int64_t value = 0;
138 if (reader->PopInt64(&value)) { 138 if (reader->PopInt64(&value)) {
139 DLOG_IF(WARNING, !IsExactlyRepresentableByDouble(value)) << 139 DLOG_IF(WARNING, !IsExactlyRepresentableByDouble(value)) <<
140 value << " is not exactly representable by double"; 140 value << " is not exactly representable by double";
141 result = base::MakeUnique<base::FundamentalValue>( 141 result = base::MakeUnique<base::Value>(
142 static_cast<double>(value)); 142 static_cast<double>(value));
143 } 143 }
144 break; 144 break;
145 } 145 }
146 case Message::UINT64: { 146 case Message::UINT64: {
147 uint64_t value = 0; 147 uint64_t value = 0;
148 if (reader->PopUint64(&value)) { 148 if (reader->PopUint64(&value)) {
149 DLOG_IF(WARNING, !IsExactlyRepresentableByDouble(value)) << 149 DLOG_IF(WARNING, !IsExactlyRepresentableByDouble(value)) <<
150 value << " is not exactly representable by double"; 150 value << " is not exactly representable by double";
151 result = base::MakeUnique<base::FundamentalValue>( 151 result = base::MakeUnique<base::Value>(
152 static_cast<double>(value)); 152 static_cast<double>(value));
153 } 153 }
154 break; 154 break;
155 } 155 }
156 case Message::DOUBLE: { 156 case Message::DOUBLE: {
157 double value = 0; 157 double value = 0;
158 if (reader->PopDouble(&value)) 158 if (reader->PopDouble(&value))
159 result = base::MakeUnique<base::FundamentalValue>(value); 159 result = base::MakeUnique<base::Value>(value);
160 break; 160 break;
161 } 161 }
162 case Message::STRING: { 162 case Message::STRING: {
163 std::string value; 163 std::string value;
164 if (reader->PopString(&value)) 164 if (reader->PopString(&value))
165 result = base::MakeUnique<base::StringValue>(value); 165 result = base::MakeUnique<base::StringValue>(value);
166 break; 166 break;
167 } 167 }
168 case Message::OBJECT_PATH: { 168 case Message::OBJECT_PATH: {
169 ObjectPath value; 169 ObjectPath value;
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 } 302 }
303 303
304 void AppendValueDataAsVariant(MessageWriter* writer, const base::Value& value) { 304 void AppendValueDataAsVariant(MessageWriter* writer, const base::Value& value) {
305 MessageWriter variant_writer(NULL); 305 MessageWriter variant_writer(NULL);
306 writer->OpenVariant(GetTypeSignature(value), &variant_writer); 306 writer->OpenVariant(GetTypeSignature(value), &variant_writer);
307 AppendValueData(&variant_writer, value); 307 AppendValueData(&variant_writer, value);
308 writer->CloseContainer(&variant_writer); 308 writer->CloseContainer(&variant_writer);
309 } 309 }
310 310
311 } // namespace dbus 311 } // namespace dbus
OLDNEW
« no previous file with comments | « content/shell/browser/shell_devtools_frontend.cc ('k') | dbus/values_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698