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

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

Issue 1837013003: [tracing] Add support for profiling trace events (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@ipc_trace
Patch Set: nits. Created 4 years, 8 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/blame_context.h" 5 #include "base/trace_event/blame_context.h"
6 6
7 #include "base/strings/stringprintf.h" 7 #include "base/strings/stringprintf.h"
8 #include "base/trace_event/trace_event.h" 8 #include "base/trace_event/trace_event.h"
9 #include "base/trace_event/trace_event_argument.h" 9 #include "base/trace_event/trace_event_argument.h"
10 10
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 void BlameContext::Leave() { 48 void BlameContext::Leave() {
49 DCHECK(WasInitialized()); 49 DCHECK(WasInitialized());
50 TRACE_EVENT_API_ADD_TRACE_EVENT(TRACE_EVENT_PHASE_LEAVE_CONTEXT, 50 TRACE_EVENT_API_ADD_TRACE_EVENT(TRACE_EVENT_PHASE_LEAVE_CONTEXT,
51 category_group_enabled_, name_, scope_, id_, 51 category_group_enabled_, name_, scope_, id_,
52 0 /* num_args */, nullptr, nullptr, nullptr, 52 0 /* num_args */, nullptr, nullptr, nullptr,
53 nullptr, TRACE_EVENT_FLAG_HAS_ID); 53 nullptr, TRACE_EVENT_FLAG_HAS_ID);
54 } 54 }
55 55
56 void BlameContext::TakeSnapshot() { 56 void BlameContext::TakeSnapshot() {
57 DCHECK(WasInitialized()); 57 DCHECK(WasInitialized());
58 if (!*category_group_enabled_) 58 if (!(*category_group_enabled_ & TraceLog::ENABLED_FOR_NON_PROFILING_MODE))
59 return; 59 return;
60 scoped_ptr<trace_event::TracedValue> snapshot(new trace_event::TracedValue); 60 scoped_ptr<trace_event::TracedValue> snapshot(new trace_event::TracedValue);
61 AsValueInto(snapshot.get()); 61 AsValueInto(snapshot.get());
62 static const char* kArgName = "snapshot"; 62 static const char* kArgName = "snapshot";
63 const int kNumArgs = 1; 63 const int kNumArgs = 1;
64 unsigned char arg_types[1] = {TRACE_VALUE_TYPE_CONVERTABLE}; 64 unsigned char arg_types[1] = {TRACE_VALUE_TYPE_CONVERTABLE};
65 scoped_ptr<trace_event::ConvertableToTraceFormat> arg_values[1] = { 65 scoped_ptr<trace_event::ConvertableToTraceFormat> arg_values[1] = {
66 std::move(snapshot)}; 66 std::move(snapshot)};
67 TRACE_EVENT_API_ADD_TRACE_EVENT(TRACE_EVENT_PHASE_SNAPSHOT_OBJECT, 67 TRACE_EVENT_API_ADD_TRACE_EVENT(TRACE_EVENT_PHASE_SNAPSHOT_OBJECT,
68 category_group_enabled_, type_, scope_, id_, 68 category_group_enabled_, type_, scope_, id_,
(...skipping 27 matching lines...) Expand all
96 trace_event::TraceLog::GetInstance()->AddEnabledStateObserver(this); 96 trace_event::TraceLog::GetInstance()->AddEnabledStateObserver(this);
97 TakeSnapshot(); 97 TakeSnapshot();
98 } 98 }
99 99
100 bool BlameContext::WasInitialized() const { 100 bool BlameContext::WasInitialized() const {
101 return category_group_enabled_ != nullptr; 101 return category_group_enabled_ != nullptr;
102 } 102 }
103 103
104 } // namespace trace_event 104 } // namespace trace_event
105 } // namespace base 105 } // namespace base
OLDNEW
« no previous file with comments | « no previous file | base/trace_event/heap_profiler_allocation_context_tracker_unittest.cc » ('j') | base/trace_event/trace_log.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698