summaryrefslogtreecommitdiff
path: root/chromium/third_party/catapult/tracing/tracing/ui/analysis/single_flow_event_sub_view.html
blob: ae6497b7c69d3f96e4ad7f3869ab5b601d9b1a11 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<!DOCTYPE html>
<!--
Copyright (c) 2013 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/base/iteration_helpers.html">
<link rel="import" href="/tracing/model/event_set.html">
<link rel="import" href="/tracing/ui/analysis/analysis_link.html">
<link rel="import" href="/tracing/ui/analysis/analysis_sub_view.html">
<link rel="import" href="/tracing/ui/analysis/single_event_sub_view.html">

<dom-module id="tr-ui-a-single-flow-event-sub-view">
  <template>
    <style>
    :host {
      display: block;
    }
    </style>
    <tr-ui-a-single-event-sub-view id="singleEventSubView">
    </tr-ui-a-single-event-sub-view>
  </template>
</dom-module>
<script>
'use strict';

function createAnalysisLinkTo(event) {
  var linkEl = document.createElement('tr-ui-a-analysis-link');
  linkEl.setSelectionAndContent(
      new tr.model.EventSet(event), event.userFriendlyName);
  return linkEl;
}

Polymer({
  is: 'tr-ui-a-single-flow-event-sub-view',
  behaviors: [tr.ui.analysis.AnalysisSubView],

  listeners: {
    'singleEventSubView.customize-rows': 'onCustomizeRows_'
  },

  set selection(selection) {
    this.currentSelection_ = selection;
    this.$.singleEventSubView.setSelectionWithoutErrorChecks(selection);
  },

  get selection() {
    return this.currentSelection_;
  },

  /**
   * Event handler for an event that's fired after the single event sub view has
   * finished row construction. This hook gives us the opportunity to customize
   * the rows present in the sub view.
   */
  onCustomizeRows_: function(e) {
    var event = tr.b.getOnlyElement(this.currentSelection_);
    var rows = e.rows;

    rows.unshift({
      name: 'ID',
      value: event.id
    });
    rows.push({
      name: 'From',
      value: createAnalysisLinkTo(event.startSlice)
    });
    rows.push({
      name: 'To',
      value: createAnalysisLinkTo(event.endSlice)
    });
  }
});
tr.ui.analysis.AnalysisSubView.register(
    'tr-ui-a-single-flow-event-sub-view',
    tr.model.FlowEvent,
    {
      multi: false,
      title: 'Flow Event',
    });
</script>