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

Side by Side Diff: base/debug/trace_event.h

Issue 10913242: Trace PostTasks from post to run (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | base/message_loop.cc » ('j') | base/message_loop.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 // This header is designed to give you trace_event macros without specifying 5 // This header is designed to give you trace_event macros without specifying
6 // how the events actually get collected and stored. If you need to expose trace 6 // how the events actually get collected and stored. If you need to expose trace
7 // event to some other universe, you can copy-and-paste this file, 7 // event to some other universe, you can copy-and-paste this file,
8 // implement the TRACE_EVENT_API macros, and do any other necessary fixup for 8 // implement the TRACE_EVENT_API macros, and do any other necessary fixup for
9 // the target platform. The end result is that multiple libraries can funnel 9 // the target platform. The end result is that multiple libraries can funnel
10 // events through to a shared trace event collector. 10 // events through to a shared trace event collector.
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 155
156 #include "base/atomicops.h" 156 #include "base/atomicops.h"
157 #include "base/debug/trace_event_impl.h" 157 #include "base/debug/trace_event_impl.h"
158 #include "build/build_config.h" 158 #include "build/build_config.h"
159 159
160 // By default, const char* argument values are assumed to have long-lived scope 160 // By default, const char* argument values are assumed to have long-lived scope
161 // and will not be copied. Use this macro to force a const char* to be copied. 161 // and will not be copied. Use this macro to force a const char* to be copied.
162 #define TRACE_STR_COPY(str) \ 162 #define TRACE_STR_COPY(str) \
163 trace_event_internal::TraceStringWithCopy(str) 163 trace_event_internal::TraceStringWithCopy(str)
164 164
165 // By default, uint64 ID argument values are not mangled with the Process ID in
166 // TRACE_EVENT_ASYNC macros. Use this macro to force Process ID mangling.
167 #define TRACE_ID_MANGLE(id) \
168 trace_event_internal::TraceID::ForceMangle(id)
169
165 // Records a pair of begin and end events called "name" for the current 170 // Records a pair of begin and end events called "name" for the current
166 // scope, with 0, 1 or 2 associated arguments. If the category is not 171 // scope, with 0, 1 or 2 associated arguments. If the category is not
167 // enabled, then this does nothing. 172 // enabled, then this does nothing.
168 // - category and name strings must have application lifetime (statics or 173 // - category and name strings must have application lifetime (statics or
169 // literals). They may not include " chars. 174 // literals). They may not include " chars.
170 #define TRACE_EVENT0(category, name) \ 175 #define TRACE_EVENT0(category, name) \
171 INTERNAL_TRACE_EVENT_ADD_SCOPED(category, name) 176 INTERNAL_TRACE_EVENT_ADD_SCOPED(category, name)
172 #define TRACE_EVENT1(category, name, arg1_name, arg1_val) \ 177 #define TRACE_EVENT1(category, name, arg1_name, arg1_val) \
173 INTERNAL_TRACE_EVENT_ADD_SCOPED(category, name, arg1_name, arg1_val) 178 INTERNAL_TRACE_EVENT_ADD_SCOPED(category, name, arg1_name, arg1_val)
174 #define TRACE_EVENT2(category, name, arg1_name, arg1_val, arg2_name, arg2_val) \ 179 #define TRACE_EVENT2(category, name, arg1_name, arg1_val, arg2_name, arg2_val) \
(...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after
631 const int kZeroNumArgs = 0; 636 const int kZeroNumArgs = 0;
632 const int kNoThreshholdBeginId = -1; 637 const int kNoThreshholdBeginId = -1;
633 const long long kNoThresholdValue = 0; 638 const long long kNoThresholdValue = 0;
634 const unsigned long long kNoEventId = 0; 639 const unsigned long long kNoEventId = 0;
635 640
636 // TraceID encapsulates an ID that can either be an integer or pointer. Pointers 641 // TraceID encapsulates an ID that can either be an integer or pointer. Pointers
637 // are mangled with the Process ID so that they are unlikely to collide when the 642 // are mangled with the Process ID so that they are unlikely to collide when the
638 // same pointer is used on different processes. 643 // same pointer is used on different processes.
639 class TraceID { 644 class TraceID {
640 public: 645 public:
646 class ForceMangle {
647 public:
648 explicit ForceMangle(unsigned long long id) : data_(id) {}
649 explicit ForceMangle(unsigned long id) : data_(id) {}
650 explicit ForceMangle(unsigned int id) : data_(id) {}
651 explicit ForceMangle(unsigned short id) : data_(id) {}
652 explicit ForceMangle(unsigned char id) : data_(id) {}
653 explicit ForceMangle(long long id) :
654 data_(static_cast<unsigned long long>(id)) {}
655 explicit ForceMangle(long id) :
656 data_(static_cast<unsigned long long>(id)) {}
657 explicit ForceMangle(int id) :
658 data_(static_cast<unsigned long long>(id)) {}
659 explicit ForceMangle(short id) :
660 data_(static_cast<unsigned long long>(id)) {}
661 explicit ForceMangle(signed char id) :
662 data_(static_cast<unsigned long long>(id)) {}
663
664 unsigned long long data() const { return data_; }
665
666 private:
667 unsigned long long data_;
668 };
669
641 explicit TraceID(const void* id, unsigned char* flags) : 670 explicit TraceID(const void* id, unsigned char* flags) :
642 data_(static_cast<unsigned long long>( 671 data_(static_cast<unsigned long long>(
643 reinterpret_cast<unsigned long>(id))) { 672 reinterpret_cast<unsigned long>(id))) {
644 *flags |= TRACE_EVENT_FLAG_MANGLE_ID; 673 *flags |= TRACE_EVENT_FLAG_MANGLE_ID;
645 } 674 }
675 explicit TraceID(ForceMangle id, unsigned char* flags) : data_(id.data()) {
676 *flags |= TRACE_EVENT_FLAG_MANGLE_ID;
677 }
646 explicit TraceID(unsigned long long id, unsigned char* flags) : 678 explicit TraceID(unsigned long long id, unsigned char* flags) :
647 data_(id) { (void)flags; } 679 data_(id) { (void)flags; }
648 explicit TraceID(unsigned long id, unsigned char* flags) : 680 explicit TraceID(unsigned long id, unsigned char* flags) :
649 data_(id) { (void)flags; } 681 data_(id) { (void)flags; }
650 explicit TraceID(unsigned int id, unsigned char* flags) : 682 explicit TraceID(unsigned int id, unsigned char* flags) :
651 data_(id) { (void)flags; } 683 data_(id) { (void)flags; }
652 explicit TraceID(unsigned short id, unsigned char* flags) : 684 explicit TraceID(unsigned short id, unsigned char* flags) :
653 data_(id) { (void)flags; } 685 data_(id) { (void)flags; }
654 explicit TraceID(unsigned char id, unsigned char* flags) : 686 explicit TraceID(unsigned char id, unsigned char* flags) :
655 data_(id) { (void)flags; } 687 data_(id) { (void)flags; }
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
864 const char* name; 896 const char* name;
865 int threshold_begin_id; 897 int threshold_begin_id;
866 }; 898 };
867 Data* p_data_; 899 Data* p_data_;
868 Data data_; 900 Data data_;
869 }; 901 };
870 902
871 } // namespace trace_event_internal 903 } // namespace trace_event_internal
872 904
873 #endif // BASE_DEBUG_TRACE_EVENT_H_ 905 #endif // BASE_DEBUG_TRACE_EVENT_H_
OLDNEW
« no previous file with comments | « no previous file | base/message_loop.cc » ('j') | base/message_loop.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698