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

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

Issue 1645853003: base: Add scope support to context trace events (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Review comments. Created 4 years, 10 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
« no previous file with comments | « base/trace_event/common/trace_event_common.h ('k') | base/trace_event/trace_event_unittest.cc » ('j') | no next file with comments »
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 #ifndef BASE_TRACE_EVENT_TRACE_EVENT_H_ 5 #ifndef BASE_TRACE_EVENT_TRACE_EVENT_H_
6 #define BASE_TRACE_EVENT_TRACE_EVENT_H_ 6 #define BASE_TRACE_EVENT_TRACE_EVENT_H_
7 7
8 // This header file defines implementation details of how the trace macros in 8 // This header file defines implementation details of how the trace macros in
9 // trace_event_common.h collect and store trace events. Anything not 9 // trace_event_common.h collect and store trace events. Anything not
10 // implementation-specific should go in trace_macros_common.h instead of here. 10 // implementation-specific should go in trace_macros_common.h instead of here.
(...skipping 922 matching lines...) Expand 10 before | Expand all | Expand 10 after
933 TRACE_EVENT_API_ATOMIC_STORE( 933 TRACE_EVENT_API_ATOMIC_STORE(
934 g_trace_state[BucketNumber], 934 g_trace_state[BucketNumber],
935 reinterpret_cast<TRACE_EVENT_API_ATOMIC_WORD>( 935 reinterpret_cast<TRACE_EVENT_API_ATOMIC_WORD>(
936 const_cast<char*>(category_and_name))); 936 const_cast<char*>(category_and_name)));
937 } 937 }
938 938
939 private: 939 private:
940 const char* previous_state_; 940 const char* previous_state_;
941 }; 941 };
942 942
943 using TraceContext = const void*; 943 using TraceContext = trace_event_internal::TraceID;
944 944
945 class TraceScopedContext { 945 class TraceScopedContext {
946 public: 946 public:
947 TraceScopedContext(const char* category_group, 947 TraceScopedContext(const char* category_group,
948 const char* name, 948 const char* name,
949 TraceContext context) 949 trace_event_internal::TraceID::DontMangle context)
950 : category_group_(category_group), name_(name), context_(context) { 950 : category_group_(category_group), name_(name), context_(context) {
951 TRACE_EVENT_ENTER_CONTEXT(category_group_, name_, context_); 951 TRACE_EVENT_ENTER_CONTEXT(category_group_, name_, context_);
952 } 952 }
953 953
954 ~TraceScopedContext() { 954 ~TraceScopedContext() {
955 TRACE_EVENT_LEAVE_CONTEXT(category_group_, name_, context_); 955 TRACE_EVENT_LEAVE_CONTEXT(category_group_, name_, context_);
956 } 956 }
957 957
958 private: 958 private:
959 const char* category_group_; 959 const char* category_group_;
960 const char* name_; 960 const char* name_;
961 TraceContext context_; 961 trace_event_internal::TraceID::DontMangle context_;
962 DISALLOW_COPY_AND_ASSIGN(TraceScopedContext); 962 DISALLOW_COPY_AND_ASSIGN(TraceScopedContext);
963 }; 963 };
964 964
965 } // namespace trace_event_internal 965 } // namespace trace_event_internal
966 966
967 namespace base { 967 namespace base {
968 namespace trace_event { 968 namespace trace_event {
969 969
970 using trace_event_internal::TraceContext;
971
972 template<typename IDType> class TraceScopedTrackableObject { 970 template<typename IDType> class TraceScopedTrackableObject {
973 public: 971 public:
974 TraceScopedTrackableObject(const char* category_group, const char* name, 972 TraceScopedTrackableObject(const char* category_group, const char* name,
975 IDType id) 973 IDType id)
976 : category_group_(category_group), 974 : category_group_(category_group),
977 name_(name), 975 name_(name),
978 id_(id) { 976 id_(id) {
979 TRACE_EVENT_OBJECT_CREATED_WITH_ID(category_group_, name_, id_); 977 TRACE_EVENT_OBJECT_CREATED_WITH_ID(category_group_, name_, id_);
980 } 978 }
981 979
(...skipping 10 matching lines...) Expand all
992 const char* name_; 990 const char* name_;
993 IDType id_; 991 IDType id_;
994 992
995 DISALLOW_COPY_AND_ASSIGN(TraceScopedTrackableObject); 993 DISALLOW_COPY_AND_ASSIGN(TraceScopedTrackableObject);
996 }; 994 };
997 995
998 } // namespace trace_event 996 } // namespace trace_event
999 } // namespace base 997 } // namespace base
1000 998
1001 #endif // BASE_TRACE_EVENT_TRACE_EVENT_H_ 999 #endif // BASE_TRACE_EVENT_TRACE_EVENT_H_
OLDNEW
« no previous file with comments | « base/trace_event/common/trace_event_common.h ('k') | base/trace_event/trace_event_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698