| <!DOCTYPE html> |
| <!-- |
| Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| Use of this source code is governed by a BSD-style license that can be |
| found in the LICENSE file. |
| --> |
| |
| <link rel="import" href="/base/extension_registry.html"> |
| <link rel="import" href="/core/analysis/util.html"> |
| <link rel="import" href="/core/trace_model/event.html"> |
| |
| <script> |
| 'use strict'; |
| |
| tv.exportTo('tv.c.trace_model', function() { |
| /** |
| * A snapshot of an object instance, at a given moment in time. |
| * |
| * Initialization of snapshots and instances is three phased: |
| * |
| * 1. Instances and snapshots are constructed. This happens during event |
| * importing. Little should be done here, because the object's data |
| * are still being used by the importer to reconstruct object references. |
| * |
| * 2. Instances and snapshtos are preinitialized. This happens after implicit |
| * objects have been found, but before any references have been found and |
| * switched to direct references. Thus, every snapshot stands on its own. |
| * This is a good time to do global field renaming and type conversion, |
| * e.g. recognizing domain-specific types and converting from C++ naming |
| * convention to JS. |
| * |
| * 3. Instances and snapshtos are initialized. At this point, {id_ref: |
| * '0x1000'} fields have been converted to snapshot references. This is a |
| * good time to generic initialization steps and argument verification. |
| * |
| * @constructor |
| */ |
| function ObjectSnapshot(objectInstance, ts, args) { |
| tv.c.trace_model.Event.call(this); |
| this.objectInstance = objectInstance; |
| this.ts = ts; |
| this.args = args; |
| } |
| |
| ObjectSnapshot.prototype = { |
| __proto__: tv.c.trace_model.Event.prototype, |
| |
| /** |
| * See ObjectSnapshot constructor notes on object initialization. |
| */ |
| preInitialize: function() { |
| }, |
| |
| /** |
| * See ObjectSnapshot constructor notes on object initialization. |
| */ |
| initialize: function() { |
| }, |
| |
| addBoundsToRange: function(range) { |
| range.addValue(this.ts); |
| }, |
| |
| get userFriendlyName() { |
| return 'Snapshot of ' + |
| this.objectInstance.typeName + ' ' + |
| this.objectInstance.id + ' @ ' + |
| tv.c.analysis.tsString(this.ts); |
| } |
| }; |
| |
| tv.c.trace_model.EventRegistry.register( |
| ObjectSnapshot, |
| { |
| name: 'objectSnapshot', |
| pluralName: 'objectSnapshots', |
| singleViewElementName: 'tv-c-single-object-snapshot-sub-view', |
| multiViewElementName: 'tv-c-multi-object-sub-view' |
| }); |
| |
| var options = new tv.b.ExtensionRegistryOptions( |
| tv.b.TYPE_BASED_REGISTRY_MODE); |
| options.mandatoryBaseClass = ObjectSnapshot; |
| options.defaultConstructor = ObjectSnapshot; |
| tv.b.decorateExtensionRegistry(ObjectSnapshot, options); |
| |
| return { |
| ObjectSnapshot: ObjectSnapshot |
| }; |
| }); |
| </script> |