Home | History | Annotate | Download | only in analysis
      1 // Copyright (c) 2013 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';
      6 
      7 base.require('ui');
      8 
      9 base.exportTo('tracing.analysis', function() {
     10   var ObjectSnapshotView = ui.define('object-snapshot-view');
     11 
     12   ObjectSnapshotView.prototype = {
     13     __proto__: HTMLDivElement.prototype,
     14 
     15     decorate: function() {
     16       this.objectSnapshot_ = undefined;
     17     },
     18 
     19     set modelObject(obj) {
     20       this.objectSnapshot = obj;
     21     },
     22 
     23     get modelObject() {
     24       return this.objectSnapshot;
     25     },
     26 
     27     get objectSnapshot() {
     28       return this.objectSnapshot_;
     29     },
     30 
     31     set objectSnapshot(i) {
     32       this.objectSnapshot_ = i;
     33       this.updateContents();
     34     },
     35 
     36     updateContents: function() {
     37       throw new Error('Not implemented');
     38     }
     39   };
     40 
     41   ObjectSnapshotView.typeNameToViewInfoMap = {};
     42   ObjectSnapshotView.register = function(typeName,
     43                                          viewConstructor,
     44                                          opt_options) {
     45     if (ObjectSnapshotView.typeNameToViewInfoMap[typeName])
     46       throw new Error('Handler already registered for ' + typeName);
     47     var options = opt_options || {
     48       showInTrackView: true
     49     };
     50     ObjectSnapshotView.typeNameToViewInfoMap[typeName] = {
     51       constructor: viewConstructor,
     52       options: options
     53     };
     54   };
     55 
     56   ObjectSnapshotView.unregister = function(typeName) {
     57     if (ObjectSnapshotView.typeNameToViewInfoMap[typeName] === undefined)
     58       throw new Error(typeName + ' not registered');
     59     delete ObjectSnapshotView.typeNameToViewInfoMap[typeName];
     60   };
     61 
     62   ObjectSnapshotView.getViewInfo = function(typeName) {
     63     return ObjectSnapshotView.typeNameToViewInfoMap[typeName];
     64   };
     65 
     66   return {
     67     ObjectSnapshotView: ObjectSnapshotView
     68   };
     69 });
     70