| 1996 | } |
| 1997 | |
| 1998 | void TraceLog::UpdateTraceEventDuration( |
| 1999 | const unsigned char* category_group_enabled, |
| 2000 | const char* name, |
| 2001 | TraceEventHandle handle) { |
| 2002 | |
| 2003 | PerThreadInfo* thr_info = thread_local_info_; |
| 2004 | if (!thr_info) { |
| 2005 | thr_info = SetupThreadLocalBuffer(); |
| 2006 | } |
| 2007 | |
| 2008 | // Avoid re-entrance of AddTraceEvent. This may happen in GPU process when |
| 2009 | // ECHO_TO_CONSOLE is enabled: AddTraceEvent -> LOG(ERROR) -> |
| 2010 | // GpuProcessLogMessageHandler -> PostPendingTask -> TRACE_EVENT ... |
| 2011 | if (base::subtle::NoBarrier_Load(&thr_info->is_in_trace_event_)) |
| 2012 | return; |
| 2013 | MarkFlagInScope thread_is_in_trace_event(&thr_info->is_in_trace_event_); |
| 2014 | |
| 2015 | MicrosecondsInt64 thread_now = GetThreadCpuTimeMicros(); |
| 2016 | MicrosecondsInt64 now = OffsetNow(); |
| 2017 | |
| 2018 | std::string console_message; |
| 2019 | if (*category_group_enabled & ENABLED_FOR_RECORDING) { |
| 2020 | OptionalAutoLock lock(lock_); |
| 2021 | |
| 2022 | TraceEvent* trace_event = GetEventByHandleInternal(handle, &lock); |
| 2023 | if (trace_event) { |
| 2024 | DCHECK(trace_event->phase() == TRACE_EVENT_PHASE_COMPLETE); |
| 2025 | trace_event->UpdateDuration(now, thread_now); |
| 2026 | #if defined(OS_ANDROID) |
| 2027 | trace_event->SendToATrace(); |
| 2028 | #endif |
| 2029 | } |
| 2030 | |
| 2031 | if (trace_options() & ECHO_TO_CONSOLE) { |
| 2032 | console_message = EventToConsoleMessage(TRACE_EVENT_PHASE_END, |
| 2033 | now, trace_event); |
| 2034 | } |
| 2035 | } |
| 2036 | |
| 2037 | if (console_message.size()) |
| 2038 | LOG(ERROR) << console_message; |
| 2039 | |
| 2040 | if (*category_group_enabled & ENABLED_FOR_EVENT_CALLBACK) { |
| 2041 | EventCallback event_callback = reinterpret_cast<EventCallback>( |
| 2042 | base::subtle::NoBarrier_Load(&event_callback_)); |
| 2043 | if (event_callback) { |
| 2044 | event_callback(now, TRACE_EVENT_PHASE_END, category_group_enabled, name, |
| 2045 | trace_event_internal::kNoEventId, 0, nullptr, nullptr, nullptr, |
| 2046 | TRACE_EVENT_FLAG_NONE); |
| 2047 | } |
| 2048 | } |
| 2049 | } |
| 2050 | |
| 2051 | void TraceLog::SetWatchEvent(const std::string& category_name, |
| 2052 | const std::string& event_name, |
nothing calls this directly
no test coverage detected