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

Unified Diff: third_party/WebKit/Source/modules/vibration/NavigatorVibration.cpp

Issue 2082463002: Measure the usage of navigator.vibrate in for user gesture & subframe. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Record more detailed usage of vibrate for user gesture, subframe and cross-origin subframe. Also removing the old metrics. Created 4 years, 6 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/modules/vibration/NavigatorVibration.cpp
diff --git a/third_party/WebKit/Source/modules/vibration/NavigatorVibration.cpp b/third_party/WebKit/Source/modules/vibration/NavigatorVibration.cpp
index ae5ca2c5c3622862bdb791b90a39b4e520bbbc8e..218593518df635fb46152a18bee33bb73d94e305 100644
--- a/third_party/WebKit/Source/modules/vibration/NavigatorVibration.cpp
+++ b/third_party/WebKit/Source/modules/vibration/NavigatorVibration.cpp
@@ -24,6 +24,8 @@
#include "core/frame/UseCounter.h"
#include "core/page/Page.h"
#include "modules/vibration/VibrationController.h"
+#include "platform/Histogram.h"
+#include "platform/UserGestureIndicator.h"
namespace blink {
@@ -71,9 +73,20 @@ bool NavigatorVibration::vibrate(Navigator& navigator, const VibrationPattern& p
if (!frame)
return false;
- UseCounter::count(frame, UseCounter::NavigatorVibrate);
- if (!frame->isMainFrame())
- UseCounter::count(frame, UseCounter::NavigatorVibrateSubFrame);
+ const unsigned userGestureBit = 0x1;
+ const unsigned subFrameBit = 0x2;
+ const unsigned crossOriginFrameBit = 0x4;
+ unsigned vibrateParams = 0;
+ if (UserGestureIndicator::processingUserGesture())
+ vibrateParams |= userGestureBit;
+ if (!frame->isMainFrame()) {
+ if (frame->isCrossOrigin())
+ vibrateParams |= crossOriginFrameBit;
+ else
+ vibrateParams |= subFrameBit;
+ }
+ DEFINE_STATIC_LOCAL(EnumerationHistogram, NavigatorVibrateHistogram, ("WebModules.NavigatorVibrate", 6));
+ NavigatorVibrateHistogram.count(vibrateParams);
mlamouri (slow - plz ping) 2016/06/27 12:34:02 We usually use proper enum to guarantee enum/histo
Bin Lu 2016/06/27 15:38:35 Done. Added enum.
DCHECK(frame->document());
DCHECK(frame->page());

Powered by Google App Engine
This is Rietveld 408576698