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

Unified Diff: third_party/WebKit/Source/core/frame/LocalFrame.cpp

Issue 2212183004: Log to UMA when x-origin frames (1) are created and (2) become visible (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 months 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/frame/LocalFrame.cpp
diff --git a/third_party/WebKit/Source/core/frame/LocalFrame.cpp b/third_party/WebKit/Source/core/frame/LocalFrame.cpp
index ccb59c9d1649bfd00846ebd78fbd0b4b0676d3a7..890d93b260e11fbed475e05381294e3d350e3970 100644
--- a/third_party/WebKit/Source/core/frame/LocalFrame.cpp
+++ b/third_party/WebKit/Source/core/frame/LocalFrame.cpp
@@ -69,6 +69,7 @@
#include "core/paint/TransformRecorder.h"
#include "core/svg/SVGDocumentExtensions.h"
#include "platform/DragImage.h"
+#include "platform/Histogram.h"
#include "platform/JSONValues.h"
#include "platform/PluginScriptForbiddenScope.h"
#include "platform/RuntimeEnabledFeatures.h"
@@ -238,6 +239,21 @@ inline float parentTextZoomFactor(LocalFrame* frame)
return toLocalFrame(parent)->textZoomFactor();
}
+// These are logged to UMA, so don't re-arrange them without creating a new histogram.
+enum FrameStateForDeferredLoading {
+ Created,
+ WouldLoadBecauseVisible,
+ // TODO(dgrogan): Add WouldLoadBecauseTopOrLeft, WouldLoadBecauseDisplayNone, etc
+
+ FrameStateForDeferredLoadingEnd
+};
+
+void RecordStateToHistogram(FrameStateForDeferredLoading state)
+{
+ DEFINE_STATIC_LOCAL(EnumerationHistogram, unseenFrameHistogram, ("FrameLoading.Deferred.StateCountsV1", FrameStateForDeferredLoadingEnd));
+ unseenFrameHistogram.count(state);
+}
+
} // namespace
template class CORE_TEMPLATE_EXPORT Supplement<LocalFrame>;
@@ -489,6 +505,8 @@ void LocalFrame::setDOMWindow(LocalDOMWindow* domWindow)
if (domWindow)
script().clearWindowProxy();
+ // Can't call isCrossOrigin until we get here, which seems to happen
+ // more than once.
ojan 2016/08/08 22:01:54 Nit: I think this would get called every time a fr
dgrogan 2016/08/09 00:30:16 In my testing it happens exactly twice per frame l
if (m_domWindow)
m_domWindow->reset();
m_domWindow = domWindow;
@@ -820,6 +838,8 @@ inline LocalFrame::LocalFrame(FrameLoaderClient* client, FrameHost* host, FrameO
, m_textZoomFactor(parentTextZoomFactor(this))
, m_inViewSourceMode(false)
, m_serviceRegistry(serviceRegistry)
+ , m_visibilityWasLogged(false)
+ , m_creationWasLogged(false)
{
if (isLocalRoot())
m_instrumentingAgents = new InstrumentingAgents();
@@ -855,6 +875,27 @@ PluginData* LocalFrame::pluginData() const
return page()->pluginData();
}
+void LocalFrame::onVisibilityMaybeChanged(bool visible)
+{
+ // Which x-origin check do we want? Frame::isCrossOrigin checks this origin against
+ // the top. But FrameView::m_crossOriginForThrottling is set if this origin is unable
+ // to access ANY origin between here and the top, inclusive.
+ if (!isCrossOrigin())
ojan 2016/08/08 22:01:54 I think this is probably the right one. I think th
+ return;
+
+ // Logging creation here is lame but I don't know where else to do it.
+ // Can't do it in the ctor because isCrossOrigin relies on document(), which isn't set yet.
ojan 2016/08/08 22:01:54 How about we log this in setDOMWindow? That actual
dgrogan 2016/08/09 00:30:16 We have the same isCrossOrigin problem there: the
dcheng 2016/08/09 01:24:04 If this needs to depend on isCrossOrigin(), it sho
+ if (!m_creationWasLogged) {
+ m_creationWasLogged = true;
+ RecordStateToHistogram(Created);
+ }
+
+ if (visible && !m_visibilityWasLogged) {
+ m_visibilityWasLogged = true;
+ RecordStateToHistogram(WouldLoadBecauseVisible);
+ }
+}
+
DEFINE_WEAK_IDENTIFIER_MAP(LocalFrame);
FrameNavigationDisabler::FrameNavigationDisabler(LocalFrame& frame)

Powered by Google App Engine
This is Rietveld 408576698