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

Side by Side Diff: dbus/values_util.cc

Issue 1131113004: Convert JsonWriter::Write to taking a const ref for the in-param (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: another rebase Created 5 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
« no previous file with comments | « content/shell/renderer/test_runner/test_interfaces.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 "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 30 matching lines...) Expand all
41 return false; 41 return false;
42 // Get key as a string. 42 // Get key as a string.
43 std::string key_string; 43 std::string key_string;
44 if (entry_reader.GetDataType() == Message::STRING) { 44 if (entry_reader.GetDataType() == Message::STRING) {
45 // If the type of keys is STRING, pop it directly. 45 // If the type of keys is STRING, pop it directly.
46 if (!entry_reader.PopString(&key_string)) 46 if (!entry_reader.PopString(&key_string))
47 return false; 47 return false;
48 } else { 48 } else {
49 // If the type of keys is not STRING, convert it to string. 49 // If the type of keys is not STRING, convert it to string.
50 scoped_ptr<base::Value> key(PopDataAsValue(&entry_reader)); 50 scoped_ptr<base::Value> key(PopDataAsValue(&entry_reader));
51 if (!key.get()) 51 if (!key)
52 return false; 52 return false;
53 // Use JSONWriter to convert an arbitrary value to a string. 53 // Use JSONWriter to convert an arbitrary value to a string.
54 base::JSONWriter::Write(key.get(), &key_string); 54 base::JSONWriter::Write(*key, &key_string);
55 } 55 }
56 // Get the value and set the key-value pair. 56 // Get the value and set the key-value pair.
57 base::Value* value = PopDataAsValue(&entry_reader); 57 base::Value* value = PopDataAsValue(&entry_reader);
58 if (!value) 58 if (!value)
59 return false; 59 return false;
60 dictionary_value->SetWithoutPathExpansion(key_string, value); 60 dictionary_value->SetWithoutPathExpansion(key_string, value);
61 } 61 }
62 return true; 62 return true;
63 } 63 }
64 64
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 } 298 }
299 299
300 void AppendValueDataAsVariant(MessageWriter* writer, const base::Value& value) { 300 void AppendValueDataAsVariant(MessageWriter* writer, const base::Value& value) {
301 MessageWriter variant_writer(NULL); 301 MessageWriter variant_writer(NULL);
302 writer->OpenVariant(GetTypeSignature(value), &variant_writer); 302 writer->OpenVariant(GetTypeSignature(value), &variant_writer);
303 AppendValueData(&variant_writer, value); 303 AppendValueData(&variant_writer, value);
304 writer->CloseContainer(&variant_writer); 304 writer->CloseContainer(&variant_writer);
305 } 305 }
306 306
307 } // namespace dbus 307 } // namespace dbus
OLDNEW
« no previous file with comments | « content/shell/renderer/test_runner/test_interfaces.cc ('k') | dbus/values_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698