1 <!DOCTYPE html> 2 <!-- 3 Copyright (c) 2014 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 <head> 8 <script> 9 'use strict'; 10 11 function onTraceViewerImportFail() { 12 document.addEventListener('DOMContentLoaded', function() { 13 document.body.textContent = 14 'tracing/bin/trace_viewer_full.html is missing. ' + 15 'Run vulcanize_trace_viewer from $TRACE_VIEWER and reload.'; 16 }); 17 } 18 </script> 19 <link rel="import" href="trace_viewer_full.html" 20 onerror="onTraceViewerImportFail(event)"> 21 22 <style> 23 html, body { 24 box-sizing: border-box; 25 overflow: hidden; 26 margin: 0px; 27 padding: 0; 28 width: 100%; 29 height: 100%; 30 } 31 #trace-viewer { 32 width: 100%; 33 height: 100%; 34 } 35 #trace-viewer:focus { 36 outline: none; 37 } 38 </style> 39 <script> 40 'use strict'; 41 42 (function() { 43 var viewer; 44 var url; 45 var model; 46 47 function load() { 48 var req = new XMLHttpRequest(); 49 var is_binary = /[.]gz$/.test(url) || /[.]zip$/.test(url); 50 req.overrideMimeType('text/plain; charset=x-user-defined'); 51 req.open('GET', url, true); 52 if (is_binary) 53 req.responseType = 'arraybuffer'; 54 55 req.onreadystatechange = function(event) { 56 if (req.readyState !== 4) 57 return; 58 59 window.setTimeout(function() { 60 if (req.status === 200) 61 onResult(is_binary ? req.response : req.responseText); 62 else 63 onResultFail(req.status); 64 }, 0); 65 }; 66 req.send(null); 67 } 68 69 function onResultFail(err) { 70 var overlay = new tr.ui.b.Overlay(); 71 overlay.textContent = err + ': ' + url + ' could not be loaded'; 72 overlay.title = 'Failed to fetch data'; 73 overlay.visible = true; 74 } 75 76 function onResult(result) { 77 model = new tr.Model(); 78 var i = new tr.importer.Import(model); 79 var p = i.importTracesWithProgressDialog([result]); 80 p.then(onModelLoaded, onImportFail); 81 } 82 83 function onModelLoaded() { 84 viewer.model = model; 85 viewer.viewTitle = url; 86 } 87 88 function onImportFail() { 89 var overlay = new tr.ui.b.Overlay(); 90 overlay.textContent = tr.b.normalizeException(err).message; 91 overlay.title = 'Import error'; 92 overlay.visible = true; 93 } 94 95 document.addEventListener('DOMContentLoaded', function() { 96 var container = document.createElement('track-view-container'); 97 container.id = 'track_view_container'; 98 99 viewer = document.createElement('tr-ui-timeline-view'); 100 viewer.track_view_container = container; 101 Polymer.dom(viewer).appendChild(container); 102 103 viewer.id = 'trace-viewer'; 104 viewer.globalMode = true; 105 Polymer.dom(document.body).appendChild(viewer); 106 107 url = '../test_data/big_trace.json'; 108 load(); 109 }); 110 }()); 111 </script> 112 </head> 113 <body> 114 </body> 115 </html> 116