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

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

Issue 2515993002: Replace DOMWindow with iframe attrs: src, id, name (Closed)
Patch Set: don't truncate ID Created 4 years, 1 month 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
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/timing/PerformanceBase.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 e8402d527b83e817adafcd38c2ec1c91a1b20a52..da6233deabda0ef21a4bcfdd3698f09c0923d35d 100644
--- a/third_party/WebKit/Source/core/timing/Performance.cpp
+++ b/third_party/WebKit/Source/core/timing/Performance.cpp
@@ -34,8 +34,11 @@
#include "bindings/core/v8/ScriptValue.h"
#include "bindings/core/v8/V8ObjectBuilder.h"
#include "core/dom/Document.h"
+#include "core/dom/QualifiedName.h"
+#include "core/frame/DOMWindow.h"
#include "core/frame/LocalFrame.h"
#include "core/frame/UseCounter.h"
+#include "core/html/HTMLFrameOwnerElement.h"
#include "core/loader/DocumentLoader.h"
#include "core/origin_trials/OriginTrials.h"
#include "core/timing/PerformanceTiming.h"
@@ -51,6 +54,22 @@ static const char kCrossOriginAttribution[] = "cross-origin-unreachable";
namespace blink {
+namespace {
+
+String getFrameAttribute(HTMLFrameOwnerElement* frameOwner,
+ const QualifiedName& attrName,
+ bool truncate) {
+ String attrValue;
+ if (frameOwner->hasAttribute(attrName)) {
+ attrValue = frameOwner->getAttribute(attrName);
+ if (truncate && attrValue.length() > 100)
+ attrValue = attrValue.substring(0, 100); // Truncate to 100 chars
+ }
+ return attrValue;
+}
+
+} // namespace
+
static double toTimeOrigin(LocalFrame* frame) {
if (!frame)
return 0.0;
@@ -195,7 +214,18 @@ void Performance::reportLongTask(
const HeapHashSet<Member<Frame>>& contextFrames) {
std::pair<String, DOMWindow*> attribution =
Performance::sanitizedAttribution(contextFrames, frame());
- addLongTaskTiming(startTime, endTime, attribution.first, attribution.second);
+ DOMWindow* culpritDomWindow = attribution.second;
+ if (!culpritDomWindow || !culpritDomWindow->document() ||
+ !culpritDomWindow->document()->localOwner()) {
+ addLongTaskTiming(startTime, endTime, attribution.first, "", "", "");
+ } else {
+ HTMLFrameOwnerElement* frameOwner =
+ culpritDomWindow->document()->localOwner();
+ addLongTaskTiming(startTime, endTime, attribution.first,
+ getFrameAttribute(frameOwner, HTMLNames::srcAttr, false),
+ getFrameAttribute(frameOwner, HTMLNames::idAttr, false),
+ getFrameAttribute(frameOwner, HTMLNames::nameAttr, true));
+ }
}
} // namespace blink
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/timing/PerformanceBase.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698