OLD | NEW |
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 Loading... |
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 Loading... |
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 |
OLD | NEW |