summaryrefslogtreecommitdiff
path: root/chromium/third_party/catapult/tracing/tracing/extras/chrome/blame_context
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/third_party/catapult/tracing/tracing/extras/chrome/blame_context')
-rw-r--r--chromium/third_party/catapult/tracing/tracing/extras/chrome/blame_context/blame_context.html75
-rw-r--r--chromium/third_party/catapult/tracing/tracing/extras/chrome/blame_context/blame_context_test.html64
-rw-r--r--chromium/third_party/catapult/tracing/tracing/extras/chrome/blame_context/frame_blame_context_test.html44
-rw-r--r--chromium/third_party/catapult/tracing/tracing/extras/chrome/blame_context/frame_tree_node.html70
-rw-r--r--chromium/third_party/catapult/tracing/tracing/extras/chrome/blame_context/render_frame.html82
-rw-r--r--chromium/third_party/catapult/tracing/tracing/extras/chrome/blame_context/top_level.html59
6 files changed, 394 insertions, 0 deletions
diff --git a/chromium/third_party/catapult/tracing/tracing/extras/chrome/blame_context/blame_context.html b/chromium/third_party/catapult/tracing/tracing/extras/chrome/blame_context/blame_context.html
new file mode 100644
index 00000000000..08a8842b1f9
--- /dev/null
+++ b/chromium/third_party/catapult/tracing/tracing/extras/chrome/blame_context/blame_context.html
@@ -0,0 +1,75 @@
+<!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() {
+ const ObjectSnapshot = tr.model.ObjectSnapshot;
+ const ObjectInstance = tr.model.ObjectInstance;
+
+ function BlameContextSnapshot() {
+ ObjectSnapshot.apply(this, arguments);
+ }
+
+ BlameContextSnapshot.prototype = {
+ __proto__: ObjectSnapshot.prototype,
+
+ /**
+ * Returns the parent in the context tree.
+ */
+ get parentContext() {
+ if (this.args.parent instanceof BlameContextSnapshot) {
+ return this.args.parent;
+ }
+ return undefined;
+ },
+
+ get userFriendlyName() {
+ return 'BlameContext';
+ }
+ };
+
+ function BlameContextInstance() {
+ ObjectInstance.apply(this, arguments);
+ }
+
+ BlameContextInstance.prototype = {
+ __proto__: ObjectInstance.prototype,
+
+ /**
+ * Returns the type of the blame context, to be overriden by subclasses.
+ */
+ get blameContextType() {
+ throw new Error('Not implemented');
+ }
+ };
+
+ return {
+ BlameContextSnapshot,
+ BlameContextInstance,
+ };
+});
+</script>
diff --git a/chromium/third_party/catapult/tracing/tracing/extras/chrome/blame_context/blame_context_test.html b/chromium/third_party/catapult/tracing/tracing/extras/chrome/blame_context/blame_context_test.html
new file mode 100644
index 00000000000..8d6f4b5be5c
--- /dev/null
+++ b/chromium/third_party/catapult/tracing/tracing/extras/chrome/blame_context/blame_context_test.html
@@ -0,0 +1,64 @@
+<!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/core/test_utils.html">
+<link rel="import" href="/tracing/extras/chrome/blame_context/blame_context.html">
+
+<script>
+'use strict';
+
+tr.b.unittest.testSuite(function() {
+ const BlameContextSnapshot = tr.e.chrome.BlameContextSnapshot;
+ const BlameContextInstance = tr.e.chrome.BlameContextInstance;
+
+ function TestBlameContextSnapshot() {
+ BlameContextSnapshot.apply(this, arguments);
+ }
+
+ TestBlameContextSnapshot.prototype = {
+ __proto__: BlameContextSnapshot.prototype,
+
+ get userFriendlyName() {
+ return 'Test';
+ }
+ };
+
+ tr.model.ObjectSnapshot.subTypes.register(
+ TestBlameContextSnapshot,
+ {typeName: 'Test'});
+
+ function TestBlameContextInstance() {
+ BlameContextInstance.apply(this, arguments);
+ }
+
+ TestBlameContextInstance.prototype = {
+ __proto__: BlameContextInstance.prototype,
+
+ get blameContextType() {
+ return 'Test';
+ }
+ };
+
+ tr.model.ObjectInstance.subTypes.register(
+ TestBlameContextInstance,
+ {typeName: 'Test'});
+
+ const TestUtils = tr.c.TestUtils;
+
+ test('parentContext', function() {
+ let parent;
+ let child;
+ TestUtils.newModel(function(model) {
+ parent = TestUtils.newSnapshot(model, {id: '0x1', name: 'Test'});
+ child = TestUtils.newSnapshot(model, {id: '0x2', name: 'Test',
+ args: {parent: {id_ref: '0x1'}}});
+ });
+
+ assert.isTrue(child.parentContext === parent);
+ });
+});
+</script>
diff --git a/chromium/third_party/catapult/tracing/tracing/extras/chrome/blame_context/frame_blame_context_test.html b/chromium/third_party/catapult/tracing/tracing/extras/chrome/blame_context/frame_blame_context_test.html
new file mode 100644
index 00000000000..43b15ae43be
--- /dev/null
+++ b/chromium/third_party/catapult/tracing/tracing/extras/chrome/blame_context/frame_blame_context_test.html
@@ -0,0 +1,44 @@
+<!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/core/test_utils.html">
+<link rel="import" href="/tracing/extras/chrome/blame_context/frame_tree_node.html">
+<link rel="import" href="/tracing/extras/chrome/blame_context/render_frame.html">
+<link rel="import" href="/tracing/extras/chrome/blame_context/top_level.html">
+
+<script>
+'use strict';
+
+tr.b.unittest.testSuite(function() {
+ const TestUtils = tr.c.TestUtils;
+
+ test('crossProcessCounterpart', function() {
+ let frameTreeNode;
+ let renderFrame;
+ TestUtils.newModel(function(model) {
+ // Add a toplevel to make the context tree consistent with the spec,
+ // though its functionality is not tested here.
+ TestUtils.newSnapshot(model, {
+ pid: 1, name: 'TopLevel', id: '0x1',
+ scope: 'PlatformThread', category: 'blink'});
+ renderFrame = TestUtils.newSnapshot(
+ model, {
+ pid: 1, name: 'RenderFrame', id: '0x2', scope: 'RenderFrame',
+ category: 'blink', args: {
+ parent: {scope: 'PlatformThread', id_ref: '0x1'}}});
+ frameTreeNode = TestUtils.newSnapshot(
+ model, {
+ pid: 2, name: 'FrameTreeNode', id: '0x3', scope: 'FrameTreeNode',
+ category: 'navigation', args: {
+ renderFrame: {scope: 'RenderFrame', id_ref: '0x2', pid_ref: 1}}});
+ });
+
+ assert.isTrue(frameTreeNode.renderFrame === renderFrame);
+ assert.isTrue(renderFrame.frameTreeNode === frameTreeNode);
+ });
+});
+</script>
diff --git a/chromium/third_party/catapult/tracing/tracing/extras/chrome/blame_context/frame_tree_node.html b/chromium/third_party/catapult/tracing/tracing/extras/chrome/blame_context/frame_tree_node.html
new file mode 100644
index 00000000000..bfd21093de5
--- /dev/null
+++ b/chromium/third_party/catapult/tracing/tracing/extras/chrome/blame_context/frame_tree_node.html
@@ -0,0 +1,70 @@
+<!DOCTYPE html>
+<!--
+Copyright (c) 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/extras/chrome/blame_context/blame_context.html">
+
+<script>
+'use strict';
+
+/**
+ * @fileoverview Trace Viewer side's correspondence of Chrome's
+ * content::FrameTreeNode class.
+ *
+ */
+tr.exportTo('tr.e.chrome', function() {
+ const BlameContextSnapshot = tr.e.chrome.BlameContextSnapshot;
+ const BlameContextInstance = tr.e.chrome.BlameContextInstance;
+
+ function FrameTreeNodeSnapshot() {
+ BlameContextSnapshot.apply(this, arguments);
+ }
+
+ FrameTreeNodeSnapshot.prototype = {
+ __proto__: BlameContextSnapshot.prototype,
+
+ get renderFrame() {
+ if (this.args.renderFrame instanceof tr.e.chrome.RenderFrameSnapshot) {
+ return this.args.renderFrame;
+ }
+ return undefined;
+ },
+
+ get url() {
+ return this.args.url;
+ },
+
+ get userFriendlyName() {
+ return 'FrameTreeNode';
+ }
+ };
+
+ tr.model.ObjectSnapshot.subTypes.register(
+ FrameTreeNodeSnapshot,
+ {typeName: 'FrameTreeNode'});
+
+ function FrameTreeNodeInstance() {
+ BlameContextInstance.apply(this, arguments);
+ }
+
+ FrameTreeNodeInstance.prototype = {
+ __proto__: BlameContextInstance.prototype,
+
+ get blameContextType() {
+ return 'Frame';
+ }
+ };
+
+ tr.model.ObjectInstance.subTypes.register(
+ FrameTreeNodeInstance,
+ {typeName: 'FrameTreeNode'});
+
+ return {
+ FrameTreeNodeSnapshot,
+ FrameTreeNodeInstance,
+ };
+});
+</script>
diff --git a/chromium/third_party/catapult/tracing/tracing/extras/chrome/blame_context/render_frame.html b/chromium/third_party/catapult/tracing/tracing/extras/chrome/blame_context/render_frame.html
new file mode 100644
index 00000000000..1543403dae8
--- /dev/null
+++ b/chromium/third_party/catapult/tracing/tracing/extras/chrome/blame_context/render_frame.html
@@ -0,0 +1,82 @@
+<!DOCTYPE html>
+<!--
+Copyright (c) 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/extras/chrome/blame_context/blame_context.html">
+
+<script>
+'use strict';
+
+/**
+ * @fileoverview Trace Viewer side's correspondence of Chrome's
+ * content::FrameBlameContext class.
+ *
+ */
+tr.exportTo('tr.e.chrome', function() {
+ const BlameContextSnapshot = tr.e.chrome.BlameContextSnapshot;
+ const BlameContextInstance = tr.e.chrome.BlameContextInstance;
+
+ function RenderFrameSnapshot() {
+ BlameContextSnapshot.apply(this, arguments);
+ }
+
+ RenderFrameSnapshot.prototype = {
+ __proto__: BlameContextSnapshot.prototype,
+
+ referencedAt(item, object, field) {
+ if (item instanceof tr.e.chrome.FrameTreeNodeSnapshot &&
+ object === item.args &&
+ field === 'renderFrame') {
+ this.args.frameTreeNode = item;
+ }
+ },
+
+ get frameTreeNode() {
+ if (this.args.frameTreeNode instanceof
+ tr.e.chrome.FrameTreeNodeSnapshot) {
+ return this.args.frameTreeNode;
+ }
+ return undefined;
+ },
+
+ get url() {
+ if (this.frameTreeNode) {
+ return this.frameTreeNode.url;
+ }
+ return undefined;
+ },
+
+ get userFriendlyName() {
+ return 'RenderFrame';
+ }
+ };
+
+ tr.model.ObjectSnapshot.subTypes.register(
+ RenderFrameSnapshot,
+ {typeName: 'RenderFrame'});
+
+ function RenderFrameInstance() {
+ BlameContextInstance.apply(this, arguments);
+ }
+
+ RenderFrameInstance.prototype = {
+ __proto__: BlameContextInstance.prototype,
+
+ get blameContextType() {
+ return 'Frame';
+ }
+ };
+
+ tr.model.ObjectInstance.subTypes.register(
+ RenderFrameInstance,
+ {typeName: 'RenderFrame'});
+
+ return {
+ RenderFrameSnapshot,
+ RenderFrameInstance,
+ };
+});
+</script>
diff --git a/chromium/third_party/catapult/tracing/tracing/extras/chrome/blame_context/top_level.html b/chromium/third_party/catapult/tracing/tracing/extras/chrome/blame_context/top_level.html
new file mode 100644
index 00000000000..b69bdb83b0d
--- /dev/null
+++ b/chromium/third_party/catapult/tracing/tracing/extras/chrome/blame_context/top_level.html
@@ -0,0 +1,59 @@
+<!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/extras/chrome/blame_context/blame_context.html">
+
+<script>
+'use strict';
+
+/**
+ * @fileoverview Trace Viewer side's correspondence of Chrome's
+ * content::TopLevelBlameContext class.
+ *
+ */
+tr.exportTo('tr.e.chrome', function() {
+ const BlameContextSnapshot = tr.e.chrome.BlameContextSnapshot;
+ const BlameContextInstance = tr.e.chrome.BlameContextInstance;
+
+ function TopLevelSnapshot() {
+ BlameContextSnapshot.apply(this, arguments);
+ }
+
+ TopLevelSnapshot.prototype = {
+ __proto__: BlameContextSnapshot.prototype,
+
+ get userFriendlyName() {
+ return 'TopLevel';
+ }
+ };
+
+ tr.model.ObjectSnapshot.subTypes.register(
+ TopLevelSnapshot,
+ {typeName: 'TopLevel'});
+
+ function TopLevelInstance() {
+ BlameContextInstance.apply(this, arguments);
+ }
+
+ TopLevelInstance.prototype = {
+ __proto__: BlameContextInstance.prototype,
+
+ get blameContextType() {
+ return 'TopLevel';
+ }
+ };
+
+ tr.model.ObjectInstance.subTypes.register(
+ TopLevelInstance,
+ {typeName: 'TopLevel'});
+
+ return {
+ TopLevelSnapshot,
+ TopLevelInstance,
+ };
+});
+</script>