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

Side by Side 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: 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 unified diff | Download patch
« no previous file with comments | « no previous file | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Samsung Electronics 2 * Copyright (C) 2012 Samsung Electronics
3 * 3 *
4 * This library is free software; you can redistribute it and/or 4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public 5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either 6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version. 7 * version 2 of the License, or (at your option) any later version.
8 * 8 *
9 * This library is distributed in the hope that it will be useful, 9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details. 12 * Library General Public License for more details.
13 * 13 *
14 * You should have received a copy of the GNU Library General Public License 14 * You should have received a copy of the GNU Library General Public License
15 * along with this library; see the file COPYING.LIB. If not, write to 15 * along with this library; see the file COPYING.LIB. If not, write to
16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA. 17 * Boston, MA 02110-1301, USA.
18 */ 18 */
19 19
20 #include "modules/vibration/NavigatorVibration.h" 20 #include "modules/vibration/NavigatorVibration.h"
21 21
22 #include "core/frame/LocalFrame.h" 22 #include "core/frame/LocalFrame.h"
23 #include "core/frame/Navigator.h" 23 #include "core/frame/Navigator.h"
24 #include "core/frame/UseCounter.h" 24 #include "core/frame/UseCounter.h"
25 #include "core/page/Page.h" 25 #include "core/page/Page.h"
26 #include "modules/vibration/VibrationController.h" 26 #include "modules/vibration/VibrationController.h"
27 #include "platform/Histogram.h"
28 #include "platform/UserGestureIndicator.h"
27 29
28 namespace blink { 30 namespace blink {
29 31
30 NavigatorVibration::NavigatorVibration(Navigator& navigator) 32 NavigatorVibration::NavigatorVibration(Navigator& navigator)
31 : DOMWindowProperty(navigator.frame()) 33 : DOMWindowProperty(navigator.frame())
32 { 34 {
33 } 35 }
34 36
35 NavigatorVibration::~NavigatorVibration() 37 NavigatorVibration::~NavigatorVibration()
36 { 38 {
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 UseCounter::count(frame, UseCounter::NavigatorVibrate); 76 UseCounter::count(frame, UseCounter::NavigatorVibrate);
75 if (!frame->isMainFrame()) 77 if (!frame->isMainFrame())
76 UseCounter::count(frame, UseCounter::NavigatorVibrateSubFrame); 78 UseCounter::count(frame, UseCounter::NavigatorVibrateSubFrame);
77 79
78 DCHECK(frame->document()); 80 DCHECK(frame->document());
79 DCHECK(frame->page()); 81 DCHECK(frame->page());
80 82
81 if (!frame->page()->isPageVisible()) 83 if (!frame->page()->isPageVisible())
82 return false; 84 return false;
83 85
86 if (frame->isCrossOrigin()) {
Michael van Ouwerkerk 2016/06/20 13:00:01 Recording whether a user gesture is present would
87 DEFINE_STATIC_LOCAL(EnumerationHistogram, crossOriginVibrateHistogram, ( "WebModules.CrossOriginVibrate", 2));
88 crossOriginVibrateHistogram.count(UserGestureIndicator::processingUserGe sture() ? 1 : 0);
Michael van Ouwerkerk 2016/06/20 13:00:01 To make the data consistent with the use counters
89 }
mlamouri (slow - plz ping) 2016/06/20 10:39:20 Would that make sense to integrate with the Naviga
ojan 2016/06/20 14:04:09 I didn't realize we had NavigatorVibrateSubFrame a
90
84 return NavigatorVibration::from(navigator).controller()->vibrate(pattern); 91 return NavigatorVibration::from(navigator).controller()->vibrate(pattern);
85 } 92 }
86 93
87 VibrationController* NavigatorVibration::controller() 94 VibrationController* NavigatorVibration::controller()
88 { 95 {
89 if (!m_controller && frame()) 96 if (!m_controller && frame())
90 m_controller = new VibrationController(*frame()->document()); 97 m_controller = new VibrationController(*frame()->document());
91 98
92 return m_controller.get(); 99 return m_controller.get();
93 } 100 }
94 101
95 void NavigatorVibration::willDetachGlobalObjectFromFrame() 102 void NavigatorVibration::willDetachGlobalObjectFromFrame()
96 { 103 {
97 if (m_controller) { 104 if (m_controller) {
98 m_controller->cancel(); 105 m_controller->cancel();
99 m_controller = nullptr; 106 m_controller = nullptr;
100 } 107 }
101 } 108 }
102 109
103 DEFINE_TRACE(NavigatorVibration) 110 DEFINE_TRACE(NavigatorVibration)
104 { 111 {
105 visitor->trace(m_controller); 112 visitor->trace(m_controller);
106 Supplement<Navigator>::trace(visitor); 113 Supplement<Navigator>::trace(visitor);
107 DOMWindowProperty::trace(visitor); 114 DOMWindowProperty::trace(visitor);
108 } 115 }
109 116
110 } // namespace blink 117 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698