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

Unified Diff: tracing/tracing/extras/tquery/tquery.html

Issue 1398213005: tquery: Remove hard dependency on UI (Closed) Base URL: https://github.com/catapult-project/catapult@master
Patch Set: More review tweaks. Created 5 years, 2 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 | « tracing/tracing/core/scripting_object.html ('k') | tracing/tracing/extras/tquery/tquery_test.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tracing/tracing/extras/tquery/tquery.html
diff --git a/tracing/tracing/extras/tquery/tquery.html b/tracing/tracing/extras/tquery/tquery.html
index 54d94020bdde558312c4482b26719e9d20203d82..cbef1321aa617026ce25832a16f6455a682cf8c6 100644
--- a/tracing/tracing/extras/tquery/tquery.html
+++ b/tracing/tracing/extras/tquery/tquery.html
@@ -21,10 +21,18 @@ found in the LICENSE file.
'use strict';
tr.exportTo('tr.e.tquery', function() {
- function TQuery(brushingStateController) {
+ function addEventTreeToSelection(selection, event) {
+ selection.push(event);
+ if (!event.subSlices)
+ return;
+ event.subSlices.forEach(
+ addEventTreeToSelection.bind(undefined, selection));
+ }
+
+ function TQuery(model) {
tr.c.ScriptingObject.call(this);
- this.brushingStateController_ = brushingStateController;
+ this.model_ = model;
this.parent_ = undefined;
this.filterExpression_ = undefined;
// Memoized filtering result.
@@ -34,7 +42,8 @@ tr.exportTo('tr.e.tquery', function() {
TQuery.prototype = {
__proto__: tr.c.ScriptingObject.prototype,
- onModelChanged: function() {
+ onModelChanged: function(model) {
+ this.model_ = model;
this.selection_ = undefined;
},
@@ -45,7 +54,7 @@ tr.exportTo('tr.e.tquery', function() {
// Append a new filter expression to this query and return a query node
// that represents the result.
filter: function(filterExpression) {
- var result = new TQuery(this.brushingStateController_);
+ var result = new TQuery(this.model_);
result.parent_ = this;
result.filterExpression_ =
tr.e.tquery.Filter.normalizeFilterExpression(filterExpression);
@@ -81,7 +90,7 @@ tr.exportTo('tr.e.tquery', function() {
node.selection_ = new tr.model.EventSet();
if (node.parent_ === undefined) {
// If this is the root, start by collecting all objects from the
- // brushing state controller.
+ // model.
lastTask = lastTask.after(
this.selectEverythingAsTask_(node.selection_));
} else {
@@ -133,26 +142,30 @@ tr.exportTo('tr.e.tquery', function() {
}
},
- // Show the result as a highlight on the brushing state controller. Returns
- // a {Task} which runs the query and sets the highlight.
- show: function() {
- var graph = this.createFilterTaskGraph_();
-
- graph.lastTask = graph.lastTask.after(function() {
- this.brushingStateController.showScriptControlSelection(
- graph.lastNode.selection_);
+ // Returns a task that fills the given selection with everything in the
+ // model.
+ selectEverythingAsTask_: function(selection) {
+ var filterTask = new tr.b.Task();
+ this.model_.iterateAllEventContainers(function(container) {
+ filterTask.subTask(function() {
+ container.iterateAllEventsInThisContainer(
+ function() { return true; },
+ addEventTreeToSelection.bind(undefined, selection));
+ }, this);
}, this);
- return graph.rootTask;
+ return filterTask;
},
- // Returns a task that fills the given selection with everything reachable
- // by the brushing state controller.
- selectEverythingAsTask_: function(selection) {
- var passThroughFilter = new tr.c.Filter();
- var filterTask = this.brushingStateController.
- addAllEventsMatchingFilterToSelectionAsTask(passThroughFilter,
- selection);
- return filterTask;
+ // Returns a promise which will resolve into a {EventSet} representing the
+ // result of this query.
+ ready: function() {
+ return new Promise(function(resolve, reject) {
+ var graph = this.createFilterTaskGraph_();
+ graph.lastTask = graph.lastTask.after(function() {
+ resolve(this.selection_);
+ }, this);
+ tr.b.Task.RunWhenIdle(graph.rootTask);
+ }.bind(this));
},
get selection() {
« no previous file with comments | « tracing/tracing/core/scripting_object.html ('k') | tracing/tracing/extras/tquery/tquery_test.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698