File tree Expand file tree Collapse file tree 5 files changed +11
-33
lines changed
java/src/org/chromium/base
chrome/android/expectations
components/cronet/android Expand file tree Collapse file tree 5 files changed +11
-33
lines changed Original file line number Diff line number Diff line change 12
12
13
13
import org .chromium .base .task .PostTask ;
14
14
import org .chromium .base .task .TaskTraits ;
15
- import org .chromium .build .BuildConfig ;
16
15
17
16
import java .util .concurrent .Callable ;
18
17
import java .util .concurrent .ExecutionException ;
@@ -33,8 +32,9 @@ public class ThreadUtils {
33
32
* A helper object to ensure that interactions with a particular object only happens on a
34
33
* particular thread.
35
34
*
36
- * <pre>Example:
37
- *
35
+ * Example:
36
+ * <pre>
37
+ * {@code
38
38
* class Foo {
39
39
* // Valid thread is set during construction here.
40
40
* private final ThreadChecker mThreadChecker = new ThreadChecker();
@@ -43,19 +43,11 @@ public class ThreadUtils {
43
43
* mThreadChecker.assertOnValidThread();
44
44
* }
45
45
* }
46
+ * }
46
47
* </pre>
47
48
*/
48
- // TODO(b/274802355): Add @CheckDiscard once R8 can remove this.
49
49
public static class ThreadChecker {
50
- private long mThreadId ;
51
-
52
- public ThreadChecker () {
53
- resetThreadId ();
54
- }
55
-
56
- public void resetThreadId () {
57
- mThreadId = BuildConfig .ENABLE_ASSERTS ? Process .myTid () : 0 ;
58
- }
50
+ private final long mThreadId = Process .myTid ();
59
51
60
52
/**
61
53
* Asserts that the current thread is the same as the one the ThreadChecker was constructed
Original file line number Diff line number Diff line change 18
18
* This class stores relevant metrics from FrameMetrics between the calls to UMA reporting methods.
19
19
*/
20
20
public class FrameMetricsStore {
21
- private final ThreadChecker mThreadChecker = new ThreadChecker ();
21
+ // FrameMetricsStore can only be accessed on the handler thread (from the
22
+ // JankReportingScheduler.getOrCreateHandler() method). However construction occurs on a
23
+ // separate thread so the ThreadChecker is instead constructed later.
24
+ private ThreadChecker mThreadChecker ;
22
25
// An arbitrary value from which to create a trace event async track. The only risk if this
23
26
// clashes with another track is trace events will show up on both potentially looking weird in
24
27
// the tracing UI. No other issue will occur.
@@ -85,10 +88,8 @@ public static String scenarioToString(@JankScenario.Type int scenario) {
85
88
* checking.
86
89
*/
87
90
void initialize () {
88
- // FrameMetricsStore can only be accessed on the handler thread (from the
89
- // JankReportingScheduler.getOrCreateHandler() method). However construction occurs on a
90
- // separate thread so the ThreadChecker is instead constructed later.
91
- mThreadChecker .resetThreadId ();
91
+ assert mThreadChecker == null ;
92
+ mThreadChecker = new ThreadChecker ();
92
93
}
93
94
94
95
/** Records the total draw duration and jankiness for a single frame. */
Original file line number Diff line number Diff line change 43
43
<init>();
44
44
}
45
45
46
- # Required to remove fields until b/274802355 is resolved.
47
- -assumevalues class !cr_allowunused,** {
48
- final org.chromium.base.ThreadUtils$ThreadChecker * return _NONNULL_;
49
- }
50
-
51
46
# TODO(agrieve): Remove once we start to use Android U SDK.
52
47
-dontwarn android.window.BackEvent
53
48
-dontwarn android.window.OnBackAnimationCallback
Original file line number Diff line number Diff line change 252
252
<init>();
253
253
}
254
254
255
- # Required to remove fields until b/274802355 is resolved.
256
- -assumevalues class !cr_allowunused,** {
257
- final org.chromium.base.ThreadUtils$ThreadChecker * return _NONNULL_;
258
- }
259
-
260
255
# TODO(agrieve): Remove once we start to use Android U SDK.
261
256
-dontwarn android.window.BackEvent
262
257
-dontwarn android.window.OnBackAnimationCallback
Original file line number Diff line number Diff line change 44
44
<init>();
45
45
}
46
46
47
- # Required to remove fields until b/274802355 is resolved.
48
- -assumevalues class !cr_allowunused,** {
49
- final org.chromium.base.ThreadUtils$ThreadChecker * return _NONNULL_;
50
- }
51
-
52
47
# TODO(agrieve): Remove once we start to use Android U SDK.
53
48
-dontwarn android.window.BackEvent
54
49
-dontwarn android.window.OnBackAnimationCallback
You can’t perform that action at this time.
0 commit comments