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

Unified Diff: tools/gn/trace.cc

Issue 56433003: GN threading refactor (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/gn/trace.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/gn/trace.cc
diff --git a/tools/gn/trace.cc b/tools/gn/trace.cc
index 429cc71f0f430f91e7ff130253ec86743cedb971..aa73eba93b526fa74e0eabbd8c90e1b15c44cb96 100644
--- a/tools/gn/trace.cc
+++ b/tools/gn/trace.cc
@@ -134,6 +134,16 @@ ScopedTrace::ScopedTrace(TraceItem::Type t, const std::string& name)
}
}
+ScopedTrace::ScopedTrace(TraceItem::Type t, const Label& label)
+ : item_(NULL),
+ done_(false) {
+ if (trace_log) {
+ item_ = new TraceItem(t, label.GetUserVisibleName(false),
+ base::PlatformThread::CurrentId());
+ item_->set_begin(base::TimeTicks::HighResNow());
+ }
+}
+
ScopedTrace::~ScopedTrace() {
Done();
}
@@ -190,6 +200,7 @@ std::string SummarizeTraces() {
break;
case TraceItem::TRACE_FILE_LOAD:
case TraceItem::TRACE_FILE_WRITE:
+ case TraceItem::TRACE_DEFINE_TARGET:
break; // Ignore these for the summary.
}
}
@@ -212,6 +223,12 @@ void SaveTraces(const base::FilePath& file_name) {
std::string quote_buffer; // Allocate outside loop to prevent reallocationg.
+ // Write main thread metadata (assume this is being written on the main
+ // thread).
+ out << "{\"pid\":0,\"tid\":" << base::PlatformThread::CurrentId();
+ out << ",\"ts\":0,\"ph\":\"M\",";
+ out << "\"name\":\"thread_name\",\"args\":{\"name\":\"Main thread\"}},";
+
std::vector<TraceItem*> events = trace_log->events();
for (size_t i = 0; i < events.size(); i++) {
const TraceItem& item = *events[i];
@@ -244,6 +261,8 @@ void SaveTraces(const base::FilePath& file_name) {
case TraceItem::TRACE_SCRIPT_EXECUTE:
out << "\"script_exec\"";
break;
+ case TraceItem::TRACE_DEFINE_TARGET:
+ out << "\"define\"";
}
if (!item.toolchain().empty() || !item.cmdline().empty()) {
« no previous file with comments | « tools/gn/trace.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698