Chromium Code Reviews| Index: tracing/tracing/extras/chrome/blame_context/blame_context.html |
| diff --git a/tracing/tracing/extras/chrome/blame_context/blame_context.html b/tracing/tracing/extras/chrome/blame_context/blame_context.html |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..008664ad73f792413d3f9fd6c6cd3b2bbd5f9efb |
| --- /dev/null |
| +++ b/tracing/tracing/extras/chrome/blame_context/blame_context.html |
| @@ -0,0 +1,93 @@ |
| +<!DOCTYPE html> |
| +<!-- |
| +Copyright 2016 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="/tracing/model/object_instance.html"> |
| + |
| +<script> |
| +'use strict'; |
| + |
| +/** |
| + * @fileoverview BlameContext is the Trace Viewer side correspondence of |
| + * Chrome's class base::trace_event::BlameContext. More specifically, |
| + * |
| + * BlameContextSnapshot, which inherits from ObjectSnapshot, is the base class |
| + * of all snapshots of blame contexts traced in Chrome. |
| + * |
| + * BlameContextInstance, which inherits from ObjectInstance, gathers snapshots |
| + * of the same blame context traced in Chrome. |
| + * |
| + * BlameContextSnapshot and BlameContextInstance should never be instantiated |
| + * directly. Subclasses corresponding to different BlameContexts in Chrome |
| + * should define their own BlameContextSnapshot and BlameContextInstance |
| + * specializations for instantiation. |
| + * |
| + */ |
| +tr.exportTo('tr.e.chrome', function() { |
| + var ObjectSnapshot = tr.model.ObjectSnapshot; |
| + var ObjectInstance = tr.model.ObjectInstance; |
| + |
| + function BlameContextSnapshot() { |
| + ObjectSnapshot.apply(this, arguments); |
| + } |
| + |
| + BlameContextSnapshot.prototype = { |
| + __proto__: ObjectSnapshot.prototype, |
| + |
| + preInitialize: function() { |
|
benjhayden
2016/06/01 20:48:24
Why override these methods? The base class impleme
Xiaocheng
2016/06/02 06:54:55
This part follows the current render_frame.html an
benjhayden
2016/06/02 20:07:01
Ah, nope, that was my bad copy-pasta.
Xiaocheng
2016/06/03 05:38:38
Done.
|
| + }, |
| + |
| + initialize: function() { |
| + }, |
| + |
| + referencedAt: function(item, object, field) { |
| + }, |
| + |
| + /** |
| + * Returns the parent in the context tree. |
| + */ |
| + get parentContext() { |
| + if (this.args.parent instanceof BlameContextSnapshot) |
| + return this.args.parent; |
|
benjhayden
2016/06/01 20:48:24
Would you mind explicitly return undefined if ther
Xiaocheng
2016/06/02 06:54:55
No. Done.
|
| + }, |
| + |
| + get userFriendlyName() { |
| + return 'BlameContext'; |
| + } |
| + }; |
| + |
| + function BlameContextInstance() { |
| + ObjectInstance.apply(this, arguments); |
| + } |
| + |
| + BlameContextInstance.prototype = { |
| + __proto__: ObjectInstance.prototype, |
| + |
| + /** |
| + * Returns the pid of the process where this blame context is traced. |
| + */ |
| + get pid() { |
|
benjhayden
2016/06/01 20:48:24
Why is this necessary?
Xiaocheng
2016/06/02 06:54:55
Sorry, it's a question that I forgot to ask: is |t
benjhayden
2016/06/02 20:07:01
Yes, objectInstance.parent.pid is the right way, s
Xiaocheng
2016/06/03 05:38:38
Done.
|
| + return this.parent.pid; |
| + }, |
| + |
| + get isTracedByRenderer() { |
| + throw new Error('Not implemented'); |
| + }, |
| + |
| + /** |
| + * Returns the type of the blame context, to be overriden by subclasses. |
| + */ |
| + get blameContextType() { |
| + throw new Error('Not implemented'); |
| + } |
| + }; |
| + |
| + return { |
| + BlameContextSnapshot: BlameContextSnapshot, |
| + BlameContextInstance: BlameContextInstance |
| + }; |
| +}); |
| +</script> |