494c57c67d41a47735a3aca4d8ef08227c0da8c1
[platform/framework/web/crosswalk.git] / src / third_party / trace-viewer / src / tracing / analysis / object_snapshot_view.js
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     get requiresTallView() {
20       return true;
21     },
22
23     set modelEvent(obj) {
24       this.objectSnapshot = obj;
25     },
26
27     get modelEvent() {
28       return this.objectSnapshot;
29     },
30
31     get objectSnapshot() {
32       return this.objectSnapshot_;
33     },
34
35     set objectSnapshot(i) {
36       this.objectSnapshot_ = i;
37       this.updateContents();
38     },
39
40     updateContents: function() {
41       throw new Error('Not implemented');
42     }
43   };
44
45   ObjectSnapshotView.typeNameToViewInfoMap = {};
46   ObjectSnapshotView.register = function(typeName,
47                                          viewConstructor,
48                                          opt_options) {
49     if (ObjectSnapshotView.typeNameToViewInfoMap[typeName])
50       throw new Error('Handler already registered for ' + typeName);
51     var options = opt_options || {
52       showInTrackView: true
53     };
54     ObjectSnapshotView.typeNameToViewInfoMap[typeName] = {
55       constructor: viewConstructor,
56       options: options
57     };
58   };
59
60   ObjectSnapshotView.unregister = function(typeName) {
61     if (ObjectSnapshotView.typeNameToViewInfoMap[typeName] === undefined)
62       throw new Error(typeName + ' not registered');
63     delete ObjectSnapshotView.typeNameToViewInfoMap[typeName];
64   };
65
66   ObjectSnapshotView.getViewInfo = function(typeName) {
67     return ObjectSnapshotView.typeNameToViewInfoMap[typeName];
68   };
69
70   return {
71     ObjectSnapshotView: ObjectSnapshotView
72   };
73 });