| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_log.h" | 5 #include "base/trace_event/trace_log.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <cmath> | 8 #include <cmath> |
| 9 | 9 |
| 10 #include "base/base_switches.h" | 10 #include "base/base_switches.h" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 #include "base/trace_event/trace_event.h" | 32 #include "base/trace_event/trace_event.h" |
| 33 #include "base/trace_event/trace_event_synthetic_delay.h" | 33 #include "base/trace_event/trace_event_synthetic_delay.h" |
| 34 #include "base/trace_event/trace_log.h" | 34 #include "base/trace_event/trace_log.h" |
| 35 #include "base/trace_event/trace_sampling_thread.h" | 35 #include "base/trace_event/trace_sampling_thread.h" |
| 36 | 36 |
| 37 #if defined(OS_WIN) | 37 #if defined(OS_WIN) |
| 38 #include "base/trace_event/trace_event_etw_export_win.h" | 38 #include "base/trace_event/trace_event_etw_export_win.h" |
| 39 #include "base/trace_event/trace_event_win.h" | 39 #include "base/trace_event/trace_event_win.h" |
| 40 #endif | 40 #endif |
| 41 | 41 |
| 42 class DeleteTraceLogForTesting { | |
| 43 public: | |
| 44 static void Delete() { | |
| 45 Singleton<base::trace_event::TraceLog, | |
| 46 LeakySingletonTraits<base::trace_event::TraceLog>>::OnExit(0); | |
| 47 } | |
| 48 }; | |
| 49 | |
| 50 // The thread buckets for the sampling profiler. | 42 // The thread buckets for the sampling profiler. |
| 51 BASE_EXPORT TRACE_EVENT_API_ATOMIC_WORD g_trace_state[3]; | 43 BASE_EXPORT TRACE_EVENT_API_ATOMIC_WORD g_trace_state[3]; |
| 52 | 44 |
| 53 namespace base { | 45 namespace base { |
| 46 namespace internal { |
| 47 |
| 48 class DeleteTraceLogForTesting { |
| 49 public: |
| 50 static void Delete() { |
| 51 Singleton<trace_event::TraceLog, |
| 52 LeakySingletonTraits<trace_event::TraceLog>>::OnExit(0); |
| 53 } |
| 54 }; |
| 55 |
| 56 } // namespace internal |
| 57 |
| 54 namespace trace_event { | 58 namespace trace_event { |
| 55 | 59 |
| 56 namespace { | 60 namespace { |
| 57 | 61 |
| 58 // Controls the number of trace events we will buffer in-memory | 62 // Controls the number of trace events we will buffer in-memory |
| 59 // before throwing them away. | 63 // before throwing them away. |
| 60 const size_t kTraceBufferChunkSize = TraceBufferChunk::kTraceBufferChunkSize; | 64 const size_t kTraceBufferChunkSize = TraceBufferChunk::kTraceBufferChunkSize; |
| 61 | 65 |
| 62 const size_t kTraceEventVectorBigBufferChunks = | 66 const size_t kTraceEventVectorBigBufferChunks = |
| 63 512000000 / kTraceBufferChunkSize; | 67 512000000 / kTraceBufferChunkSize; |
| (...skipping 1524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1588 } | 1592 } |
| 1589 } | 1593 } |
| 1590 | 1594 |
| 1591 void TraceLog::WaitSamplingEventForTesting() { | 1595 void TraceLog::WaitSamplingEventForTesting() { |
| 1592 if (!sampling_thread_) | 1596 if (!sampling_thread_) |
| 1593 return; | 1597 return; |
| 1594 sampling_thread_->WaitSamplingEventForTesting(); | 1598 sampling_thread_->WaitSamplingEventForTesting(); |
| 1595 } | 1599 } |
| 1596 | 1600 |
| 1597 void TraceLog::DeleteForTesting() { | 1601 void TraceLog::DeleteForTesting() { |
| 1598 DeleteTraceLogForTesting::Delete(); | 1602 internal::DeleteTraceLogForTesting::Delete(); |
| 1599 } | 1603 } |
| 1600 | 1604 |
| 1601 TraceEvent* TraceLog::GetEventByHandle(TraceEventHandle handle) { | 1605 TraceEvent* TraceLog::GetEventByHandle(TraceEventHandle handle) { |
| 1602 return GetEventByHandleInternal(handle, NULL); | 1606 return GetEventByHandleInternal(handle, NULL); |
| 1603 } | 1607 } |
| 1604 | 1608 |
| 1605 TraceEvent* TraceLog::GetEventByHandleInternal(TraceEventHandle handle, | 1609 TraceEvent* TraceLog::GetEventByHandleInternal(TraceEventHandle handle, |
| 1606 OptionalAutoLock* lock) { | 1610 OptionalAutoLock* lock) { |
| 1607 if (!handle.chunk_seq) | 1611 if (!handle.chunk_seq) |
| 1608 return NULL; | 1612 return NULL; |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1765 } | 1769 } |
| 1766 | 1770 |
| 1767 ScopedTraceBinaryEfficient::~ScopedTraceBinaryEfficient() { | 1771 ScopedTraceBinaryEfficient::~ScopedTraceBinaryEfficient() { |
| 1768 if (*category_group_enabled_) { | 1772 if (*category_group_enabled_) { |
| 1769 TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION(category_group_enabled_, name_, | 1773 TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION(category_group_enabled_, name_, |
| 1770 event_handle_); | 1774 event_handle_); |
| 1771 } | 1775 } |
| 1772 } | 1776 } |
| 1773 | 1777 |
| 1774 } // namespace trace_event_internal | 1778 } // namespace trace_event_internal |
| OLD | NEW |