Fix a type mismatch on Windows caused by r201738.
[chromium-blink-merge.git] / tools / cc-frame-viewer / app / viewer.js
blobe6e1e87badaf2bf9b4c8754c877f2981a71a7636
1 /* Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 * Use of this source code is governed by a BSD-style license that can be
3 * found in the LICENSE file.
4 */
5 'use strict';
7 base.exportTo('ccfv', function() {
8 function assert(bool) {
9 if (bool)
10 return;
11 throw new Error("Expected true");
14 chromeapp.addEventListener('launch', init);
15 chrome.app.window.current().onClosed.addListener(onClosed);
16 chrome.app.window.current().focus();
18 var viewerEl;
19 function init(launch_event) {
20 viewerEl = document.querySelector('#viewer')
21 window.g_viewerEl = viewerEl;
23 var num_args = launch_event.args[0]
24 chromeapp.sendEvent('load', 'please', onLoadResult, onLoadError);
27 function onLoadResult(res) {
28 var trace = JSON.parse(res);
30 window.g_lastResult = trace;
31 var model = new ccfv.Model();
32 try {
33 model.initFromTraceEvents(trace);
34 } catch(e) {
35 onLoadError(e);
36 return;
38 window.g_model = model;
40 var modelViewEl = new ccfv.ModelView();
41 modelViewEl.model = model;
42 window.g_modelViewEl = modelViewEl;
44 viewerEl.appendChild(modelViewEl);
47 function onLoadError(err) {
48 viewerEl.textContent = 'error loading: ' + err;
51 function onClosed() {
52 chromeapp.exit(1);
55 });