OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_event_impl.h" | 5 #include "base/trace_event/trace_event_impl.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 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
401 const char* metadata_name, const char* arg_name, | 401 const char* metadata_name, const char* arg_name, |
402 const T& value) { | 402 const T& value) { |
403 if (!trace_event) | 403 if (!trace_event) |
404 return; | 404 return; |
405 | 405 |
406 int num_args = 1; | 406 int num_args = 1; |
407 unsigned char arg_type; | 407 unsigned char arg_type; |
408 unsigned long long arg_value; | 408 unsigned long long arg_value; |
409 ::trace_event_internal::SetTraceValue(value, &arg_type, &arg_value); | 409 ::trace_event_internal::SetTraceValue(value, &arg_type, &arg_value); |
410 trace_event->Initialize( | 410 trace_event->Initialize( |
411 thread_id, TraceTicks(), ThreadTicks(), TRACE_EVENT_PHASE_METADATA, | 411 thread_id, |
412 &g_category_group_enabled[g_category_metadata], metadata_name, | 412 TraceTicks(), |
413 trace_event_internal::kNoId, trace_event_internal::kNoId, num_args, | 413 ThreadTicks(), |
414 &arg_name, &arg_type, &arg_value, NULL, TRACE_EVENT_FLAG_NONE); | 414 TRACE_EVENT_PHASE_METADATA, |
415 &g_category_group_enabled[g_category_metadata], | |
416 metadata_name, | |
417 trace_event_internal::kNoId, // id | |
418 trace_event_internal::kNoId, // context_id | |
419 trace_event_internal::kNoId, // bind_id | |
420 num_args, | |
421 &arg_name, | |
422 &arg_type, | |
423 &arg_value, | |
424 nullptr, | |
425 TRACE_EVENT_FLAG_NONE); | |
415 } | 426 } |
416 | 427 |
417 class AutoThreadLocalBoolean { | 428 class AutoThreadLocalBoolean { |
418 public: | 429 public: |
419 explicit AutoThreadLocalBoolean(ThreadLocalBoolean* thread_local_boolean) | 430 explicit AutoThreadLocalBoolean(ThreadLocalBoolean* thread_local_boolean) |
420 : thread_local_boolean_(thread_local_boolean) { | 431 : thread_local_boolean_(thread_local_boolean) { |
421 DCHECK(!thread_local_boolean_->Get()); | 432 DCHECK(!thread_local_boolean_->Get()); |
422 thread_local_boolean_->Set(true); | 433 thread_local_boolean_->Set(true); |
423 } | 434 } |
424 ~AutoThreadLocalBoolean() { | 435 ~AutoThreadLocalBoolean() { |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
585 | 596 |
586 void TraceEvent::Initialize( | 597 void TraceEvent::Initialize( |
587 int thread_id, | 598 int thread_id, |
588 TraceTicks timestamp, | 599 TraceTicks timestamp, |
589 ThreadTicks thread_timestamp, | 600 ThreadTicks thread_timestamp, |
590 char phase, | 601 char phase, |
591 const unsigned char* category_group_enabled, | 602 const unsigned char* category_group_enabled, |
592 const char* name, | 603 const char* name, |
593 unsigned long long id, | 604 unsigned long long id, |
594 unsigned long long context_id, | 605 unsigned long long context_id, |
606 unsigned long long bind_id, | |
595 int num_args, | 607 int num_args, |
596 const char** arg_names, | 608 const char** arg_names, |
597 const unsigned char* arg_types, | 609 const unsigned char* arg_types, |
598 const unsigned long long* arg_values, | 610 const unsigned long long* arg_values, |
599 const scoped_refptr<ConvertableToTraceFormat>* convertable_values, | 611 const scoped_refptr<ConvertableToTraceFormat>* convertable_values, |
600 unsigned int flags) { | 612 unsigned int flags) { |
601 timestamp_ = timestamp; | 613 timestamp_ = timestamp; |
602 thread_timestamp_ = thread_timestamp; | 614 thread_timestamp_ = thread_timestamp; |
603 duration_ = TimeDelta::FromInternalValue(-1); | 615 duration_ = TimeDelta::FromInternalValue(-1); |
604 id_ = id; | 616 id_ = id; |
605 context_id_ = context_id; | 617 context_id_ = context_id; |
606 category_group_enabled_ = category_group_enabled; | 618 category_group_enabled_ = category_group_enabled; |
607 name_ = name; | 619 name_ = name; |
608 thread_id_ = thread_id; | 620 thread_id_ = thread_id; |
609 phase_ = phase; | 621 phase_ = phase; |
610 flags_ = flags; | 622 flags_ = flags; |
623 bind_id_ = bind_id; | |
611 | 624 |
612 // Clamp num_args since it may have been set by a third_party library. | 625 // Clamp num_args since it may have been set by a third_party library. |
613 num_args = (num_args > kTraceMaxNumArgs) ? kTraceMaxNumArgs : num_args; | 626 num_args = (num_args > kTraceMaxNumArgs) ? kTraceMaxNumArgs : num_args; |
614 int i = 0; | 627 int i = 0; |
615 for (; i < num_args; ++i) { | 628 for (; i < num_args; ++i) { |
616 arg_names_[i] = arg_names[i]; | 629 arg_names_[i] = arg_names[i]; |
617 arg_types_[i] = arg_types[i]; | 630 arg_types_[i] = arg_types[i]; |
618 | 631 |
619 if (arg_types[i] == TRACE_VALUE_TYPE_CONVERTABLE) | 632 if (arg_types[i] == TRACE_VALUE_TYPE_CONVERTABLE) |
620 convertable_values_[i] = convertable_values[i]; | 633 convertable_values_[i] = convertable_values[i]; |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
842 } | 855 } |
843 | 856 |
844 // If id_ is set, print it out as a hex string so we don't loose any | 857 // If id_ is set, print it out as a hex string so we don't loose any |
845 // bits (it might be a 64-bit pointer). | 858 // bits (it might be a 64-bit pointer). |
846 if (flags_ & TRACE_EVENT_FLAG_HAS_ID) | 859 if (flags_ & TRACE_EVENT_FLAG_HAS_ID) |
847 StringAppendF(out, ",\"id\":\"0x%" PRIx64 "\"", static_cast<uint64>(id_)); | 860 StringAppendF(out, ",\"id\":\"0x%" PRIx64 "\"", static_cast<uint64>(id_)); |
848 | 861 |
849 if (flags_ & TRACE_EVENT_FLAG_BIND_TO_ENCLOSING) | 862 if (flags_ & TRACE_EVENT_FLAG_BIND_TO_ENCLOSING) |
850 StringAppendF(out, ",\"bp\":\"e\""); | 863 StringAppendF(out, ",\"bp\":\"e\""); |
851 | 864 |
865 if ((flags_ & TRACE_EVENT_FLAG_FLOW_OUT) || | |
866 (flags_ & TRACE_EVENT_FLAG_FLOW_IN)) { | |
867 StringAppendF(out, ",\"bind_id\":\"0x%" PRIx64 "\"", | |
868 static_cast<uint64>(bind_id_)); | |
869 } | |
870 | |
871 if (flags_ & TRACE_EVENT_FLAG_FLOW_IN) | |
872 StringAppendF(out, ",\"flow_in\":true"); | |
873 | |
874 if (flags_ & TRACE_EVENT_FLAG_FLOW_OUT) | |
875 StringAppendF(out, ",\"flow_out\":true"); | |
876 | |
852 // Similar to id_, print the context_id as hex if present. | 877 // Similar to id_, print the context_id as hex if present. |
853 if (flags_ & TRACE_EVENT_FLAG_HAS_CONTEXT_ID) | 878 if (flags_ & TRACE_EVENT_FLAG_HAS_CONTEXT_ID) |
854 StringAppendF(out, ",\"cid\":\"0x%" PRIx64 "\"", | 879 StringAppendF(out, ",\"cid\":\"0x%" PRIx64 "\"", |
855 static_cast<uint64>(context_id_)); | 880 static_cast<uint64>(context_id_)); |
856 | 881 |
857 // Instant events also output their scope. | 882 // Instant events also output their scope. |
858 if (phase_ == TRACE_EVENT_PHASE_INSTANT) { | 883 if (phase_ == TRACE_EVENT_PHASE_INSTANT) { |
859 char scope = '?'; | 884 char scope = '?'; |
860 switch (flags_ & TRACE_EVENT_FLAG_SCOPE_MASK) { | 885 switch (flags_ & TRACE_EVENT_FLAG_SCOPE_MASK) { |
861 case TRACE_EVENT_SCOPE_GLOBAL: | 886 case TRACE_EVENT_SCOPE_GLOBAL: |
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1207 CheckThisIsCurrentBuffer(); | 1232 CheckThisIsCurrentBuffer(); |
1208 | 1233 |
1209 event_count_++; | 1234 event_count_++; |
1210 ThreadTicks thread_now = ThreadNow(); | 1235 ThreadTicks thread_now = ThreadNow(); |
1211 TraceTicks now = trace_log_->OffsetNow(); | 1236 TraceTicks now = trace_log_->OffsetNow(); |
1212 TimeDelta overhead = now - event_timestamp; | 1237 TimeDelta overhead = now - event_timestamp; |
1213 if (overhead.InMicroseconds() >= kOverheadReportThresholdInMicroseconds) { | 1238 if (overhead.InMicroseconds() >= kOverheadReportThresholdInMicroseconds) { |
1214 TraceEvent* trace_event = AddTraceEvent(NULL); | 1239 TraceEvent* trace_event = AddTraceEvent(NULL); |
1215 if (trace_event) { | 1240 if (trace_event) { |
1216 trace_event->Initialize( | 1241 trace_event->Initialize( |
1217 static_cast<int>(PlatformThread::CurrentId()), event_timestamp, | 1242 static_cast<int>(PlatformThread::CurrentId()), |
1218 event_thread_timestamp, TRACE_EVENT_PHASE_COMPLETE, | 1243 event_timestamp, |
1244 event_thread_timestamp, | |
1245 TRACE_EVENT_PHASE_COMPLETE, | |
1219 &g_category_group_enabled[g_category_trace_event_overhead], | 1246 &g_category_group_enabled[g_category_trace_event_overhead], |
1220 "overhead", ::trace_event_internal::kNoId, | 1247 "overhead", |
1221 ::trace_event_internal::kNoId, ::trace_event_internal::kZeroNumArgs, | 1248 trace_event_internal::kNoId, // id |
1222 NULL, NULL, NULL, NULL, 0); | 1249 trace_event_internal::kNoId, // context_id |
1250 trace_event_internal::kNoId, // bind_id | |
beaudoin
2015/07/27 18:34:13
NIT: 2 spaces before EOL comment.
| |
1251 trace_event_internal::kZeroNumArgs, | |
1252 nullptr, | |
1253 nullptr, | |
1254 nullptr, | |
1255 nullptr, | |
1256 TRACE_EVENT_FLAG_NONE); | |
1223 trace_event->UpdateDuration(now, thread_now); | 1257 trace_event->UpdateDuration(now, thread_now); |
1224 } | 1258 } |
1225 } | 1259 } |
1226 overhead_ += overhead; | 1260 overhead_ += overhead; |
1227 } | 1261 } |
1228 | 1262 |
1229 void TraceLog::ThreadLocalEventBuffer::WillDestroyCurrentMessageLoop() { | 1263 void TraceLog::ThreadLocalEventBuffer::WillDestroyCurrentMessageLoop() { |
1230 delete this; | 1264 delete this; |
1231 } | 1265 } |
1232 | 1266 |
(...skipping 778 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2011 unsigned long long id, | 2045 unsigned long long id, |
2012 int num_args, | 2046 int num_args, |
2013 const char** arg_names, | 2047 const char** arg_names, |
2014 const unsigned char* arg_types, | 2048 const unsigned char* arg_types, |
2015 const unsigned long long* arg_values, | 2049 const unsigned long long* arg_values, |
2016 const scoped_refptr<ConvertableToTraceFormat>* convertable_values, | 2050 const scoped_refptr<ConvertableToTraceFormat>* convertable_values, |
2017 unsigned int flags) { | 2051 unsigned int flags) { |
2018 int thread_id = static_cast<int>(base::PlatformThread::CurrentId()); | 2052 int thread_id = static_cast<int>(base::PlatformThread::CurrentId()); |
2019 base::TraceTicks now = base::TraceTicks::Now(); | 2053 base::TraceTicks now = base::TraceTicks::Now(); |
2020 return AddTraceEventWithThreadIdAndTimestamp( | 2054 return AddTraceEventWithThreadIdAndTimestamp( |
2021 phase, category_group_enabled, name, id, ::trace_event_internal::kNoId, | 2055 phase, |
2022 thread_id, now, num_args, arg_names, arg_types, arg_values, | 2056 category_group_enabled, |
2023 convertable_values, flags); | 2057 name, |
2058 id, | |
2059 trace_event_internal::kNoId, // context_id | |
2060 trace_event_internal::kNoId, // bind_id | |
beaudoin
2015/07/27 18:34:13
NIT: 2 spaces before EOL comment.
| |
2061 thread_id, | |
2062 now, | |
2063 num_args, | |
2064 arg_names, | |
2065 arg_types, | |
2066 arg_values, | |
2067 convertable_values, | |
2068 flags); | |
2024 } | 2069 } |
2025 | 2070 |
2026 TraceEventHandle TraceLog::AddTraceEventWithContextId( | 2071 TraceEventHandle TraceLog::AddTraceEventWithContextId( |
2027 char phase, | 2072 char phase, |
2028 const unsigned char* category_group_enabled, | 2073 const unsigned char* category_group_enabled, |
2029 const char* name, | 2074 const char* name, |
2030 unsigned long long id, | 2075 unsigned long long id, |
2031 unsigned long long context_id, | 2076 unsigned long long context_id, |
2032 int num_args, | 2077 int num_args, |
2033 const char** arg_names, | 2078 const char** arg_names, |
2034 const unsigned char* arg_types, | 2079 const unsigned char* arg_types, |
2035 const unsigned long long* arg_values, | 2080 const unsigned long long* arg_values, |
2036 const scoped_refptr<ConvertableToTraceFormat>* convertable_values, | 2081 const scoped_refptr<ConvertableToTraceFormat>* convertable_values, |
2037 unsigned int flags) { | 2082 unsigned int flags) { |
2038 int thread_id = static_cast<int>(base::PlatformThread::CurrentId()); | 2083 int thread_id = static_cast<int>(base::PlatformThread::CurrentId()); |
2039 base::TraceTicks now = base::TraceTicks::Now(); | 2084 base::TraceTicks now = base::TraceTicks::Now(); |
2040 return AddTraceEventWithThreadIdAndTimestamp( | 2085 return AddTraceEventWithThreadIdAndTimestamp( |
2041 phase, category_group_enabled, name, id, context_id, thread_id, now, | 2086 phase, |
2042 num_args, arg_names, arg_types, arg_values, convertable_values, | 2087 category_group_enabled, |
2088 name, | |
2089 id, | |
2090 context_id, | |
2091 trace_event_internal::kNoId, // bind_id | |
beaudoin
2015/07/27 18:34:14
NIT: 2 spaces before EOL comment.
| |
2092 thread_id, | |
2093 now, | |
2094 num_args, | |
2095 arg_names, | |
2096 arg_types, | |
2097 arg_values, | |
2098 convertable_values, | |
2043 flags | TRACE_EVENT_FLAG_HAS_CONTEXT_ID); | 2099 flags | TRACE_EVENT_FLAG_HAS_CONTEXT_ID); |
2044 } | 2100 } |
2045 | 2101 |
2102 // Handle legacy calls to AddTraceEventWithThreadIdAndTimestamp | |
2103 // with kNoId as bind_id | |
2046 TraceEventHandle TraceLog::AddTraceEventWithThreadIdAndTimestamp( | 2104 TraceEventHandle TraceLog::AddTraceEventWithThreadIdAndTimestamp( |
2047 char phase, | 2105 char phase, |
2048 const unsigned char* category_group_enabled, | 2106 const unsigned char* category_group_enabled, |
2049 const char* name, | 2107 const char* name, |
2050 unsigned long long id, | 2108 unsigned long long id, |
2051 unsigned long long context_id, | 2109 unsigned long long context_id, |
2052 int thread_id, | 2110 int thread_id, |
2053 const TraceTicks& timestamp, | 2111 const TraceTicks& timestamp, |
2054 int num_args, | 2112 int num_args, |
2113 const char** arg_names, | |
2114 const unsigned char* arg_types, | |
2115 const unsigned long long* arg_values, | |
2116 const scoped_refptr<ConvertableToTraceFormat>* convertable_values, | |
2117 unsigned int flags) { | |
2118 return AddTraceEventWithThreadIdAndTimestamp( | |
2119 phase, | |
2120 category_group_enabled, | |
2121 name, | |
2122 id, | |
2123 context_id, | |
2124 trace_event_internal::kNoId, // bind_id | |
beaudoin
2015/07/27 18:34:13
NIT: 2 spaces before EOL comment.
| |
2125 thread_id, | |
2126 timestamp, | |
2127 num_args, | |
2128 arg_names, | |
2129 arg_types, | |
2130 arg_values, | |
2131 convertable_values, | |
2132 flags); | |
2133 } | |
2134 | |
2135 TraceEventHandle TraceLog::AddTraceEventWithThreadIdAndTimestamp( | |
2136 char phase, | |
2137 const unsigned char* category_group_enabled, | |
2138 const char* name, | |
2139 unsigned long long id, | |
2140 unsigned long long context_id, | |
2141 unsigned long long bind_id, | |
2142 int thread_id, | |
2143 const TraceTicks& timestamp, | |
2144 int num_args, | |
2055 const char** arg_names, | 2145 const char** arg_names, |
2056 const unsigned char* arg_types, | 2146 const unsigned char* arg_types, |
2057 const unsigned long long* arg_values, | 2147 const unsigned long long* arg_values, |
2058 const scoped_refptr<ConvertableToTraceFormat>* convertable_values, | 2148 const scoped_refptr<ConvertableToTraceFormat>* convertable_values, |
2059 unsigned int flags) { | 2149 unsigned int flags) { |
2060 TraceEventHandle handle = { 0, 0, 0 }; | 2150 TraceEventHandle handle = { 0, 0, 0 }; |
2061 if (!*category_group_enabled) | 2151 if (!*category_group_enabled) |
2062 return handle; | 2152 return handle; |
2063 | 2153 |
2064 // Avoid re-entrance of AddTraceEvent. This may happen in GPU process when | 2154 // Avoid re-entrance of AddTraceEvent. This may happen in GPU process when |
2065 // ECHO_TO_CONSOLE is enabled: AddTraceEvent -> LOG(ERROR) -> | 2155 // ECHO_TO_CONSOLE is enabled: AddTraceEvent -> LOG(ERROR) -> |
2066 // GpuProcessLogMessageHandler -> PostPendingTask -> TRACE_EVENT ... | 2156 // GpuProcessLogMessageHandler -> PostPendingTask -> TRACE_EVENT ... |
2067 if (thread_is_in_trace_event_.Get()) | 2157 if (thread_is_in_trace_event_.Get()) |
2068 return handle; | 2158 return handle; |
2069 | 2159 |
2070 AutoThreadLocalBoolean thread_is_in_trace_event(&thread_is_in_trace_event_); | 2160 AutoThreadLocalBoolean thread_is_in_trace_event(&thread_is_in_trace_event_); |
2071 | 2161 |
2072 DCHECK(name); | 2162 DCHECK(name); |
2073 DCHECK(!timestamp.is_null()); | 2163 DCHECK(!timestamp.is_null()); |
2074 | 2164 |
2075 if (flags & TRACE_EVENT_FLAG_MANGLE_ID) | 2165 if (flags & TRACE_EVENT_FLAG_MANGLE_ID) { |
2166 if ((flags & TRACE_EVENT_FLAG_FLOW_IN) || | |
2167 (flags & TRACE_EVENT_FLAG_FLOW_OUT)) | |
2168 bind_id = MangleEventId(bind_id); | |
2076 id = MangleEventId(id); | 2169 id = MangleEventId(id); |
2170 } | |
2077 | 2171 |
2078 TraceTicks offset_event_timestamp = OffsetTimestamp(timestamp); | 2172 TraceTicks offset_event_timestamp = OffsetTimestamp(timestamp); |
2079 TraceTicks now = flags & TRACE_EVENT_FLAG_EXPLICIT_TIMESTAMP ? | 2173 TraceTicks now = flags & TRACE_EVENT_FLAG_EXPLICIT_TIMESTAMP ? |
2080 OffsetNow() : offset_event_timestamp; | 2174 OffsetNow() : offset_event_timestamp; |
2081 ThreadTicks thread_now = ThreadNow(); | 2175 ThreadTicks thread_now = ThreadNow(); |
2082 | 2176 |
2083 // |thread_local_event_buffer_| can be null if the current thread doesn't have | 2177 // |thread_local_event_buffer_| can be null if the current thread doesn't have |
2084 // a message loop or the message loop is blocked. | 2178 // a message loop or the message loop is blocked. |
2085 InitializeThreadLocalEventBufferIfSupported(); | 2179 InitializeThreadLocalEventBufferIfSupported(); |
2086 auto thread_local_event_buffer = thread_local_event_buffer_.Get(); | 2180 auto thread_local_event_buffer = thread_local_event_buffer_.Get(); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2140 | 2234 |
2141 TraceEvent* trace_event = NULL; | 2235 TraceEvent* trace_event = NULL; |
2142 if (thread_local_event_buffer) { | 2236 if (thread_local_event_buffer) { |
2143 trace_event = thread_local_event_buffer->AddTraceEvent(&handle); | 2237 trace_event = thread_local_event_buffer->AddTraceEvent(&handle); |
2144 } else { | 2238 } else { |
2145 lock.EnsureAcquired(); | 2239 lock.EnsureAcquired(); |
2146 trace_event = AddEventToThreadSharedChunkWhileLocked(&handle, true); | 2240 trace_event = AddEventToThreadSharedChunkWhileLocked(&handle, true); |
2147 } | 2241 } |
2148 | 2242 |
2149 if (trace_event) { | 2243 if (trace_event) { |
2150 trace_event->Initialize(thread_id, offset_event_timestamp, thread_now, | 2244 trace_event->Initialize(thread_id, |
2151 phase, category_group_enabled, name, id, | 2245 offset_event_timestamp, |
2152 context_id, num_args, arg_names, arg_types, | 2246 thread_now, |
2153 arg_values, convertable_values, flags); | 2247 phase, |
2248 category_group_enabled, | |
2249 name, | |
2250 id, | |
2251 context_id, | |
2252 bind_id, | |
2253 num_args, | |
2254 arg_names, | |
2255 arg_types, | |
2256 arg_values, | |
2257 convertable_values, | |
2258 flags); | |
2154 | 2259 |
2155 #if defined(OS_ANDROID) | 2260 #if defined(OS_ANDROID) |
2156 trace_event->SendToATrace(); | 2261 trace_event->SendToATrace(); |
2157 #endif | 2262 #endif |
2158 } | 2263 } |
2159 | 2264 |
2160 if (trace_options() & kInternalEchoToConsole) { | 2265 if (trace_options() & kInternalEchoToConsole) { |
2161 console_message = EventToConsoleMessage( | 2266 console_message = EventToConsoleMessage( |
2162 phase == TRACE_EVENT_PHASE_COMPLETE ? TRACE_EVENT_PHASE_BEGIN : phase, | 2267 phase == TRACE_EVENT_PHASE_COMPLETE ? TRACE_EVENT_PHASE_BEGIN : phase, |
2163 timestamp, trace_event); | 2268 timestamp, trace_event); |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2306 } | 2411 } |
2307 } | 2412 } |
2308 | 2413 |
2309 if (console_message.size()) | 2414 if (console_message.size()) |
2310 LOG(ERROR) << console_message; | 2415 LOG(ERROR) << console_message; |
2311 | 2416 |
2312 if (*category_group_enabled & ENABLED_FOR_EVENT_CALLBACK) { | 2417 if (*category_group_enabled & ENABLED_FOR_EVENT_CALLBACK) { |
2313 EventCallback event_callback = reinterpret_cast<EventCallback>( | 2418 EventCallback event_callback = reinterpret_cast<EventCallback>( |
2314 subtle::NoBarrier_Load(&event_callback_)); | 2419 subtle::NoBarrier_Load(&event_callback_)); |
2315 if (event_callback) { | 2420 if (event_callback) { |
2316 event_callback(now, TRACE_EVENT_PHASE_END, category_group_enabled, name, | 2421 event_callback(now, |
2317 trace_event_internal::kNoId, trace_event_internal::kNoId, | 2422 TRACE_EVENT_PHASE_END, |
2318 NULL, NULL, NULL, TRACE_EVENT_FLAG_NONE); | 2423 category_group_enabled, |
2424 name, | |
2425 trace_event_internal::kNoId, | |
2426 trace_event_internal::kNoId, | |
beaudoin
2015/07/27 18:34:13
EOL comments?
beaudoin
2015/07/29 18:55:43
Not done?
yuhaoz
2015/07/29 19:09:39
Done. Following the format of the code at line 229
| |
2427 NULL, | |
2428 NULL, | |
2429 NULL, | |
2430 TRACE_EVENT_FLAG_NONE); | |
2319 } | 2431 } |
2320 } | 2432 } |
2321 } | 2433 } |
2322 | 2434 |
2323 void TraceLog::SetWatchEvent(const std::string& category_name, | 2435 void TraceLog::SetWatchEvent(const std::string& category_name, |
2324 const std::string& event_name, | 2436 const std::string& event_name, |
2325 const WatchEventCallback& callback) { | 2437 const WatchEventCallback& callback) { |
2326 const unsigned char* category = GetCategoryGroupEnabled( | 2438 const unsigned char* category = GetCategoryGroupEnabled( |
2327 category_name.c_str()); | 2439 category_name.c_str()); |
2328 AutoLock lock(lock_); | 2440 AutoLock lock(lock_); |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2531 const char* category_group, const char* name) { | 2643 const char* category_group, const char* name) { |
2532 // The single atom works because for now the category_group can only be "gpu". | 2644 // The single atom works because for now the category_group can only be "gpu". |
2533 DCHECK_EQ(strcmp(category_group, "gpu"), 0); | 2645 DCHECK_EQ(strcmp(category_group, "gpu"), 0); |
2534 static TRACE_EVENT_API_ATOMIC_WORD atomic = 0; | 2646 static TRACE_EVENT_API_ATOMIC_WORD atomic = 0; |
2535 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO_CUSTOM_VARIABLES( | 2647 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO_CUSTOM_VARIABLES( |
2536 category_group, atomic, category_group_enabled_); | 2648 category_group, atomic, category_group_enabled_); |
2537 name_ = name; | 2649 name_ = name; |
2538 if (*category_group_enabled_) { | 2650 if (*category_group_enabled_) { |
2539 event_handle_ = | 2651 event_handle_ = |
2540 TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_THREAD_ID_AND_TIMESTAMP( | 2652 TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_THREAD_ID_AND_TIMESTAMP( |
2541 TRACE_EVENT_PHASE_COMPLETE, category_group_enabled_, name, kNoId, | 2653 TRACE_EVENT_PHASE_COMPLETE, |
2542 kNoId, static_cast<int>(base::PlatformThread::CurrentId()), | 2654 category_group_enabled_, |
2543 base::TraceTicks::Now(), 0, NULL, NULL, NULL, NULL, | 2655 name, |
2656 trace_event_internal::kNoId, // id | |
2657 trace_event_internal::kNoId, // context_id | |
beaudoin
2015/07/27 18:34:13
NIT: 2 spaces before EOL comment.
| |
2658 static_cast<int>(base::PlatformThread::CurrentId()), | |
2659 base::TraceTicks::Now(), | |
2660 trace_event_internal::kZeroNumArgs, | |
2661 nullptr, | |
2662 nullptr, | |
2663 nullptr, | |
2664 nullptr, | |
2544 TRACE_EVENT_FLAG_NONE); | 2665 TRACE_EVENT_FLAG_NONE); |
2545 } | 2666 } |
2546 } | 2667 } |
2547 | 2668 |
2548 ScopedTraceBinaryEfficient::~ScopedTraceBinaryEfficient() { | 2669 ScopedTraceBinaryEfficient::~ScopedTraceBinaryEfficient() { |
2549 if (*category_group_enabled_) { | 2670 if (*category_group_enabled_) { |
2550 TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION(category_group_enabled_, | 2671 TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION(category_group_enabled_, |
2551 name_, event_handle_); | 2672 name_, event_handle_); |
2552 } | 2673 } |
2553 } | 2674 } |
2554 | 2675 |
2555 } // namespace trace_event_internal | 2676 } // namespace trace_event_internal |
OLD | NEW |