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

Side by Side Diff: base/trace_event/trace_event_impl.cc

Issue 1870563002: Escape name and category of trace events. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove escaping of trace event category Created 4 years, 8 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_unittest.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/trace_event/trace_event_impl.h" 5 #include "base/trace_event/trace_event_impl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/format_macros.h" 9 #include "base/format_macros.h"
10 #include "base/json/string_escape.h" 10 #include "base/json/string_escape.h"
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 } else { 286 } else {
287 process_id = TraceLog::GetInstance()->process_id(); 287 process_id = TraceLog::GetInstance()->process_id();
288 thread_id = thread_id_; 288 thread_id = thread_id_;
289 } 289 }
290 const char* category_group_name = 290 const char* category_group_name =
291 TraceLog::GetCategoryGroupName(category_group_enabled_); 291 TraceLog::GetCategoryGroupName(category_group_enabled_);
292 292
293 // Category group checked at category creation time. 293 // Category group checked at category creation time.
294 DCHECK(!strchr(name_, '"')); 294 DCHECK(!strchr(name_, '"'));
295 StringAppendF(out, "{\"pid\":%i,\"tid\":%i,\"ts\":%" PRId64 295 StringAppendF(out, "{\"pid\":%i,\"tid\":%i,\"ts\":%" PRId64
296 "," 296 ",\"ph\":\"%c\",\"cat\":\"%s\",\"name\":",
297 "\"ph\":\"%c\",\"cat\":\"%s\",\"name\":\"%s\",\"args\":", 297 process_id, thread_id, time_int64, phase_, category_group_name);
298 process_id, thread_id, time_int64, phase_, category_group_name, 298 EscapeJSONString(name_, true, out);
299 name_); 299 *out += ",\"args\":";
300 300
301 // Output argument names and values, stop at first NULL argument name. 301 // Output argument names and values, stop at first NULL argument name.
302 // TODO(oysteine): The dual predicates here is a bit ugly; if the filtering 302 // TODO(oysteine): The dual predicates here is a bit ugly; if the filtering
303 // capabilities need to grow even more precise we should rethink this 303 // capabilities need to grow even more precise we should rethink this
304 // approach 304 // approach
305 ArgumentNameFilterPredicate argument_name_filter_predicate; 305 ArgumentNameFilterPredicate argument_name_filter_predicate;
306 bool strip_args = 306 bool strip_args =
307 arg_names_[0] && !argument_filter_predicate.is_null() && 307 arg_names_[0] && !argument_filter_predicate.is_null() &&
308 !argument_filter_predicate.Run(category_group_name, name_, 308 !argument_filter_predicate.Run(category_group_name, name_,
309 &argument_name_filter_predicate); 309 &argument_name_filter_predicate);
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
417 AppendValueAsJSON(arg_types_[i], arg_values_[i], &value_as_text); 417 AppendValueAsJSON(arg_types_[i], arg_values_[i], &value_as_text);
418 418
419 *out << value_as_text; 419 *out << value_as_text;
420 } 420 }
421 *out << "}"; 421 *out << "}";
422 } 422 }
423 } 423 }
424 424
425 } // namespace trace_event 425 } // namespace trace_event
426 } // namespace base 426 } // namespace base
OLDNEW
« no previous file with comments | « no previous file | base/trace_event/trace_event_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698