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

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

Issue 10834004: Correct const accessors in base/values.(h|cc) (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Reverting webdriver:Command::parameters_ to const 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/test/trace_event_analyzer.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 <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 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 { 166 {
167 json_string_->append("{"); 167 json_string_->append("{");
168 if (pretty_print_) 168 if (pretty_print_)
169 json_string_->append(kPrettyPrintLineEnding); 169 json_string_->append(kPrettyPrintLineEnding);
170 170
171 const DictionaryValue* dict = 171 const DictionaryValue* dict =
172 static_cast<const DictionaryValue*>(node); 172 static_cast<const DictionaryValue*>(node);
173 for (DictionaryValue::key_iterator key_itr = dict->begin_keys(); 173 for (DictionaryValue::key_iterator key_itr = dict->begin_keys();
174 key_itr != dict->end_keys(); 174 key_itr != dict->end_keys();
175 ++key_itr) { 175 ++key_itr) {
176 Value* value = NULL; 176 const Value* value = NULL;
177 bool result = dict->GetWithoutPathExpansion(*key_itr, &value); 177 bool result = dict->GetWithoutPathExpansion(*key_itr, &value);
178 DCHECK(result); 178 DCHECK(result);
179 179
180 if (omit_binary_values_ && value->GetType() == Value::TYPE_BINARY) { 180 if (omit_binary_values_ && value->GetType() == Value::TYPE_BINARY) {
181 continue; 181 continue;
182 } 182 }
183 183
184 if (key_itr != dict->begin_keys()) { 184 if (key_itr != dict->begin_keys()) {
185 json_string_->append(","); 185 json_string_->append(",");
186 if (pretty_print_) 186 if (pretty_print_)
(...skipping 40 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/test/trace_event_analyzer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698