Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(312)

Unified Diff: third_party/WebKit/Source/core/timing/Performance.cpp

Issue 2539323002: PerformanceMonitor: do not maintain a vector of frames in the monitor, single ExecutionContext memb… (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/timing/Performance.cpp
diff --git a/third_party/WebKit/Source/core/timing/Performance.cpp b/third_party/WebKit/Source/core/timing/Performance.cpp
index da6233deabda0ef21a4bcfdd3698f09c0923d35d..81fa3b2a984d8f28fb96183d10beb72412e1038c 100644
--- a/third_party/WebKit/Source/core/timing/Performance.cpp
+++ b/third_party/WebKit/Source/core/timing/Performance.cpp
@@ -166,19 +166,21 @@ static bool canAccessOrigin(Frame* frame1, Frame* frame2) {
*/
// static
std::pair<String, DOMWindow*> Performance::sanitizedAttribution(
- const HeapHashSet<Member<Frame>>& frames,
+ ExecutionContext* taskContext,
+ bool hasMultipleContexts,
Frame* observerFrame) {
- if (frames.size() == 0) {
+ if (!taskContext || !taskContext->isDocument() ||
caseq 2016/12/01 02:32:46 This will result in always returning kUnknownAttri
+ !toDocument(taskContext)->frame()) {
// Unable to attribute as no script was involved.
return std::make_pair(kUnknownAttribution, nullptr);
}
- if (frames.size() > 1) {
+ if (hasMultipleContexts) {
// Unable to attribute, multiple script execution contents were involved.
return std::make_pair(kAmbugiousAttribution, nullptr);
}
+
// Exactly one culprit location, attribute based on origin boundary.
- DCHECK_EQ(1u, frames.size());
- Frame* culpritFrame = *frames.begin();
+ Frame* culpritFrame = toDocument(taskContext)->frame();
DCHECK(culpritFrame);
if (canAccessOrigin(observerFrame, culpritFrame)) {
// From accessible frames or same origin, return culprit location URL.
@@ -208,12 +210,12 @@ std::pair<String, DOMWindow*> Performance::sanitizedAttribution(
return std::make_pair(kCrossOriginAttribution, nullptr);
}
-void Performance::reportLongTask(
- double startTime,
- double endTime,
- const HeapHashSet<Member<Frame>>& contextFrames) {
- std::pair<String, DOMWindow*> attribution =
- Performance::sanitizedAttribution(contextFrames, frame());
+void Performance::reportLongTask(double startTime,
+ double endTime,
+ ExecutionContext* taskContext,
+ bool hasMultipleContexts) {
+ std::pair<String, DOMWindow*> attribution = Performance::sanitizedAttribution(
+ taskContext, hasMultipleContexts, frame());
DOMWindow* culpritDomWindow = attribution.second;
if (!culpritDomWindow || !culpritDomWindow->document() ||
!culpritDomWindow->document()->localOwner()) {

Powered by Google App Engine
This is Rietveld 408576698