Home | History | Annotate | Download | only in ui
      1 <!DOCTYPE html>
      2 <!--
      3 Copyright 2016 The Chromium Authors. All rights reserved.
      4 Use of this source code is governed by a BSD-style license that can be
      5 found in the LICENSE file.
      6 -->
      7 
      8 <link rel="import" href="/tracing/base/unit.html">
      9 <link rel="import" href="/tracing/ui/analysis/analysis_link.html">
     10 
     11 <dom-module id="tr-v-ui-related-event-set-span">
     12   <script>
     13   'use strict';
     14   Polymer({
     15     is: 'tr-v-ui-related-event-set-span',
     16 
     17     ready: function() {
     18       this.diagnostic_ = undefined;
     19     },
     20 
     21     get diagnostic() {
     22       return this.diagnostic_;
     23     },
     24 
     25     set diagnostic(d) {
     26       this.diagnostic_ = d;
     27       this.updateContents_();
     28     },
     29 
     30     updateContents_: function() {
     31       Polymer.dom(this).textContent = '';
     32       var events = new tr.model.EventSet([...this.diagnostic]);
     33       var link = document.createElement('tr-ui-a-analysis-link');
     34       var label = events.length + ' events';
     35       if (events.length === 1) {
     36         var event = tr.b.getOnlyElement(events);
     37         label = event.title + ' ';
     38         label += tr.b.Unit.byName.timeDurationInMs.format(
     39             event.duration);
     40       }
     41       link.setSelectionAndContent(events, label);
     42       Polymer.dom(this).appendChild(link);
     43     }
     44   });
     45   </script>
     46 </dom-module>
     47