OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "core/inspector/InspectorWebPerfAgent.h" | 5 #include "core/inspector/InspectorWebPerfAgent.h" |
6 | 6 |
7 #include "core/InstrumentingAgents.h" | 7 #include "core/InstrumentingAgents.h" |
8 #include "core/dom/Document.h" | 8 #include "core/dom/Document.h" |
9 #include "core/dom/ExecutionContext.h" | 9 #include "core/dom/ExecutionContext.h" |
10 #include "core/frame/DOMWindow.h" | 10 #include "core/frame/DOMWindow.h" |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 Location* culpritLocation = *frameContextLocations.begin(); | 120 Location* culpritLocation = *frameContextLocations.begin(); |
121 if (canAccessOrigin(observerFrame, culpritLocation->frame())) { | 121 if (canAccessOrigin(observerFrame, culpritLocation->frame())) { |
122 // From accessible frames or same origin, return culprit location URL. | 122 // From accessible frames or same origin, return culprit location URL. |
123 return std::make_pair(kSameOriginAttribution, | 123 return std::make_pair(kSameOriginAttribution, |
124 culpritLocation->frame()->domWindow()); | 124 culpritLocation->frame()->domWindow()); |
125 } | 125 } |
126 // For cross-origin, if the culprit is the descendant or ancestor of | 126 // For cross-origin, if the culprit is the descendant or ancestor of |
127 // observer then indicate the *closest* cross-origin frame between | 127 // observer then indicate the *closest* cross-origin frame between |
128 // the observer and the culprit, in the corresponding direction. | 128 // the observer and the culprit, in the corresponding direction. |
129 if (culpritLocation->frame()->tree().isDescendantOf(observerFrame)) { | 129 if (culpritLocation->frame()->tree().isDescendantOf(observerFrame)) { |
130 // If culprit is a descendant of the observer, then walk up the tree from cu
lprit | 130 // If the culprit is a descendant of the observer, then walk up the tree |
131 // to observer, and report the *last* cross-origin (from observer) frame. | 131 // from culprit to observer, and report the *last* cross-origin (from |
132 // If no intermediate cross-origin frame is found, then report the culprit d
irectly. | 132 // observer) frame. If no intermediate cross-origin frame is found, then |
| 133 // report the culprit directly. |
133 Frame* lastCrossOriginFrame = culpritLocation->frame(); | 134 Frame* lastCrossOriginFrame = culpritLocation->frame(); |
134 for (Frame* frame = culpritLocation->frame(); frame != observerFrame; | 135 for (Frame* frame = culpritLocation->frame(); frame != observerFrame; |
135 frame = frame->tree().parent()) { | 136 frame = frame->tree().parent()) { |
136 if (!canAccessOrigin(observerFrame, frame)) { | 137 if (!canAccessOrigin(observerFrame, frame)) { |
137 lastCrossOriginFrame = frame; | 138 lastCrossOriginFrame = frame; |
138 } | 139 } |
139 } | 140 } |
140 return std::make_pair(kDescendantAttribution, | 141 return std::make_pair(kDescendantAttribution, |
141 lastCrossOriginFrame->domWindow()); | 142 lastCrossOriginFrame->domWindow()); |
142 } | 143 } |
143 if (observerFrame->tree().isDescendantOf(culpritLocation->frame())) { | 144 if (observerFrame->tree().isDescendantOf(culpritLocation->frame())) { |
144 return std::make_pair(kAncestorAttribution, nullptr); | 145 return std::make_pair(kAncestorAttribution, nullptr); |
145 } | 146 } |
146 return std::make_pair(kCrossOriginAttribution, nullptr); | 147 return std::make_pair(kCrossOriginAttribution, nullptr); |
147 } | 148 } |
148 | 149 |
149 DEFINE_TRACE(InspectorWebPerfAgent) { | 150 DEFINE_TRACE(InspectorWebPerfAgent) { |
150 visitor->trace(m_localFrame); | 151 visitor->trace(m_localFrame); |
151 visitor->trace(m_frameContextLocations); | 152 visitor->trace(m_frameContextLocations); |
152 } | 153 } |
153 | 154 |
154 } // namespace blink | 155 } // namespace blink |
OLD | NEW |