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

Side by Side Diff: base/metrics/statistics_recorder.cc

Issue 100823007: Stop doing unnecessary UTF-8 to UTF-16 conversions in JSONWriter. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix ChromeOS page encodings Created 7 years 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 | Annotate | Revision Log
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/metrics/statistics_recorder.h" 5 #include "base/metrics/statistics_recorder.h"
6 6
7 #include "base/at_exit.h" 7 #include "base/at_exit.h"
8 #include "base/debug/leak_annotations.h" 8 #include "base/debug/leak_annotations.h"
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 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 } 165 }
166 166
167 // static 167 // static
168 std::string StatisticsRecorder::ToJSON(const std::string& query) { 168 std::string StatisticsRecorder::ToJSON(const std::string& query) {
169 if (!IsActive()) 169 if (!IsActive())
170 return std::string(); 170 return std::string();
171 171
172 std::string output("{"); 172 std::string output("{");
173 if (!query.empty()) { 173 if (!query.empty()) {
174 output += "\"query\":"; 174 output += "\"query\":";
175 JsonDoubleQuote(query, true, &output); 175 EscapeJSONString(query, true, &output);
176 output += ","; 176 output += ",";
177 } 177 }
178 178
179 Histograms snapshot; 179 Histograms snapshot;
180 GetSnapshot(query, &snapshot); 180 GetSnapshot(query, &snapshot);
181 output += "\"histograms\":["; 181 output += "\"histograms\":[";
182 bool first_histogram = true; 182 bool first_histogram = true;
183 for (Histograms::const_iterator it = snapshot.begin(); it != snapshot.end(); 183 for (Histograms::const_iterator it = snapshot.begin(); it != snapshot.end();
184 ++it) { 184 ++it) {
185 if (first_histogram) 185 if (first_histogram)
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 315
316 316
317 // static 317 // static
318 StatisticsRecorder::HistogramMap* StatisticsRecorder::histograms_ = NULL; 318 StatisticsRecorder::HistogramMap* StatisticsRecorder::histograms_ = NULL;
319 // static 319 // static
320 StatisticsRecorder::RangesMap* StatisticsRecorder::ranges_ = NULL; 320 StatisticsRecorder::RangesMap* StatisticsRecorder::ranges_ = NULL;
321 // static 321 // static
322 base::Lock* StatisticsRecorder::lock_ = NULL; 322 base::Lock* StatisticsRecorder::lock_ = NULL;
323 323
324 } // namespace base 324 } // namespace base
OLDNEW
« no previous file with comments | « base/json/string_escape_unittest.cc ('k') | chrome/browser/chromeos/policy/configuration_policy_handler_chromeos.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698