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

Side by Side Diff: base/json/json_writer.cc

Issue 2000803003: Use std::unique_ptr for base::DictionaryValue and base::ListValue's internal store. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: More fixes Created 4 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 | « no previous file | base/trace_event/trace_event_argument.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 "base/json/json_writer.h" 5 #include "base/json/json_writer.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <cmath> 9 #include <cmath>
10 #include <limits> 10 #include <limits>
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 120
121 case Value::TYPE_LIST: { 121 case Value::TYPE_LIST: {
122 json_string_->push_back('['); 122 json_string_->push_back('[');
123 if (pretty_print_) 123 if (pretty_print_)
124 json_string_->push_back(' '); 124 json_string_->push_back(' ');
125 125
126 const ListValue* list = NULL; 126 const ListValue* list = NULL;
127 bool first_value_has_been_output = false; 127 bool first_value_has_been_output = false;
128 bool result = node.GetAsList(&list); 128 bool result = node.GetAsList(&list);
129 DCHECK(result); 129 DCHECK(result);
130 for (ListValue::const_iterator it = list->begin(); it != list->end(); 130 for (const auto& value : *list) {
131 ++it) {
132 const Value* value = *it;
133 if (omit_binary_values_ && value->GetType() == Value::TYPE_BINARY) 131 if (omit_binary_values_ && value->GetType() == Value::TYPE_BINARY)
134 continue; 132 continue;
135 133
136 if (first_value_has_been_output) { 134 if (first_value_has_been_output) {
137 json_string_->push_back(','); 135 json_string_->push_back(',');
138 if (pretty_print_) 136 if (pretty_print_)
139 json_string_->push_back(' '); 137 json_string_->push_back(' ');
140 } 138 }
141 139
142 if (!BuildJSONString(*value, depth)) 140 if (!BuildJSONString(*value, depth))
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 } 201 }
204 NOTREACHED(); 202 NOTREACHED();
205 return false; 203 return false;
206 } 204 }
207 205
208 void JSONWriter::IndentLine(size_t depth) { 206 void JSONWriter::IndentLine(size_t depth) {
209 json_string_->append(depth * 3U, ' '); 207 json_string_->append(depth * 3U, ' ');
210 } 208 }
211 209
212 } // namespace base 210 } // namespace base
OLDNEW
« no previous file with comments | « no previous file | base/trace_event/trace_event_argument.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698