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

Side by Side Diff: tracing/tracing/value/ui/collected_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 2017 The Chromium Authors. All rights reserved. 3 Copyright 2017 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/ui/base/base.html"> 8 <link rel="import" href="/tracing/value/ui/diagnostic_span_behavior.html">
9 9
10 <dom-module id="tr-v-ui-collected-related-event-set-span"> 10 <dom-module id="tr-v-ui-collected-related-event-set-span">
11 <script> 11 </dom-module>
12 'use strict'; 12
13 <script>
14 'use strict';
15 tr.exportTo('tr.v.ui', function() {
13 Polymer({ 16 Polymer({
14 is: 'tr-v-ui-collected-related-event-set-span', 17 is: 'tr-v-ui-collected-related-event-set-span',
15 18 behaviors: [tr.v.ui.DIAGNOSTIC_SPAN_BEHAVIOR],
16 ready() {
17 this.diagnostic_ = undefined;
18 },
19
20 get diagnostic() {
21 return this.diagnostic_;
22 },
23
24 set diagnostic(d) {
25 this.diagnostic_ = d;
26 this.updateContents_();
27 },
28 19
29 updateContents_() { 20 updateContents_() {
30 Polymer.dom(this).textContent = ''; 21 Polymer.dom(this).textContent = '';
31 for (const [canonicalUrl, events] of this.diagnostic) { 22 for (const [canonicalUrl, events] of this.diagnostic) {
32 const link = document.createElement('a'); 23 const link = document.createElement('a');
33 if (events.length === 1) { 24 if (events.length === 1) {
34 const event = tr.b.getOnlyElement(events); 25 const event = tr.b.getOnlyElement(events);
35 link.textContent = event.title + ' ' + 26 link.textContent = event.title + ' ' +
36 tr.b.Unit.byName.timeDurationInMs.format(event.duration); 27 tr.b.Unit.byName.timeDurationInMs.format(event.duration);
37 } else { 28 } else {
38 link.textContent = events.length + ' events'; 29 link.textContent = events.length + ' events';
39 } 30 }
40 link.href = canonicalUrl; 31 link.href = canonicalUrl;
41 Polymer.dom(this).appendChild(link); 32 Polymer.dom(this).appendChild(link);
42 Polymer.dom(this).appendChild(document.createElement('br')); 33 Polymer.dom(this).appendChild(document.createElement('br'));
43 } 34 }
44 } 35 }
45 }); 36 });
46 </script> 37
47 </dom-module> 38 return {};
39 });
40 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698