1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef mozilla_dom_ScrollingMetrics_h
8 #define mozilla_dom_ScrollingMetrics_h
11 #include "mozilla/MozPromise.h"
12 #include "mozilla/RefPtr.h"
13 #include "mozilla/StaticPtr.h"
18 * ScrollingMetrics records user-intiated scrolling interactions. These are
19 * aggregrated along with other user interactions (e.g. typing, view time), in
20 * the history metadata.
22 class ScrollingMetrics
{
24 using ScrollingMetricsPromise
=
25 MozPromise
<std::tuple
<uint32_t, uint32_t>, bool, true>;
27 static RefPtr
<ScrollingMetricsPromise
> CollectScrollingMetrics() {
28 return GetSingleton()->CollectScrollingMetricsInternal();
31 // Return the tuple of <scrollingTimeInMilliseconds,
32 // ScrollingDistanceInPixels>
33 static std::tuple
<uint32_t, uint32_t> CollectLocalScrollingMetrics() {
34 return GetSingleton()->CollectLocalScrollingMetricsInternal();
37 // Report a new user-initiated scrolling interaction
38 static void OnScrollingInteraction(CSSCoord distanceScrolled
);
40 static void OnScrollingInteractionEnded();
43 static ScrollingMetrics
* GetSingleton();
44 static StaticAutoPtr
<ScrollingMetrics
> sSingleton
;
45 RefPtr
<ScrollingMetricsPromise
> CollectScrollingMetricsInternal();
46 std::tuple
<uint32_t, uint32_t> CollectLocalScrollingMetricsInternal();
49 } // namespace mozilla
51 #endif /* mozilla_dom_ScrollingMetrics_h */