xref: /aosp_15_r20/external/cronet/base/android/jank_metric_uma_recorder.h (revision 6777b5387eb2ff775bb5750e3f5d96f37fb7352b)
1 // Copyright 2023 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef BASE_ANDROID_JANK_METRIC_UMA_RECORDER_H_
6 #define BASE_ANDROID_JANK_METRIC_UMA_RECORDER_H_
7 
8 #include "base/android/jni_android.h"
9 #include "base/base_export.h"
10 #include "base/feature_list.h"
11 
12 namespace base::android {
13 
14 // These values are persisted to logs. Entries should not be renumbered and
15 // numeric values should never be reused.
16 enum class FrameJankStatus {
17   kJanky = 0,
18   kNonJanky = 1,
19   kMaxValue = kNonJanky,
20 };
21 
22 // These values are persisted to logs. Entries should not be renumbered and
23 // numeric values should never be reused.
24 enum class JankScenario {
25   PERIODIC_REPORTING = 1,
26   OMNIBOX_FOCUS = 2,
27   NEW_TAB_PAGE = 3,
28   STARTUP = 4,
29   TAB_SWITCHER = 5,
30   OPEN_LINK_IN_NEW_TAB = 6,
31   START_SURFACE_HOMEPAGE = 7,
32   START_SURFACE_TAB_SWITCHER = 8,
33   FEED_SCROLLING = 9,
34   WEBVIEW_SCROLLING = 10,
35   COMBINED_WEBVIEW_SCROLLING = 11,
36   // This value should always be last and is not persisted to logs, exposed only
37   // for testing.
38   MAX_VALUE = COMBINED_WEBVIEW_SCROLLING + 1
39 };
40 
41 // Resolves the above name to a histogram value.
42 BASE_EXPORT const char* GetAndroidFrameTimelineJankHistogramName(
43     JankScenario scenario);
44 // Resolves the above name to a histogram value.
45 BASE_EXPORT const char* GetAndroidFrameTimelineDurationHistogramName(
46     JankScenario scenario);
47 
48 BASE_EXPORT void RecordJankMetrics(
49     JNIEnv* env,
50     const base::android::JavaParamRef<jlongArray>& java_durations_ns,
51     const base::android::JavaParamRef<jintArray>& java_missed_vsyncs,
52     jlong java_reporting_interval_start_time,
53     jlong java_reporting_interval_duration,
54     jint java_scenario_enum);
55 }  // namespace base::android
56 #endif  // BASE_ANDROID_JANK_METRIC_UMA_RECORDER_H_
57