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..a67c871df26d2e49ec03b4ba5ca32dae32c03ad0 |
| --- /dev/null |
| +++ b/tracing/tracing/extras/chrome/blame_context/blame_context.html |
| @@ -0,0 +1,99 @@ |
| +<!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/event_set.html"> |
| +<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 |
| + * fo all snapshots of blame contexts traced in Chrome. |
|
Sami
2016/05/27 14:03:09
typo: of
Xiaocheng
2016/05/30 07:55:55
Done.
|
| + * |
| + * BlameContextInstance, which inherits from ObjectInstance, gathers snapshots |
| + * of the same blame context traced in Chrome. |
| + * |
| + * BlameContextSnapshot and BlameContextInstance should never be instantiated |
| + * directly. Subclasses of base::trace_event::BlameContext should define their |
|
Sami
2016/05/27 14:03:09
nit: Remove base::trace_event:: since this is talk
Xiaocheng
2016/05/30 07:55:55
Sorry for my poor wording skills. The subject of t
Sami
2016/05/31 16:59:36
I'm still a bit confused: there are no BlameContex
Xiaocheng
2016/06/01 01:22:11
Yeah, it looks better.
|
| + * own subclasses of BlameContextSnapshot and BlameContextInstance for |
| + * instantiation. |
| + * |
| + */ |
| +tr.exportTo('tr.e.chrome', function() { |
| + var ObjectSnapshot = tr.model.ObjectSnapshot; |
| + var ObjectInstance = tr.model.ObjectInstance; |
| + |
| + function BlameContextSnapshot() { |
| + ObjectSnapshot.apply(this, arguments); |
| + this.attributedEvents = new tr.model.EventSet(); |
|
Sami
2016/05/27 14:03:09
I wonder what the performance/memory overhead of t
Xiaocheng
2016/05/30 07:55:55
Another idea is to move this part to Frame Data Si
Sami
2016/05/31 16:59:36
Right, having that work with a delay (as long as i
benjhayden
2016/05/31 17:37:12
attributedEvents looks very similar to some other
Sami
2016/05/31 18:15:10
In Trace Viewer we've faked it by splitting the wo
Xiaocheng
2016/06/01 01:22:11
If we don't open Frame Data Side Panel then none o
|
| + } |
| + |
| + BlameContextSnapshot.prototype = { |
| + __proto__: ObjectSnapshot.prototype, |
| + |
| + preInitialize: function() { |
| + }, |
| + |
| + initialize: function() { |
| + }, |
| + |
| + referencedAt: function(item, object, field) { |
| + if (item instanceof tr.model.TimedEvent && |
| + item.contexts.some(entry => object === entry) && |
| + field === 'snapshot') |
|
Sami
2016/05/27 14:03:09
nit: add braces
Xiaocheng
2016/05/30 07:55:55
Done.
|
| + this.attributedEvents.push(item); |
| + }, |
| + |
| + /** |
| + * Returns the parent in the context tree. |
| + */ |
| + get parentContext() { |
| + if (this.args.parent instanceof BlameContextSnapshot) |
| + return this.args.parent; |
| + }, |
| + |
| + 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() { |
| + 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> |