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