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

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

Issue 10837044: Correct const accessors in base/values.(h|cc), Part II (ListValue) (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: David's comments Created 8 years, 4 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 | « base/json/json_value_converter.h ('k') | base/values.h » ('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 <cmath> 7 #include <cmath>
8 8
9 #include "base/json/string_escape.h" 9 #include "base/json/string_escape.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 } 132 }
133 133
134 case Value::TYPE_LIST: 134 case Value::TYPE_LIST:
135 { 135 {
136 json_string_->append("["); 136 json_string_->append("[");
137 if (pretty_print_) 137 if (pretty_print_)
138 json_string_->append(" "); 138 json_string_->append(" ");
139 139
140 const ListValue* list = static_cast<const ListValue*>(node); 140 const ListValue* list = static_cast<const ListValue*>(node);
141 for (size_t i = 0; i < list->GetSize(); ++i) { 141 for (size_t i = 0; i < list->GetSize(); ++i) {
142 Value* value = NULL; 142 const Value* value = NULL;
143 bool result = list->Get(i, &value); 143 bool result = list->Get(i, &value);
144 DCHECK(result); 144 DCHECK(result);
145 145
146 if (omit_binary_values_ && value->GetType() == Value::TYPE_BINARY) { 146 if (omit_binary_values_ && value->GetType() == Value::TYPE_BINARY) {
147 continue; 147 continue;
148 } 148 }
149 149
150 if (i != 0) { 150 if (i != 0) {
151 json_string_->append(","); 151 json_string_->append(",");
152 if (pretty_print_) 152 if (pretty_print_)
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 JsonDoubleQuote(UTF8ToUTF16(str), true, json_string_); 227 JsonDoubleQuote(UTF8ToUTF16(str), true, json_string_);
228 } 228 }
229 229
230 void JSONWriter::IndentLine(int depth) { 230 void JSONWriter::IndentLine(int depth) {
231 // It may be faster to keep an indent string so we don't have to keep 231 // It may be faster to keep an indent string so we don't have to keep
232 // reallocating. 232 // reallocating.
233 json_string_->append(std::string(depth * 3, ' ')); 233 json_string_->append(std::string(depth * 3, ' '));
234 } 234 }
235 235
236 } // namespace base 236 } // namespace base
OLDNEW
« no previous file with comments | « base/json/json_value_converter.h ('k') | base/values.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698