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

Unified Diff: tracing/tracing/model/thread.html

Issue 2800933002: Add getter for thread type (Closed)
Patch Set: Address comments by benjhayden@ Created 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tracing/tracing/model/thread_test.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tracing/tracing/model/thread.html
diff --git a/tracing/tracing/model/thread.html b/tracing/tracing/model/thread.html
index 736345d5f43b0adcb47f690c3a9a89cdacea8a57..4dfef30e4987470e076460b2aa080c619162413e 100644
--- a/tracing/tracing/model/thread.html
+++ b/tracing/tracing/model/thread.html
@@ -300,6 +300,26 @@ tr.exportTo('tr.model', function() {
get samples() {
return this.samples_;
},
+
+ /**
+ * Returns substring of this.name from beginning to the first numeric
+ * character or the character '/'.
+ *
+ * Example:
+ * ThreadName12 -> ThreadName
+ * ThreadName/34123 -> ThreadName
+ * ThreadName1/34123 -> ThreadName
+ */
+ get type() {
+ const re = /^[^0-9|\/]+/;
+ const matches = re.exec(this.name);
+ if (matches && matches[0]) return matches[0];
+
+ // If a thread is named 42GPU, let's not try to find its type.
+ // We should fix the thread name.
+ throw new Error('Could not determine thread type for thread name ' +
+ this.name);
+ }
};
/**
« no previous file with comments | « no previous file | tracing/tracing/model/thread_test.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698