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