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