blob: 3895af57ea1723c65672b8a9d1e2c6b57d0c69ff [file] [log] [blame]
<!DOCTYPE html>
<!--
Copyright (c) 2015 The Chromium Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file.
-->
<link rel="import" href="/tracing/model/event_set.html">
<script>
'use strict';
tr.exportTo('tr.ui.analysis', function() {
var FLOW_IN = 0x1;
var FLOW_OUT = 0x2;
var FLOW_IN_OUT = FLOW_IN | FLOW_OUT;
function FlowClassifier() {
this.numEvents_ = 0;
this.eventsByGUID_ = {};
}
FlowClassifier.prototype = {
getFS_: function(event) {
var fs = this.eventsByGUID_[event.guid];
if (fs === undefined) {
this.numEvents_++;
fs = {
state: 0,
event: event
};
this.eventsByGUID_[event.guid] = fs;
}
return fs;
},
addInFlow: function(event) {
var fs = this.getFS_(event);
fs.state |= FLOW_IN;
return event;
},
addOutFlow: function(event) {
var fs = this.getFS_(event);
fs.state |= FLOW_OUT;
return event;
},
hasEvents: function() {
return this.numEvents_ > 0;
},
get inFlowEvents() {
var selection = new tr.model.EventSet();
for (var guid in this.eventsByGUID_) {
var fs = this.eventsByGUID_[guid];
if (fs.state === FLOW_IN)
selection.push(fs.event);
}
return selection;
},
get outFlowEvents() {
var selection = new tr.model.EventSet();
for (var guid in this.eventsByGUID_) {
var fs = this.eventsByGUID_[guid];
if (fs.state === FLOW_OUT)
selection.push(fs.event);
}
return selection;
},
get internalFlowEvents() {
var selection = new tr.model.EventSet();
for (var guid in this.eventsByGUID_) {
var fs = this.eventsByGUID_[guid];
if (fs.state === FLOW_IN_OUT)
selection.push(fs.event);
}
return selection;
}
};
return {
FlowClassifier: FlowClassifier
};
});
</script>