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 1363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1374 } | 1374 } |
1375 | 1375 |
1376 void TraceLog::UpdateTraceEventDuration( | 1376 void TraceLog::UpdateTraceEventDuration( |
1377 const unsigned char* category_group_enabled, | 1377 const unsigned char* category_group_enabled, |
1378 const char* name, | 1378 const char* name, |
1379 TraceEventHandle handle) { | 1379 TraceEventHandle handle) { |
1380 char category_group_enabled_local = *category_group_enabled; | 1380 char category_group_enabled_local = *category_group_enabled; |
1381 if (!category_group_enabled_local) | 1381 if (!category_group_enabled_local) |
1382 return; | 1382 return; |
1383 | 1383 |
1384 TimeTicks now = OffsetNow(); | |
1385 ThreadTicks thread_now = ThreadNow(); | |
1386 UpdateTraceEventDurationExplicit(category_group_enabled, name, handle, now, | |
Primiano Tucci (use gerrit)
2017/07/10 13:09:15
small nit: given that this wraps already, you coul
Benoit L
2017/07/10 13:39:54
Done.
| |
1387 thread_now); | |
1388 } | |
1389 | |
1390 void TraceLog::UpdateTraceEventDurationExplicit( | |
1391 const unsigned char* category_group_enabled, | |
1392 const char* name, | |
1393 TraceEventHandle handle, | |
1394 const TimeTicks& now, | |
1395 const ThreadTicks& thread_now) { | |
1396 char category_group_enabled_local = *category_group_enabled; | |
1397 if (!category_group_enabled_local) | |
1398 return; | |
1399 | |
1384 // Avoid re-entrance of AddTraceEvent. This may happen in GPU process when | 1400 // Avoid re-entrance of AddTraceEvent. This may happen in GPU process when |
1385 // ECHO_TO_CONSOLE is enabled: AddTraceEvent -> LOG(ERROR) -> | 1401 // ECHO_TO_CONSOLE is enabled: AddTraceEvent -> LOG(ERROR) -> |
1386 // GpuProcessLogMessageHandler -> PostPendingTask -> TRACE_EVENT ... | 1402 // GpuProcessLogMessageHandler -> PostPendingTask -> TRACE_EVENT ... |
1387 if (thread_is_in_trace_event_.Get()) | 1403 if (thread_is_in_trace_event_.Get()) |
1388 return; | 1404 return; |
1389 | |
1390 AutoThreadLocalBoolean thread_is_in_trace_event(&thread_is_in_trace_event_); | 1405 AutoThreadLocalBoolean thread_is_in_trace_event(&thread_is_in_trace_event_); |
1391 | 1406 |
1392 ThreadTicks thread_now = ThreadNow(); | |
1393 TimeTicks now = OffsetNow(); | |
1394 | |
1395 #if defined(OS_WIN) | 1407 #if defined(OS_WIN) |
1396 // Generate an ETW event that marks the end of a complete event. | 1408 // Generate an ETW event that marks the end of a complete event. |
1397 if (category_group_enabled_local & TraceCategory::ENABLED_FOR_ETW_EXPORT) | 1409 if (category_group_enabled_local & TraceCategory::ENABLED_FOR_ETW_EXPORT) |
1398 TraceEventETWExport::AddCompleteEndEvent(name); | 1410 TraceEventETWExport::AddCompleteEndEvent(name); |
1399 #endif // OS_WIN | 1411 #endif // OS_WIN |
1400 | 1412 |
1401 std::string console_message; | 1413 std::string console_message; |
1402 if (category_group_enabled_local & TraceCategory::ENABLED_FOR_RECORDING) { | 1414 if (category_group_enabled_local & TraceCategory::ENABLED_FOR_RECORDING) { |
1403 OptionalAutoLock lock(&lock_); | 1415 OptionalAutoLock lock(&lock_); |
1404 | 1416 |
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1702 } | 1714 } |
1703 | 1715 |
1704 ScopedTraceBinaryEfficient::~ScopedTraceBinaryEfficient() { | 1716 ScopedTraceBinaryEfficient::~ScopedTraceBinaryEfficient() { |
1705 if (*category_group_enabled_) { | 1717 if (*category_group_enabled_) { |
1706 TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION(category_group_enabled_, name_, | 1718 TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION(category_group_enabled_, name_, |
1707 event_handle_); | 1719 event_handle_); |
1708 } | 1720 } |
1709 } | 1721 } |
1710 | 1722 |
1711 } // namespace trace_event_internal | 1723 } // namespace trace_event_internal |
OLD | NEW |