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

Side by Side Diff: third_party/WebKit/Source/platform/TraceEvent.h

Issue 1499683002: tracing: Add macros for generating context trace events (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years 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 /* 1 /*
2 * Copyright (C) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 do { \ 227 do { \
228 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category); \ 228 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category); \
229 if (INTERNAL_TRACE_EVENT_CATEGORY_GROUP_ENABLED_FOR_RECORDING_MODE()) { \ 229 if (INTERNAL_TRACE_EVENT_CATEGORY_GROUP_ENABLED_FOR_RECORDING_MODE()) { \
230 blink::TraceEvent::addTraceEvent( \ 230 blink::TraceEvent::addTraceEvent( \
231 phase, INTERNALTRACEEVENTUID(categoryGroupEnabled), name, \ 231 phase, INTERNALTRACEEVENTUID(categoryGroupEnabled), name, \
232 blink::TraceEvent::noEventId, blink::TraceEvent::noBindId, \ 232 blink::TraceEvent::noEventId, blink::TraceEvent::noBindId, \
233 timestamp, flags, ##__VA_ARGS__); \ 233 timestamp, flags, ##__VA_ARGS__); \
234 } \ 234 } \
235 } while (0) 235 } while (0)
236 236
237 // Implementation detail: internal macro to enter and leave a context based on
238 // the current scope.
239 #define INTERNAL_TRACE_EVENT_SCOPED_CONTEXT(categoryGroup, name, context) \
240 blink::TraceEvent::TraceScopedContext INTERNAL_TRACE_EVENT_UID(scopedTracer) (categoryGroup, name, context)
237 241
238 // These values must be in sync with base::debug::TraceLog::CategoryGroupEnabled Flags. 242 // These values must be in sync with base::debug::TraceLog::CategoryGroupEnabled Flags.
239 #define ENABLED_FOR_RECORDING (1 << 0) 243 #define ENABLED_FOR_RECORDING (1 << 0)
240 #define ENABLED_FOR_EVENT_CALLBACK (1 << 2) 244 #define ENABLED_FOR_EVENT_CALLBACK (1 << 2)
241 245
242 #define INTERNAL_TRACE_EVENT_CATEGORY_GROUP_ENABLED_FOR_RECORDING_MODE() \ 246 #define INTERNAL_TRACE_EVENT_CATEGORY_GROUP_ENABLED_FOR_RECORDING_MODE() \
243 (*INTERNALTRACEEVENTUID(categoryGroupEnabled) & (ENABLED_FOR_RECORDING | ENA BLED_FOR_EVENT_CALLBACK)) 247 (*INTERNALTRACEEVENTUID(categoryGroupEnabled) & (ENABLED_FOR_RECORDING | ENA BLED_FOR_EVENT_CALLBACK))
244 248
245 #define INTERNAL_TRACE_MEMORY(category, name) 249 #define INTERNAL_TRACE_MEMORY(category, name)
246 250
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after
606 { 610 {
607 TRACE_EVENT_OBJECT_DELETED_WITH_ID(m_categoryGroup, m_name, m_id); 611 TRACE_EVENT_OBJECT_DELETED_WITH_ID(m_categoryGroup, m_name, m_id);
608 } 612 }
609 613
610 private: 614 private:
611 const char* m_categoryGroup; 615 const char* m_categoryGroup;
612 const char* m_name; 616 const char* m_name;
613 IDType m_id; 617 IDType m_id;
614 }; 618 };
615 619
620 using TraceContext = const void*;
621
622 class TraceScopedContext {
623 WTF_MAKE_NONCOPYABLE(TraceScopedContext);
624
625 public:
626 TraceScopedContext(const char* categoryGroup, const char* name, TraceContext context)
627 : m_categoryGroup(categoryGroup)
628 , m_name(name)
629 , m_context(context)
630 {
631 TRACE_EVENT_ENTER_CONTEXT(m_categoryGroup, m_name, m_context);
632 }
633
634 ~TraceScopedContext()
635 {
636 TRACE_EVENT_LEAVE_CONTEXT(m_categoryGroup, m_name, m_context);
637 }
638
639 private:
640 const char* m_categoryGroup;
641 const char* m_name;
642 TraceContext m_context;
643 };
644
616 } // namespace TraceEvent 645 } // namespace TraceEvent
617 646
618 } // namespace blink 647 } // namespace blink
619 648
620 #endif 649 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698