Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Side by Side Diff: base/trace_event/trace_event_impl.cc

Issue 1239593002: Implement a new flow event API that allows binding flow events and regular events. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Mainly incorporates context_id into the new flow event APIs. Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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,
vmpstr 2015/07/21 18:03:41 nit: Can you put some inline comments with what th
418 trace_event_internal::kNoId,
419 trace_event_internal::kNoId,
420 num_args,
421 &arg_name,
422 &arg_type,
423 &arg_value,
424 NULL,
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
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
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 "\"",
vmpstr 2015/07/21 18:03:41 nit: can you put braces around the if (usually we
868 static_cast<uint64>(bind_id_));
869
870 if (flags_ & TRACE_EVENT_FLAG_FLOW_IN)
871 StringAppendF(out, ",\"flow_in\":true");
872
873 if (flags_ & TRACE_EVENT_FLAG_FLOW_OUT)
874 StringAppendF(out, ",\"flow_out\":true");
875
852 // Similar to id_, print the context_id as hex if present. 876 // Similar to id_, print the context_id as hex if present.
853 if (flags_ & TRACE_EVENT_FLAG_HAS_CONTEXT_ID) 877 if (flags_ & TRACE_EVENT_FLAG_HAS_CONTEXT_ID)
854 StringAppendF(out, ",\"cid\":\"0x%" PRIx64 "\"", 878 StringAppendF(out, ",\"cid\":\"0x%" PRIx64 "\"",
855 static_cast<uint64>(context_id_)); 879 static_cast<uint64>(context_id_));
856 880
857 // Instant events also output their scope. 881 // Instant events also output their scope.
858 if (phase_ == TRACE_EVENT_PHASE_INSTANT) { 882 if (phase_ == TRACE_EVENT_PHASE_INSTANT) {
859 char scope = '?'; 883 char scope = '?';
860 switch (flags_ & TRACE_EVENT_FLAG_SCOPE_MASK) { 884 switch (flags_ & TRACE_EVENT_FLAG_SCOPE_MASK) {
861 case TRACE_EVENT_SCOPE_GLOBAL: 885 case TRACE_EVENT_SCOPE_GLOBAL:
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after
1207 CheckThisIsCurrentBuffer(); 1231 CheckThisIsCurrentBuffer();
1208 1232
1209 event_count_++; 1233 event_count_++;
1210 ThreadTicks thread_now = ThreadNow(); 1234 ThreadTicks thread_now = ThreadNow();
1211 TraceTicks now = trace_log_->OffsetNow(); 1235 TraceTicks now = trace_log_->OffsetNow();
1212 TimeDelta overhead = now - event_timestamp; 1236 TimeDelta overhead = now - event_timestamp;
1213 if (overhead.InMicroseconds() >= kOverheadReportThresholdInMicroseconds) { 1237 if (overhead.InMicroseconds() >= kOverheadReportThresholdInMicroseconds) {
1214 TraceEvent* trace_event = AddTraceEvent(NULL); 1238 TraceEvent* trace_event = AddTraceEvent(NULL);
1215 if (trace_event) { 1239 if (trace_event) {
1216 trace_event->Initialize( 1240 trace_event->Initialize(
1217 static_cast<int>(PlatformThread::CurrentId()), event_timestamp, 1241 static_cast<int>(PlatformThread::CurrentId()),
1218 event_thread_timestamp, TRACE_EVENT_PHASE_COMPLETE, 1242 event_timestamp,
1243 event_thread_timestamp,
1244 TRACE_EVENT_PHASE_COMPLETE,
1219 &g_category_group_enabled[g_category_trace_event_overhead], 1245 &g_category_group_enabled[g_category_trace_event_overhead],
1220 "overhead", ::trace_event_internal::kNoId, 1246 "overhead",
1221 ::trace_event_internal::kNoId, ::trace_event_internal::kZeroNumArgs, 1247 trace_event_internal::kNoId,
1222 NULL, NULL, NULL, NULL, 0); 1248 trace_event_internal::kNoId,
1249 trace_event_internal::kNoId,
1250 trace_event_internal::kZeroNumArgs,
1251 NULL,
1252 NULL,
1253 NULL,
1254 NULL,
vmpstr 2015/07/21 18:03:41 nit: For the functions that you're updating, can y
1255 TRACE_EVENT_FLAG_NONE);
1223 trace_event->UpdateDuration(now, thread_now); 1256 trace_event->UpdateDuration(now, thread_now);
1224 } 1257 }
1225 } 1258 }
1226 overhead_ += overhead; 1259 overhead_ += overhead;
1227 } 1260 }
1228 1261
1229 void TraceLog::ThreadLocalEventBuffer::WillDestroyCurrentMessageLoop() { 1262 void TraceLog::ThreadLocalEventBuffer::WillDestroyCurrentMessageLoop() {
1230 delete this; 1263 delete this;
1231 } 1264 }
1232 1265
(...skipping 778 matching lines...) Expand 10 before | Expand all | Expand 10 after
2011 unsigned long long id, 2044 unsigned long long id,
2012 int num_args, 2045 int num_args,
2013 const char** arg_names, 2046 const char** arg_names,
2014 const unsigned char* arg_types, 2047 const unsigned char* arg_types,
2015 const unsigned long long* arg_values, 2048 const unsigned long long* arg_values,
2016 const scoped_refptr<ConvertableToTraceFormat>* convertable_values, 2049 const scoped_refptr<ConvertableToTraceFormat>* convertable_values,
2017 unsigned int flags) { 2050 unsigned int flags) {
2018 int thread_id = static_cast<int>(base::PlatformThread::CurrentId()); 2051 int thread_id = static_cast<int>(base::PlatformThread::CurrentId());
2019 base::TraceTicks now = base::TraceTicks::Now(); 2052 base::TraceTicks now = base::TraceTicks::Now();
2020 return AddTraceEventWithThreadIdAndTimestamp( 2053 return AddTraceEventWithThreadIdAndTimestamp(
2021 phase, category_group_enabled, name, id, ::trace_event_internal::kNoId, 2054 phase,
2022 thread_id, now, num_args, arg_names, arg_types, arg_values, 2055 category_group_enabled,
2023 convertable_values, flags); 2056 name,
2057 id,
2058 trace_event_internal::kNoId,
2059 trace_event_internal::kNoId,
2060 thread_id,
2061 now,
2062 num_args,
2063 arg_names,
2064 arg_types,
2065 arg_values,
2066 convertable_values,
2067 flags);
2024 } 2068 }
2025 2069
2026 TraceEventHandle TraceLog::AddTraceEventWithContextId( 2070 TraceEventHandle TraceLog::AddTraceEventWithContextId(
2027 char phase, 2071 char phase,
2028 const unsigned char* category_group_enabled, 2072 const unsigned char* category_group_enabled,
2029 const char* name, 2073 const char* name,
2030 unsigned long long id, 2074 unsigned long long id,
2031 unsigned long long context_id, 2075 unsigned long long context_id,
2032 int num_args, 2076 int num_args,
2033 const char** arg_names, 2077 const char** arg_names,
2034 const unsigned char* arg_types, 2078 const unsigned char* arg_types,
2035 const unsigned long long* arg_values, 2079 const unsigned long long* arg_values,
2036 const scoped_refptr<ConvertableToTraceFormat>* convertable_values, 2080 const scoped_refptr<ConvertableToTraceFormat>* convertable_values,
2037 unsigned int flags) { 2081 unsigned int flags) {
2038 int thread_id = static_cast<int>(base::PlatformThread::CurrentId()); 2082 int thread_id = static_cast<int>(base::PlatformThread::CurrentId());
2039 base::TraceTicks now = base::TraceTicks::Now(); 2083 base::TraceTicks now = base::TraceTicks::Now();
2040 return AddTraceEventWithThreadIdAndTimestamp( 2084 return AddTraceEventWithThreadIdAndTimestamp(
2041 phase, category_group_enabled, name, id, context_id, thread_id, now, 2085 phase,
2042 num_args, arg_names, arg_types, arg_values, convertable_values, 2086 category_group_enabled,
2087 name,
2088 id,
2089 context_id,
2090 trace_event_internal::kNoId,
2091 thread_id,
2092 now,
2093 num_args,
2094 arg_names,
2095 arg_types,
2096 arg_values,
2097 convertable_values,
2043 flags | TRACE_EVENT_FLAG_HAS_CONTEXT_ID); 2098 flags | TRACE_EVENT_FLAG_HAS_CONTEXT_ID);
2044 } 2099 }
2045 2100
2101 // Handle legacy calls to AddTraceEventWithThreadIdAndTimestamp
2102 // with kNoId as bind_id
2103 TraceEventHandle TraceLog::AddTraceEventWithThreadIdAndTimestamp(
2104 char phase,
2105 const unsigned char* category_group_enabled,
2106 const char* name,
2107 unsigned long long id,
2108 int thread_id,
2109 const TraceTicks& timestamp,
2110 int num_args,
2111 const char** arg_names,
2112 const unsigned char* arg_types,
2113 const unsigned long long* arg_values,
2114 const scoped_refptr<ConvertableToTraceFormat>* convertable_values,
2115 unsigned int flags) {
2116 return AddTraceEventWithThreadIdAndTimestamp(
2117 phase,
2118 category_group_enabled,
2119 name,
2120 id,
2121 trace_event_internal::kNoId,
2122 trace_event_internal::kNoId,
2123 thread_id,
2124 timestamp,
2125 num_args,
2126 arg_names,
2127 arg_types,
2128 arg_values,
2129 convertable_values,
2130 flags);
2131 }
2132
2046 TraceEventHandle TraceLog::AddTraceEventWithThreadIdAndTimestamp( 2133 TraceEventHandle TraceLog::AddTraceEventWithThreadIdAndTimestamp(
2047 char phase, 2134 char phase,
2048 const unsigned char* category_group_enabled, 2135 const unsigned char* category_group_enabled,
2049 const char* name, 2136 const char* name,
2050 unsigned long long id, 2137 unsigned long long id,
2051 unsigned long long context_id, 2138 unsigned long long context_id,
2139 unsigned long long bind_id,
2052 int thread_id, 2140 int thread_id,
2053 const TraceTicks& timestamp, 2141 const TraceTicks& timestamp,
2054 int num_args, 2142 int num_args,
2055 const char** arg_names, 2143 const char** arg_names,
2056 const unsigned char* arg_types, 2144 const unsigned char* arg_types,
2057 const unsigned long long* arg_values, 2145 const unsigned long long* arg_values,
2058 const scoped_refptr<ConvertableToTraceFormat>* convertable_values, 2146 const scoped_refptr<ConvertableToTraceFormat>* convertable_values,
2059 unsigned int flags) { 2147 unsigned int flags) {
2060 TraceEventHandle handle = { 0, 0, 0 }; 2148 TraceEventHandle handle = { 0, 0, 0 };
2061 if (!*category_group_enabled) 2149 if (!*category_group_enabled)
2062 return handle; 2150 return handle;
2063 2151
2064 // Avoid re-entrance of AddTraceEvent. This may happen in GPU process when 2152 // Avoid re-entrance of AddTraceEvent. This may happen in GPU process when
2065 // ECHO_TO_CONSOLE is enabled: AddTraceEvent -> LOG(ERROR) -> 2153 // ECHO_TO_CONSOLE is enabled: AddTraceEvent -> LOG(ERROR) ->
2066 // GpuProcessLogMessageHandler -> PostPendingTask -> TRACE_EVENT ... 2154 // GpuProcessLogMessageHandler -> PostPendingTask -> TRACE_EVENT ...
2067 if (thread_is_in_trace_event_.Get()) 2155 if (thread_is_in_trace_event_.Get())
2068 return handle; 2156 return handle;
2069 2157
2070 AutoThreadLocalBoolean thread_is_in_trace_event(&thread_is_in_trace_event_); 2158 AutoThreadLocalBoolean thread_is_in_trace_event(&thread_is_in_trace_event_);
2071 2159
2072 DCHECK(name); 2160 DCHECK(name);
2073 DCHECK(!timestamp.is_null()); 2161 DCHECK(!timestamp.is_null());
2074 2162
2075 if (flags & TRACE_EVENT_FLAG_MANGLE_ID) 2163 if (flags & TRACE_EVENT_FLAG_MANGLE_ID) {
2164 if ((flags & TRACE_EVENT_FLAG_FLOW_IN) ||
2165 (flags & TRACE_EVENT_FLAG_FLOW_OUT))
2166 bind_id = MangleEventId(bind_id);
2076 id = MangleEventId(id); 2167 id = MangleEventId(id);
2168 }
2077 2169
2078 TraceTicks offset_event_timestamp = OffsetTimestamp(timestamp); 2170 TraceTicks offset_event_timestamp = OffsetTimestamp(timestamp);
2079 TraceTicks now = flags & TRACE_EVENT_FLAG_EXPLICIT_TIMESTAMP ? 2171 TraceTicks now = flags & TRACE_EVENT_FLAG_EXPLICIT_TIMESTAMP ?
2080 OffsetNow() : offset_event_timestamp; 2172 OffsetNow() : offset_event_timestamp;
2081 ThreadTicks thread_now = ThreadNow(); 2173 ThreadTicks thread_now = ThreadNow();
2082 2174
2083 // |thread_local_event_buffer_| can be null if the current thread doesn't have 2175 // |thread_local_event_buffer_| can be null if the current thread doesn't have
2084 // a message loop or the message loop is blocked. 2176 // a message loop or the message loop is blocked.
2085 InitializeThreadLocalEventBufferIfSupported(); 2177 InitializeThreadLocalEventBufferIfSupported();
2086 auto thread_local_event_buffer = thread_local_event_buffer_.Get(); 2178 auto thread_local_event_buffer = thread_local_event_buffer_.Get();
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
2140 2232
2141 TraceEvent* trace_event = NULL; 2233 TraceEvent* trace_event = NULL;
2142 if (thread_local_event_buffer) { 2234 if (thread_local_event_buffer) {
2143 trace_event = thread_local_event_buffer->AddTraceEvent(&handle); 2235 trace_event = thread_local_event_buffer->AddTraceEvent(&handle);
2144 } else { 2236 } else {
2145 lock.EnsureAcquired(); 2237 lock.EnsureAcquired();
2146 trace_event = AddEventToThreadSharedChunkWhileLocked(&handle, true); 2238 trace_event = AddEventToThreadSharedChunkWhileLocked(&handle, true);
2147 } 2239 }
2148 2240
2149 if (trace_event) { 2241 if (trace_event) {
2150 trace_event->Initialize(thread_id, offset_event_timestamp, thread_now, 2242 trace_event->Initialize(thread_id,
2151 phase, category_group_enabled, name, id, 2243 offset_event_timestamp,
2152 context_id, num_args, arg_names, arg_types, 2244 thread_now,
2153 arg_values, convertable_values, flags); 2245 phase,
2246 category_group_enabled,
2247 name,
2248 id,
2249 context_id,
2250 bind_id,
dsinclair 2015/07/21 18:11:49 Why did you unwrap this call?
yuhaoz 2015/07/21 18:22:34 Simply because it looks clearer, especially with m
dsinclair 2015/07/21 18:32:50 I prefer the old way, personally. It also makes it
2251 num_args,
2252 arg_names,
2253 arg_types,
2254 arg_values,
2255 convertable_values,
2256 flags);
2154 2257
2155 #if defined(OS_ANDROID) 2258 #if defined(OS_ANDROID)
2156 trace_event->SendToATrace(); 2259 trace_event->SendToATrace();
2157 #endif 2260 #endif
2158 } 2261 }
2159 2262
2160 if (trace_options() & kInternalEchoToConsole) { 2263 if (trace_options() & kInternalEchoToConsole) {
2161 console_message = EventToConsoleMessage( 2264 console_message = EventToConsoleMessage(
2162 phase == TRACE_EVENT_PHASE_COMPLETE ? TRACE_EVENT_PHASE_BEGIN : phase, 2265 phase == TRACE_EVENT_PHASE_COMPLETE ? TRACE_EVENT_PHASE_BEGIN : phase,
2163 timestamp, trace_event); 2266 timestamp, trace_event);
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
2306 } 2409 }
2307 } 2410 }
2308 2411
2309 if (console_message.size()) 2412 if (console_message.size())
2310 LOG(ERROR) << console_message; 2413 LOG(ERROR) << console_message;
2311 2414
2312 if (*category_group_enabled & ENABLED_FOR_EVENT_CALLBACK) { 2415 if (*category_group_enabled & ENABLED_FOR_EVENT_CALLBACK) {
2313 EventCallback event_callback = reinterpret_cast<EventCallback>( 2416 EventCallback event_callback = reinterpret_cast<EventCallback>(
2314 subtle::NoBarrier_Load(&event_callback_)); 2417 subtle::NoBarrier_Load(&event_callback_));
2315 if (event_callback) { 2418 if (event_callback) {
2316 event_callback(now, TRACE_EVENT_PHASE_END, category_group_enabled, name, 2419 event_callback(now,
2317 trace_event_internal::kNoId, trace_event_internal::kNoId, 2420 TRACE_EVENT_PHASE_END,
2318 NULL, NULL, NULL, TRACE_EVENT_FLAG_NONE); 2421 category_group_enabled,
2422 name,
2423 trace_event_internal::kNoId,
dsinclair 2015/07/21 18:11:49 ditto
2424 trace_event_internal::kNoId,
2425 NULL,
2426 NULL,
2427 NULL,
2428 TRACE_EVENT_FLAG_NONE);
2319 } 2429 }
2320 } 2430 }
2321 } 2431 }
2322 2432
2323 void TraceLog::SetWatchEvent(const std::string& category_name, 2433 void TraceLog::SetWatchEvent(const std::string& category_name,
2324 const std::string& event_name, 2434 const std::string& event_name,
2325 const WatchEventCallback& callback) { 2435 const WatchEventCallback& callback) {
2326 const unsigned char* category = GetCategoryGroupEnabled( 2436 const unsigned char* category = GetCategoryGroupEnabled(
2327 category_name.c_str()); 2437 category_name.c_str());
2328 AutoLock lock(lock_); 2438 AutoLock lock(lock_);
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
2531 const char* category_group, const char* name) { 2641 const char* category_group, const char* name) {
2532 // The single atom works because for now the category_group can only be "gpu". 2642 // The single atom works because for now the category_group can only be "gpu".
2533 DCHECK_EQ(strcmp(category_group, "gpu"), 0); 2643 DCHECK_EQ(strcmp(category_group, "gpu"), 0);
2534 static TRACE_EVENT_API_ATOMIC_WORD atomic = 0; 2644 static TRACE_EVENT_API_ATOMIC_WORD atomic = 0;
2535 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO_CUSTOM_VARIABLES( 2645 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO_CUSTOM_VARIABLES(
2536 category_group, atomic, category_group_enabled_); 2646 category_group, atomic, category_group_enabled_);
2537 name_ = name; 2647 name_ = name;
2538 if (*category_group_enabled_) { 2648 if (*category_group_enabled_) {
2539 event_handle_ = 2649 event_handle_ =
2540 TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_THREAD_ID_AND_TIMESTAMP( 2650 TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_THREAD_ID_AND_TIMESTAMP(
2541 TRACE_EVENT_PHASE_COMPLETE, category_group_enabled_, name, kNoId, 2651 TRACE_EVENT_PHASE_COMPLETE,
2542 kNoId, static_cast<int>(base::PlatformThread::CurrentId()), 2652 category_group_enabled_,
2543 base::TraceTicks::Now(), 0, NULL, NULL, NULL, NULL, 2653 name,
2654 trace_event_internal::kNoId,
2655 trace_event_internal::kNoId,
dsinclair 2015/07/21 18:11:49 ditto
2656 trace_event_internal::kNoId,
2657 static_cast<int>(base::PlatformThread::CurrentId()),
2658 base::TraceTicks::Now(),
2659 trace_event_internal::kZeroNumArgs,
2660 NULL,
2661 NULL,
2662 NULL,
2663 NULL,
2544 TRACE_EVENT_FLAG_NONE); 2664 TRACE_EVENT_FLAG_NONE);
2545 } 2665 }
2546 } 2666 }
2547 2667
2548 ScopedTraceBinaryEfficient::~ScopedTraceBinaryEfficient() { 2668 ScopedTraceBinaryEfficient::~ScopedTraceBinaryEfficient() {
2549 if (*category_group_enabled_) { 2669 if (*category_group_enabled_) {
2550 TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION(category_group_enabled_, 2670 TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION(category_group_enabled_,
2551 name_, event_handle_); 2671 name_, event_handle_);
2552 } 2672 }
2553 } 2673 }
2554 2674
2555 } // namespace trace_event_internal 2675 } // namespace trace_event_internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698