| 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 #include <memory> | 9 #include <memory> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 466 trace_config_.IsCategoryGroupEnabled(category_group)) { | 466 trace_config_.IsCategoryGroupEnabled(category_group)) { |
| 467 enabled_flag |= ENABLED_FOR_RECORDING; | 467 enabled_flag |= ENABLED_FOR_RECORDING; |
| 468 } | 468 } |
| 469 | 469 |
| 470 if (event_callback_ && | 470 if (event_callback_ && |
| 471 event_callback_trace_config_.IsCategoryGroupEnabled(category_group)) { | 471 event_callback_trace_config_.IsCategoryGroupEnabled(category_group)) { |
| 472 enabled_flag |= ENABLED_FOR_EVENT_CALLBACK; | 472 enabled_flag |= ENABLED_FOR_EVENT_CALLBACK; |
| 473 } | 473 } |
| 474 | 474 |
| 475 #if defined(OS_WIN) | 475 #if defined(OS_WIN) |
| 476 if (base::trace_event::TraceEventETWExport::IsCategoryGroupEnabled( | 476 //if (base::trace_event::TraceEventETWExport::IsCategoryGroupEnabled( |
| 477 category_group)) { | 477 //category_group)) { |
| 478 enabled_flag |= ENABLED_FOR_ETW_EXPORT; | 478 //enabled_flag |= ENABLED_FOR_ETW_EXPORT; |
| 479 } | 479 //} |
| 480 #endif | 480 #endif |
| 481 | 481 |
| 482 // TODO(primiano): this is a temporary workaround for catapult:#2341, | 482 // TODO(primiano): this is a temporary workaround for catapult:#2341, |
| 483 // to guarantee that metadata events are always added even if the category | 483 // to guarantee that metadata events are always added even if the category |
| 484 // filter is "-*". See crbug.com/618054 for more details and long-term fix. | 484 // filter is "-*". See crbug.com/618054 for more details and long-term fix. |
| 485 if (mode_ == RECORDING_MODE && !strcmp(category_group, "__metadata")) | 485 if (mode_ == RECORDING_MODE && !strcmp(category_group, "__metadata")) |
| 486 enabled_flag |= ENABLED_FOR_RECORDING; | 486 enabled_flag |= ENABLED_FOR_RECORDING; |
| 487 | 487 |
| 488 g_category_group_enabled[category_index] = enabled_flag; | 488 g_category_group_enabled[category_index] = enabled_flag; |
| 489 } | 489 } |
| (...skipping 772 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1262 existing_name->second.push_back(','); | 1262 existing_name->second.push_back(','); |
| 1263 existing_name->second.append(new_name); | 1263 existing_name->second.append(new_name); |
| 1264 } | 1264 } |
| 1265 } | 1265 } |
| 1266 } | 1266 } |
| 1267 } | 1267 } |
| 1268 | 1268 |
| 1269 #if defined(OS_WIN) | 1269 #if defined(OS_WIN) |
| 1270 // This is done sooner rather than later, to avoid creating the event and | 1270 // This is done sooner rather than later, to avoid creating the event and |
| 1271 // acquiring the lock, which is not needed for ETW as it's already threadsafe. | 1271 // acquiring the lock, which is not needed for ETW as it's already threadsafe. |
| 1272 if (*category_group_enabled & ENABLED_FOR_ETW_EXPORT) | 1272 //if (*category_group_enabled & ENABLED_FOR_ETW_EXPORT) |
| 1273 TraceEventETWExport::AddEvent(phase, category_group_enabled, name, id, | 1273 //TraceEventETWExport::AddEvent(phase, category_group_enabled, name, id, |
| 1274 num_args, arg_names, arg_types, arg_values, | 1274 //num_args, arg_names, arg_types, arg_values, |
| 1275 convertable_values); | 1275 //convertable_values); |
| 1276 #endif // OS_WIN | 1276 #endif // OS_WIN |
| 1277 | 1277 |
| 1278 std::string console_message; | 1278 std::string console_message; |
| 1279 if (*category_group_enabled & ENABLED_FOR_RECORDING) { | 1279 if (*category_group_enabled & ENABLED_FOR_RECORDING) { |
| 1280 OptionalAutoLock lock(&lock_); | 1280 OptionalAutoLock lock(&lock_); |
| 1281 | 1281 |
| 1282 TraceEvent* trace_event = NULL; | 1282 TraceEvent* trace_event = NULL; |
| 1283 if (thread_local_event_buffer) { | 1283 if (thread_local_event_buffer) { |
| 1284 trace_event = thread_local_event_buffer->AddTraceEvent(&handle); | 1284 trace_event = thread_local_event_buffer->AddTraceEvent(&handle); |
| 1285 } else { | 1285 } else { |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1454 if (thread_is_in_trace_event_.Get()) | 1454 if (thread_is_in_trace_event_.Get()) |
| 1455 return; | 1455 return; |
| 1456 | 1456 |
| 1457 AutoThreadLocalBoolean thread_is_in_trace_event(&thread_is_in_trace_event_); | 1457 AutoThreadLocalBoolean thread_is_in_trace_event(&thread_is_in_trace_event_); |
| 1458 | 1458 |
| 1459 ThreadTicks thread_now = ThreadNow(); | 1459 ThreadTicks thread_now = ThreadNow(); |
| 1460 TimeTicks now = OffsetNow(); | 1460 TimeTicks now = OffsetNow(); |
| 1461 | 1461 |
| 1462 #if defined(OS_WIN) | 1462 #if defined(OS_WIN) |
| 1463 // Generate an ETW event that marks the end of a complete event. | 1463 // Generate an ETW event that marks the end of a complete event. |
| 1464 if (category_group_enabled_local & ENABLED_FOR_ETW_EXPORT) | 1464 //if (category_group_enabled_local & ENABLED_FOR_ETW_EXPORT) |
| 1465 TraceEventETWExport::AddCompleteEndEvent(name); | 1465 //TraceEventETWExport::AddCompleteEndEvent(name); |
| 1466 #endif // OS_WIN | 1466 #endif // OS_WIN |
| 1467 | 1467 |
| 1468 std::string console_message; | 1468 std::string console_message; |
| 1469 if (category_group_enabled_local & ENABLED_FOR_RECORDING) { | 1469 if (category_group_enabled_local & ENABLED_FOR_RECORDING) { |
| 1470 OptionalAutoLock lock(&lock_); | 1470 OptionalAutoLock lock(&lock_); |
| 1471 | 1471 |
| 1472 TraceEvent* trace_event = GetEventByHandleInternal(handle, &lock); | 1472 TraceEvent* trace_event = GetEventByHandleInternal(handle, &lock); |
| 1473 if (trace_event) { | 1473 if (trace_event) { |
| 1474 DCHECK(trace_event->phase() == TRACE_EVENT_PHASE_COMPLETE); | 1474 DCHECK(trace_event->phase() == TRACE_EVENT_PHASE_COMPLETE); |
| 1475 trace_event->UpdateDuration(now, thread_now); | 1475 trace_event->UpdateDuration(now, thread_now); |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1711 kEchoToConsoleTraceEventBufferChunks); | 1711 kEchoToConsoleTraceEventBufferChunks); |
| 1712 else if (options & kInternalRecordAsMuchAsPossible) | 1712 else if (options & kInternalRecordAsMuchAsPossible) |
| 1713 return TraceBuffer::CreateTraceBufferVectorOfSize( | 1713 return TraceBuffer::CreateTraceBufferVectorOfSize( |
| 1714 kTraceEventVectorBigBufferChunks); | 1714 kTraceEventVectorBigBufferChunks); |
| 1715 return TraceBuffer::CreateTraceBufferVectorOfSize( | 1715 return TraceBuffer::CreateTraceBufferVectorOfSize( |
| 1716 kTraceEventVectorBufferChunks); | 1716 kTraceEventVectorBufferChunks); |
| 1717 } | 1717 } |
| 1718 | 1718 |
| 1719 #if defined(OS_WIN) | 1719 #if defined(OS_WIN) |
| 1720 void TraceLog::UpdateETWCategoryGroupEnabledFlags() { | 1720 void TraceLog::UpdateETWCategoryGroupEnabledFlags() { |
| 1721 AutoLock lock(lock_); | 1721 //AutoLock lock(lock_); |
| 1722 size_t category_index = base::subtle::NoBarrier_Load(&g_category_index); | 1722 //size_t category_index = base::subtle::NoBarrier_Load(&g_category_index); |
| 1723 // Go through each category and set/clear the ETW bit depending on whether the | 1723 //// Go through each category and set/clear the ETW bit depending on whether t
he |
| 1724 // category is enabled. | 1724 //// category is enabled. |
| 1725 for (size_t i = 0; i < category_index; i++) { | 1725 //for (size_t i = 0; i < category_index; i++) { |
| 1726 const char* category_group = g_category_groups[i]; | 1726 // const char* category_group = g_category_groups[i]; |
| 1727 DCHECK(category_group); | 1727 // DCHECK(category_group); |
| 1728 if (base::trace_event::TraceEventETWExport::IsCategoryGroupEnabled( | 1728 // if (base::trace_event::TraceEventETWExport::IsCategoryGroupEnabled( |
| 1729 category_group)) { | 1729 // category_group)) { |
| 1730 g_category_group_enabled[i] |= ENABLED_FOR_ETW_EXPORT; | 1730 // g_category_group_enabled[i] |= ENABLED_FOR_ETW_EXPORT; |
| 1731 } else { | 1731 // } else { |
| 1732 g_category_group_enabled[i] &= ~ENABLED_FOR_ETW_EXPORT; | 1732 // g_category_group_enabled[i] &= ~ENABLED_FOR_ETW_EXPORT; |
| 1733 } | 1733 // } |
| 1734 } | 1734 //} |
| 1735 } | 1735 } |
| 1736 #endif // defined(OS_WIN) | 1736 #endif // defined(OS_WIN) |
| 1737 | 1737 |
| 1738 void ConvertableToTraceFormat::EstimateTraceMemoryOverhead( | 1738 void ConvertableToTraceFormat::EstimateTraceMemoryOverhead( |
| 1739 TraceEventMemoryOverhead* overhead) { | 1739 TraceEventMemoryOverhead* overhead) { |
| 1740 overhead->Add("ConvertableToTraceFormat(Unknown)", sizeof(*this)); | 1740 overhead->Add("ConvertableToTraceFormat(Unknown)", sizeof(*this)); |
| 1741 } | 1741 } |
| 1742 | 1742 |
| 1743 void TraceLog::AddAsyncEnabledStateObserver( | 1743 void TraceLog::AddAsyncEnabledStateObserver( |
| 1744 WeakPtr<AsyncEnabledStateObserver> listener) { | 1744 WeakPtr<AsyncEnabledStateObserver> listener) { |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1793 } | 1793 } |
| 1794 | 1794 |
| 1795 ScopedTraceBinaryEfficient::~ScopedTraceBinaryEfficient() { | 1795 ScopedTraceBinaryEfficient::~ScopedTraceBinaryEfficient() { |
| 1796 if (*category_group_enabled_) { | 1796 if (*category_group_enabled_) { |
| 1797 TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION(category_group_enabled_, name_, | 1797 TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION(category_group_enabled_, name_, |
| 1798 event_handle_); | 1798 event_handle_); |
| 1799 } | 1799 } |
| 1800 } | 1800 } |
| 1801 | 1801 |
| 1802 } // namespace trace_event_internal | 1802 } // namespace trace_event_internal |
| OLD | NEW |