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

Side by Side Diff: tracing/tracing/value/ui/related_event_set_span.html

Issue 3002973002: Refactor diagnostic spans to share a polymer behavior. (Closed)
Patch Set: Created 3 years, 4 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 unified diff | Download patch
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <!-- 2 <!--
3 Copyright 2016 The Chromium Authors. All rights reserved. 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 4 Use of this source code is governed by a BSD-style license that can be
5 found in the LICENSE file. 5 found in the LICENSE file.
6 --> 6 -->
7 7
8 <link rel="import" href="/tracing/base/unit.html"> 8 <link rel="import" href="/tracing/base/unit.html">
9 <link rel="import" href="/tracing/ui/analysis/analysis_link.html"> 9 <link rel="import" href="/tracing/ui/analysis/analysis_link.html">
10 <link rel="import" href="/tracing/value/ui/diagnostic_span_behavior.html">
10 11
11 <dom-module id="tr-v-ui-related-event-set-span"> 12 <dom-module id="tr-v-ui-related-event-set-span">
12 <script> 13 </dom-module>
13 'use strict'; 14
15 <script>
16 'use strict';
17 tr.exportTo('tr.v.ui', function() {
14 Polymer({ 18 Polymer({
15 is: 'tr-v-ui-related-event-set-span', 19 is: 'tr-v-ui-related-event-set-span',
16 20 behaviors: [tr.v.ui.DIAGNOSTIC_SPAN_BEHAVIOR],
17 ready() {
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 21
30 updateContents_() { 22 updateContents_() {
31 Polymer.dom(this).textContent = ''; 23 Polymer.dom(this).textContent = '';
32 const events = new tr.model.EventSet([...this.diagnostic]); 24 const events = new tr.model.EventSet([...this.diagnostic]);
33 const link = document.createElement('tr-ui-a-analysis-link'); 25 const link = document.createElement('tr-ui-a-analysis-link');
34 let label = events.length + ' events'; 26 let label = events.length + ' events';
35 if (events.length === 1) { 27 if (events.length === 1) {
36 const event = tr.b.getOnlyElement(events); 28 const event = tr.b.getOnlyElement(events);
37 label = event.title + ' '; 29 label = event.title + ' ';
38 label += tr.b.Unit.byName.timeDurationInMs.format( 30 label += tr.b.Unit.byName.timeDurationInMs.format(
39 event.duration); 31 event.duration);
40 } 32 }
41 link.setSelectionAndContent(events, label); 33 link.setSelectionAndContent(events, label);
42 Polymer.dom(this).appendChild(link); 34 Polymer.dom(this).appendChild(link);
43 } 35 }
44 }); 36 });
45 </script> 37
46 </dom-module> 38 return {};
39 });
40 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698