summaryrefslogtreecommitdiff
path: root/chromium/third_party/catapult/tracing/tracing/ui/analysis/single_user_expectation_sub_view.html
blob: 0c2ba50450a62a66f0609ca92c5fc7dd88398d23 (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
<!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/base/iteration_helpers.html">
<link rel="import" href="/tracing/ui/analysis/analysis_sub_view.html">
<link rel="import" href="/tracing/ui/analysis/single_event_sub_view.html">
<link rel="import"
  href="/tracing/ui/analysis/user_expectation_related_samples_table.html">
<link rel="import" href="/tracing/value/ui/scalar_span.html">
<link rel="import" href="/tracing/value/unit.html">
<link rel="import" href="/tracing/value/value_set.html">

<polymer-element name="tr-ui-a-single-user-expectation-sub-view"
    extends="tr-ui-a-sub-view">
  <template>
    <style>
    :host {
      display: flex;
      flex-direction: row;
    }
    #events {
      display: flex;
      flex-direction: column;
    }
    </style>
    <tr-ui-a-single-event-sub-view id="realView"></tr-ui-a-single-event-sub-view>
    <div id="events">
      <tr-ui-a-user-expectation-related-samples-table id="relatedSamples"></tr-ui-a-user-expectation-related-samples-table>
    </div>
  </template>
  <script>
  'use strict';

  Polymer({
    created: function() {
      this.currentSelection_ = undefined;
    },

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

    set selection(selection) {
      this.$.realView.addEventListener('customize-rows',
          this.onCustomizeRows_.bind(this));

      this.currentSelection_ = selection;
      this.$.realView.setSelectionWithoutErrorChecks(selection);

      this.$.relatedSamples.selection = selection;
      if (this.$.relatedSamples.hasRelatedSamples())
        this.$.events.style.display = '';
      else
        this.$.events.style.display = 'none';
    },

    get relatedEventsToHighlight() {
      if (!this.currentSelection_)
        return undefined;
      return tr.b.getOnlyElement(this.currentSelection_).associatedEvents;
    },

    onCustomizeRows_: function(event) {
      var ue = tr.b.getOnlyElement(this.selection);

      if (ue.rawCpuMs) {
        event.rows.push({
          name: 'Total CPU',
          value: tr.v.ui.createScalarSpan(ue.totalCpuMs, {
            unit: tr.v.Unit.byName.timeDurationInMs
          })
        });
      }
    }
  });
  </script>
</polymer-element>