1<!DOCTYPE html> 2<!-- 3Copyright 2016 The Chromium Authors. All rights reserved. 4Use of this source code is governed by a BSD-style license that can be 5found in the LICENSE file. 6--> 7 8<link rel="import" href="/tracing/model/object_instance.html"> 9 10<script> 11'use strict'; 12 13/** 14 * @fileoverview BlameContext is the Trace Viewer side correspondence of 15 * Chrome's class base::trace_event::BlameContext. More specifically, 16 * 17 * BlameContextSnapshot, which inherits from ObjectSnapshot, is the base class 18 * of all snapshots of blame contexts traced in Chrome. 19 * 20 * BlameContextInstance, which inherits from ObjectInstance, gathers snapshots 21 * of the same blame context traced in Chrome. 22 * 23 * BlameContextSnapshot and BlameContextInstance should never be instantiated 24 * directly. Subclasses corresponding to different BlameContexts in Chrome 25 * should define their own BlameContextSnapshot and BlameContextInstance 26 * specializations for instantiation. 27 * 28 */ 29tr.exportTo('tr.e.chrome', function() { 30 var ObjectSnapshot = tr.model.ObjectSnapshot; 31 var ObjectInstance = tr.model.ObjectInstance; 32 33 function BlameContextSnapshot() { 34 ObjectSnapshot.apply(this, arguments); 35 } 36 37 BlameContextSnapshot.prototype = { 38 __proto__: ObjectSnapshot.prototype, 39 40 /** 41 * Returns the parent in the context tree. 42 */ 43 get parentContext() { 44 if (this.args.parent instanceof BlameContextSnapshot) 45 return this.args.parent; 46 return undefined; 47 }, 48 49 get userFriendlyName() { 50 return 'BlameContext'; 51 } 52 }; 53 54 function BlameContextInstance() { 55 ObjectInstance.apply(this, arguments); 56 } 57 58 BlameContextInstance.prototype = { 59 __proto__: ObjectInstance.prototype, 60 61 /** 62 * Returns the type of the blame context, to be overriden by subclasses. 63 */ 64 get blameContextType() { 65 throw new Error('Not implemented'); 66 } 67 }; 68 69 return { 70 BlameContextSnapshot: BlameContextSnapshot, 71 BlameContextInstance: BlameContextInstance 72 }; 73}); 74</script> 75