summaryrefslogtreecommitdiffstats
path: root/chromium/third_party/catapult/tracing/tracing/extras/chrome/blame_context/render_frame.html
blob: 1543403dae8318741eec6c2bc2c8d7c4790c544b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
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>