Index: third_party/WebKit/Source/core/frame/VisualViewport.cpp |
diff --git a/third_party/WebKit/Source/core/frame/VisualViewport.cpp b/third_party/WebKit/Source/core/frame/VisualViewport.cpp |
index d6472c65beed2a7c3115a1f23f3a9c20361bebe0..1172fab5091b7af5b5dd26ed62b8a64a37b4cee3 100644 |
--- a/third_party/WebKit/Source/core/frame/VisualViewport.cpp |
+++ b/third_party/WebKit/Source/core/frame/VisualViewport.cpp |
@@ -71,12 +71,15 @@ VisualViewport::VisualViewport(FrameHost& owner) |
: m_frameHost(&owner) |
, m_scale(1) |
, m_topControlsAdjustment(0) |
+ , m_maxPageScale(-1) |
+ , m_trackPinchZoomStatsForPage(false) |
{ |
reset(); |
} |
VisualViewport::~VisualViewport() |
{ |
+ sendUMAMetrics(); |
Rick Byers
2015/09/28 18:43:58
Is there already an established pattern for render
bokan
2015/09/29 20:33:20
I copied this pattern from the Blink useCounter wh
bokan
2015/10/01 20:58:15
Right, so this wont report stats for a page if the
Rick Byers
2015/10/02 00:53:22
Ugh, that's a pain. I didn't realize UseCounter d
|
} |
DEFINE_TRACE(VisualViewport) |
@@ -654,6 +657,55 @@ IntPoint VisualViewport::rootFrameToViewport(const IntPoint& pointInRootFrame) c |
return flooredIntPoint(FloatPoint(rootFrameToViewport(FloatPoint(pointInRootFrame)))); |
} |
+void VisualViewport::startTrackingPinchStats() |
+{ |
+#if !OS(ANDROID) |
+ return; |
Rick Byers
2015/09/28 18:43:58
Always sucks to add more #if OS(ANDROID (eg. makes
bokan
2015/10/01 20:18:31
Gone in latest patch.
|
+#endif |
+ |
+ if (!mainFrame()) |
+ return; |
+ |
+ Document* document = mainFrame()->document(); |
+ if (!document) |
+ return; |
+ |
+ if (!document->url().protocolIsInHTTPFamily()) |
+ return; |
+ |
+ const ViewportDescription& desc = mainFrame()->document()->viewportDescription(); |
+ bool isNonMobile = |
Rick Byers
2015/09/28 18:43:58
I thought this logic (along with "am I on Android"
bokan
2015/09/29 20:33:20
WebViewImpl::shouldDisableDesktopWorkarounds. It's
bokan
2015/10/01 20:18:31
Latest patch replaces this with the shouldDisableD
|
+ !desc.isSpecifiedByAuthor() |
+ || (desc.isMetaViewportType() && desc.maxWidth.type() == blink::Fixed); |
+ |
+ m_trackPinchZoomStatsForPage = isNonMobile; |
+} |
+ |
+void VisualViewport::userDidChangeScale() |
+{ |
+ if (!m_trackPinchZoomStatsForPage) |
+ return; |
+ |
+ m_maxPageScale = std::max(m_maxPageScale, m_scale); |
Rick Byers
2015/09/28 18:43:58
I assume this gets called only at GesturePinchEnd
bokan
2015/09/29 20:33:20
Good point. I do think capturing the scale only at
|
+} |
+ |
+void VisualViewport::sendUMAMetrics() |
+{ |
+ if (m_trackPinchZoomStatsForPage) { |
+ bool didScale = m_maxPageScale > 0; |
+ |
+ Platform::current()->histogramEnumeration("Viewport.DidScalePage", didScale ? 1 : 0, 2); |
+ |
+ if (didScale) { |
+ int zoomPercentage = floor(m_maxPageScale * 100); |
+ Platform::current()->histogramEnumeration("Viewport.MaxPageScale", zoomPercentage, 501); |
Ilya Sherman
2015/09/30 04:30:28
This allocates a histogram with 500 buckets, which
bokan
2015/10/01 20:18:31
Ok, I mapped the percentages into ~20 buckets comp
|
+ } |
+ } |
+ |
+ m_maxPageScale = -1; |
+ m_trackPinchZoomStatsForPage = false; |
+} |
+ |
String VisualViewport::debugName(const GraphicsLayer* graphicsLayer) |
{ |
String name; |