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

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: Keep depcreated UserCounter metrics and suffix the labels with (obsolete). 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..c33c8c4875774a643f12a3624ca4e5788409c0e3 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"
Michael van Ouwerkerk 2016/06/28 11:45:52 Delete this as it is no longer used.
#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;
Michael van Ouwerkerk 2016/06/28 11:45:53 I don't find this section very readable, using bit
+ 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, ("Vibration.Context", NavigatorVibrationType::EnumMax));
+ NavigatorVibrateHistogram.count(static_cast<NavigatorVibrationType>(vibrateParams));
DCHECK(frame->document());
DCHECK(frame->page());

Powered by Google App Engine
This is Rietveld 408576698