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

Side by Side Diff: base/debug/trace_event_memory.cc

Issue 148173011: Make flow event traces disabled-by-default, and rename "ipc" and "task" categories to "toplevel" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Replace "ipc" and "task" categories with toplevel. Created 6 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | base/debug/trace_event_memory_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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/debug/trace_event_memory.h" 5 #include "base/debug/trace_event_memory.h"
6 6
7 #include "base/debug/leak_annotations.h" 7 #include "base/debug/leak_annotations.h"
8 #include "base/debug/trace_event.h" 8 #include "base/debug/trace_event.h"
9 #include "base/lazy_instance.h" 9 #include "base/lazy_instance.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 const std::string kSingleQuote = "'"; 402 const std::string kSingleQuote = "'";
403 for (size_t t = 4; t < tokens.size(); t += 2) { 403 for (size_t t = 4; t < tokens.size(); t += 2) {
404 // Casting strings into pointers is ugly but otherwise tcmalloc would need 404 // Casting strings into pointers is ugly but otherwise tcmalloc would need
405 // to gain a special output serializer just for pseudo-stacks. 405 // to gain a special output serializer just for pseudo-stacks.
406 const char* trace_category = StringFromHexAddress(tokens[t]); 406 const char* trace_category = StringFromHexAddress(tokens[t]);
407 DCHECK_LT(t + 1, tokens.size()); 407 DCHECK_LT(t + 1, tokens.size());
408 const char* trace_name = StringFromHexAddress(tokens[t + 1]); 408 const char* trace_name = StringFromHexAddress(tokens[t + 1]);
409 409
410 // TODO(jamescook): Report the trace category and name separately to the 410 // TODO(jamescook): Report the trace category and name separately to the
411 // trace viewer and allow it to decide what decorations to apply. For now 411 // trace viewer and allow it to decide what decorations to apply. For now
412 // just hard-code a decoration for posted tasks. 412 // just hard-code a decoration for posted tasks (toplevel).
413 std::string trace_string(trace_name); 413 std::string trace_string(trace_name);
414 if (!strcmp(trace_category, "task")) 414 if (!strcmp(trace_category, "toplevel"))
415 trace_string.append("->PostTask"); 415 trace_string.append("->PostTask");
416 416
417 // Some trace name strings have double quotes, convert them to single. 417 // Some trace name strings have double quotes, convert them to single.
418 ReplaceChars(trace_string, "\"", kSingleQuote, &trace_string); 418 ReplaceChars(trace_string, "\"", kSingleQuote, &trace_string);
419 419
420 output->append(trace_string); 420 output->append(trace_string);
421 421
422 // Trace viewer expects a trailing space. 422 // Trace viewer expects a trailing space.
423 output->append(" "); 423 output->append(" ");
424 } 424 }
425 output->append("\"}"); 425 output->append("\"}");
426 return true; 426 return true;
427 } 427 }
428 428
429 const char* StringFromHexAddress(const std::string& hex_address) { 429 const char* StringFromHexAddress(const std::string& hex_address) {
430 uint64 address = 0; 430 uint64 address = 0;
431 if (!base::HexStringToUInt64(hex_address, &address)) 431 if (!base::HexStringToUInt64(hex_address, &address))
432 return "error"; 432 return "error";
433 if (!address) 433 if (!address)
434 return "null"; 434 return "null";
435 // Note that this cast handles 64-bit to 32-bit conversion if necessary. 435 // Note that this cast handles 64-bit to 32-bit conversion if necessary.
436 return reinterpret_cast<const char*>(address); 436 return reinterpret_cast<const char*>(address);
437 } 437 }
438 438
439 } // namespace debug 439 } // namespace debug
440 } // namespace base 440 } // namespace base
OLDNEW
« no previous file with comments | « no previous file | base/debug/trace_event_memory_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698