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

Side by Side Diff: dbus/values_util.cc

Issue 9863050: Checked the return values of function calls. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 9 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
« no previous file with comments | « no previous file | no next file » | 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 "base/json/json_writer.h" 7 #include "base/json/json_writer.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/values.h" 10 #include "base/values.h"
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 break; 200 break;
201 } 201 }
202 } 202 }
203 return result; 203 return result;
204 } 204 }
205 205
206 void AppendBasicTypeValueData(MessageWriter* writer, const base::Value& value) { 206 void AppendBasicTypeValueData(MessageWriter* writer, const base::Value& value) {
207 switch (value.GetType()) { 207 switch (value.GetType()) {
208 case base::Value::TYPE_BOOLEAN: { 208 case base::Value::TYPE_BOOLEAN: {
209 bool bool_value = false; 209 bool bool_value = false;
210 value.GetAsBoolean(&bool_value); 210 bool success = value.GetAsBoolean(&bool_value);
211 DCHECK(success);
211 writer->AppendBool(bool_value); 212 writer->AppendBool(bool_value);
212 break; 213 break;
213 } 214 }
214 case base::Value::TYPE_INTEGER: { 215 case base::Value::TYPE_INTEGER: {
215 int int_value = 0; 216 int int_value = 0;
216 value.GetAsInteger(&int_value); 217 bool success = value.GetAsInteger(&int_value);
218 DCHECK(success);
217 writer->AppendInt32(int_value); 219 writer->AppendInt32(int_value);
218 break; 220 break;
219 } 221 }
220 case base::Value::TYPE_DOUBLE: { 222 case base::Value::TYPE_DOUBLE: {
221 double double_value = 0; 223 double double_value = 0;
222 value.GetAsDouble(&double_value); 224 bool success = value.GetAsDouble(&double_value);
225 DCHECK(success);
223 writer->AppendDouble(double_value); 226 writer->AppendDouble(double_value);
224 break; 227 break;
225 } 228 }
226 case base::Value::TYPE_STRING: { 229 case base::Value::TYPE_STRING: {
227 std::string string_value; 230 std::string string_value;
228 value.GetAsString(&string_value); 231 bool success = value.GetAsString(&string_value);
232 DCHECK(success);
229 writer->AppendString(string_value); 233 writer->AppendString(string_value);
230 break; 234 break;
231 } 235 }
232 default: 236 default:
233 DLOG(ERROR) << "Unexpected type " << value.GetType(); 237 DLOG(ERROR) << "Unexpected type " << value.GetType();
234 break; 238 break;
235 } 239 }
236 } 240 }
237 241
238 void AppendBasicTypeValueDataAsVariant(MessageWriter* writer, 242 void AppendBasicTypeValueDataAsVariant(MessageWriter* writer,
239 const base::Value& value) { 243 const base::Value& value) {
240 MessageWriter sub_writer(NULL); 244 MessageWriter sub_writer(NULL);
241 writer->OpenVariant(GetTypeSignature(value), &sub_writer); 245 writer->OpenVariant(GetTypeSignature(value), &sub_writer);
242 AppendBasicTypeValueData(&sub_writer, value); 246 AppendBasicTypeValueData(&sub_writer, value);
243 writer->CloseContainer(&sub_writer); 247 writer->CloseContainer(&sub_writer);
244 } 248 }
245 249
246 } // namespace dbus 250 } // namespace dbus
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698