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

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: off-by-one in depth fixed 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..dc017d37dfcfcce2775ac3eb87e89fd0bbbacab9 100644
--- a/third_party/WebKit/Source/core/timing/Performance.cpp
+++ b/third_party/WebKit/Source/core/timing/Performance.cpp
@@ -46,7 +46,7 @@
static const double kLongTaskThreshold = 0.05;
static const char kUnknownAttribution[] = "unknown";
-static const char kAmbugiousAttribution[] = "multiple-contexts";
+static const char kAmbiguousAttribution[] = "multiple-contexts";
static const char kSameOriginAttribution[] = "same-origin";
static const char kAncestorAttribution[] = "cross-origin-ancestor";
static const char kDescendantAttribution[] = "cross-origin-descendant";
@@ -166,19 +166,22 @@ 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 (hasMultipleContexts) {
+ // Unable to attribute, multiple script execution contents were involved.
+ return std::make_pair(kAmbiguousAttribution, nullptr);
+ }
+
+ if (!taskContext || !taskContext->isDocument() ||
+ !toDocument(taskContext)->frame()) {
// Unable to attribute as no script was involved.
return std::make_pair(kUnknownAttribution, nullptr);
}
- if (frames.size() > 1) {
- // 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 +211,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()) {
« no previous file with comments | « third_party/WebKit/Source/core/timing/Performance.h ('k') | third_party/WebKit/Source/core/timing/PerformanceTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698