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

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

Issue 7778033: Add trace code to track all posted tasks in message_loop. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: win trace tests Created 9 years, 3 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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.h" 5 #include "base/debug/trace_event.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #if defined(OS_WIN) 9 #if defined(OS_WIN)
10 #include "base/debug/trace_event_win.h" 10 #include "base/debug/trace_event_win.h"
11 #endif 11 #endif
12 #include "base/format_macros.h" 12 #include "base/format_macros.h"
13 #include "base/memory/ref_counted_memory.h" 13 #include "base/memory/ref_counted_memory.h"
14 #include "base/process_util.h" 14 #include "base/process_util.h"
15 #include "base/stringprintf.h" 15 #include "base/stringprintf.h"
16 #include "base/threading/thread_local.h" 16 #include "base/threading/thread_local.h"
17 #include "base/utf_string_conversions.h" 17 #include "base/utf_string_conversions.h"
18 #include "base/stl_util.h" 18 #include "base/stl_util.h"
19 #include "base/time.h" 19 #include "base/time.h"
20 20
21 #define USE_UNRELIABLE_NOW 21 #define USE_UNRELIABLE_NOW
22 22
23 class DeleteTraceLogForTesting {
24 public:
25 static void Delete() {
26 Singleton<base::debug::TraceLog,
27 StaticMemorySingletonTraits<base::debug::TraceLog> >::OnExit(0);
28 }
29 };
30
23 namespace base { 31 namespace base {
24 namespace debug { 32 namespace debug {
25 33
26 // Controls the number of trace events we will buffer in-memory 34 // Controls the number of trace events we will buffer in-memory
27 // before throwing them away. 35 // before throwing them away.
28 const size_t kTraceEventBufferSize = 500000; 36 const size_t kTraceEventBufferSize = 500000;
29 const size_t kTraceEventBatchSize = 1000; 37 const size_t kTraceEventBatchSize = 1000;
30 38
31 #define TRACE_EVENT_MAX_CATEGORIES 42 39 #define TRACE_EVENT_MAX_CATEGORIES 42
32 40
(...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after
482 TraceEvent(static_cast<unsigned long>(base::GetCurrentProcId()), 490 TraceEvent(static_cast<unsigned long>(base::GetCurrentProcId()),
483 it->first, 491 it->first,
484 TimeTicks(), base::debug::TRACE_EVENT_PHASE_METADATA, 492 TimeTicks(), base::debug::TRACE_EVENT_PHASE_METADATA,
485 g_category_metadata, "thread_name", 493 g_category_metadata, "thread_name",
486 "name", it->second, 494 "name", it->second,
487 NULL, 0, 495 NULL, 0,
488 false)); 496 false));
489 } 497 }
490 } 498 }
491 499
500 void TraceLog::DeleteForTesting() {
501 DeleteTraceLogForTesting::Delete();
502 }
503
492 void TraceLog::Resurrect() { 504 void TraceLog::Resurrect() {
493 StaticMemorySingletonTraits<TraceLog>::Resurrect(); 505 StaticMemorySingletonTraits<TraceLog>::Resurrect();
494 } 506 }
495 507
496 namespace internal { 508 namespace internal {
497 509
498 void TraceEndOnScopeClose::Initialize(const TraceCategory* category, 510 void TraceEndOnScopeClose::Initialize(const TraceCategory* category,
499 const char* name) { 511 const char* name) {
500 data_.category = category; 512 data_.category = category;
501 data_.name = name; 513 data_.name = name;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
535 NULL, 0, NULL, 0, 547 NULL, 0, NULL, 0,
536 p_data_->threshold_begin_id, p_data_->threshold, 548 p_data_->threshold_begin_id, p_data_->threshold,
537 TraceLog::EVENT_FLAG_NONE); 549 TraceLog::EVENT_FLAG_NONE);
538 } 550 }
539 } 551 }
540 552
541 } // namespace internal 553 } // namespace internal
542 554
543 } // namespace debug 555 } // namespace debug
544 } // namespace base 556 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698