Backed out changeset 2450366cf7ca (bug 1891629) for causing win msix mochitest failures
[gecko.git] / dom / base / ScrollingMetrics.h
blob081c38d06911ae33f01c1b6e8a81c60ecdc04eca
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
10 #include "Units.h"
11 #include "mozilla/MozPromise.h"
12 #include "mozilla/RefPtr.h"
13 #include "mozilla/StaticPtr.h"
15 namespace mozilla {
17 /**
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 {
23 public:
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();
42 private:
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 */