• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1<!DOCTYPE html>
2<!--
3Copyright (c) 2014 The Chromium Authors. All rights reserved.
4Use of this source code is governed by a BSD-style license that can be
5found in the LICENSE file.
6-->
7<head>
8<script>
9function 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 i = new tr.importer.Import(model);
75    var p = i.importTracesWithProgressDialog([result]);
76    p.then(onModelLoaded, onImportFail);
77  }
78
79  function onModelLoaded() {
80    viewer.model = model;
81    viewer.viewTitle = url;
82  }
83
84  function onImportFail() {
85    var overlay = new tr.ui.b.Overlay();
86    overlay.textContent = tr.b.normalizeException(err).message;
87    overlay.title = 'Import error';
88    overlay.visible = true;
89  }
90
91  document.addEventListener('DOMContentLoaded', function() {
92    var container = document.createElement('track-view-container');
93    container.id = 'track_view_container';
94
95    viewer = document.createElement('tr-ui-timeline-view');
96    viewer.track_view_container = container;
97    viewer.appendChild(container);
98
99    viewer.id = 'trace-viewer';
100    viewer.globalMode = true;
101    document.body.appendChild(viewer);
102
103    url = '../test_data/big_trace.json';
104    load();
105  });
106}());
107</script>
108</head>
109<body>
110</body>
111</html>
112