• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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   // This value should always be last and is not persisted to logs, exposed only
36   // for testing.
37   MAX_VALUE = WEBVIEW_SCROLLING + 1
38 };
39 
40 // Resolves the above name to a histogram value.
41 BASE_EXPORT const char* GetAndroidFrameTimelineJankHistogramName(
42     JankScenario scenario);
43 // Resolves the above name to a histogram value.
44 BASE_EXPORT const char* GetAndroidFrameTimelineDurationHistogramName(
45     JankScenario scenario);
46 
47 BASE_EXPORT void RecordJankMetrics(
48     JNIEnv* env,
49     const base::android::JavaParamRef<jlongArray>& java_durations_ns,
50     const base::android::JavaParamRef<jintArray>& java_missed_vsyncs,
51     jlong java_reporting_interval_start_time,
52     jlong java_reporting_interval_duration,
53     jint java_scenario_enum);
54 }  // namespace base::android
55 #endif  // BASE_ANDROID_JANK_METRIC_UMA_RECORDER_H_
56