diff --git a/base/android/java/src/org/chromium/base/ThreadUtils.java b/base/android/java/src/org/chromium/base/ThreadUtils.java index 8dfe3ea5d53475..d4fdbcf42a8227 100644 --- a/base/android/java/src/org/chromium/base/ThreadUtils.java +++ b/base/android/java/src/org/chromium/base/ThreadUtils.java @@ -12,7 +12,6 @@ import org.chromium.base.task.PostTask; import org.chromium.base.task.TaskTraits; -import org.chromium.build.BuildConfig; import java.util.concurrent.Callable; import java.util.concurrent.ExecutionException; @@ -33,8 +32,9 @@ public class ThreadUtils { * A helper object to ensure that interactions with a particular object only happens on a * particular thread. * - *
Example: - * + * Example: + *+ * {@code * class Foo { * // Valid thread is set during construction here. * private final ThreadChecker mThreadChecker = new ThreadChecker(); @@ -43,19 +43,11 @@ public class ThreadUtils { * mThreadChecker.assertOnValidThread(); * } * } + * } **/ - // TODO(b/274802355): Add @CheckDiscard once R8 can remove this. public static class ThreadChecker { - private long mThreadId; - - public ThreadChecker() { - resetThreadId(); - } - - public void resetThreadId() { - mThreadId = BuildConfig.ENABLE_ASSERTS ? Process.myTid() : 0; - } + private final long mThreadId = Process.myTid(); /** * Asserts that the current thread is the same as the one the ThreadChecker was constructed diff --git a/base/android/java/src/org/chromium/base/jank_tracker/FrameMetricsStore.java b/base/android/java/src/org/chromium/base/jank_tracker/FrameMetricsStore.java index f87d88edd414bb..e4e182cdb3d32b 100644 --- a/base/android/java/src/org/chromium/base/jank_tracker/FrameMetricsStore.java +++ b/base/android/java/src/org/chromium/base/jank_tracker/FrameMetricsStore.java @@ -18,7 +18,10 @@ * This class stores relevant metrics from FrameMetrics between the calls to UMA reporting methods. */ public class FrameMetricsStore { - private final ThreadChecker mThreadChecker = new ThreadChecker(); + // FrameMetricsStore can only be accessed on the handler thread (from the + // JankReportingScheduler.getOrCreateHandler() method). However construction occurs on a + // separate thread so the ThreadChecker is instead constructed later. + private ThreadChecker mThreadChecker; // An arbitrary value from which to create a trace event async track. The only risk if this // clashes with another track is trace events will show up on both potentially looking weird in // the tracing UI. No other issue will occur. @@ -85,10 +88,8 @@ public static String scenarioToString(@JankScenario.Type int scenario) { * checking. */ void initialize() { - // FrameMetricsStore can only be accessed on the handler thread (from the - // JankReportingScheduler.getOrCreateHandler() method). However construction occurs on a - // separate thread so the ThreadChecker is instead constructed later. - mThreadChecker.resetThreadId(); + assert mThreadChecker == null; + mThreadChecker = new ThreadChecker(); } /** Records the total draw duration and jankiness for a single frame. */ diff --git a/base/android/proguard/chromium_code.flags b/base/android/proguard/chromium_code.flags index e417fbaaa59eba..6393108051d330 100644 --- a/base/android/proguard/chromium_code.flags +++ b/base/android/proguard/chromium_code.flags @@ -43,11 +43,6 @@(); } -# Required to remove fields until b/274802355 is resolved. --assumevalues class !cr_allowunused,** { - final org.chromium.base.ThreadUtils$ThreadChecker * return _NONNULL_; -} - # TODO(agrieve): Remove once we start to use Android U SDK. -dontwarn android.window.BackEvent -dontwarn android.window.OnBackAnimationCallback diff --git a/chrome/android/expectations/monochrome_64_32_public_bundle.proguard_flags.expected b/chrome/android/expectations/monochrome_64_32_public_bundle.proguard_flags.expected index 24f6c31cedb671..c1e055cdb08d8b 100644 --- a/chrome/android/expectations/monochrome_64_32_public_bundle.proguard_flags.expected +++ b/chrome/android/expectations/monochrome_64_32_public_bundle.proguard_flags.expected @@ -252,11 +252,6 @@ (); } -# Required to remove fields until b/274802355 is resolved. --assumevalues class !cr_allowunused,** { - final org.chromium.base.ThreadUtils$ThreadChecker * return _NONNULL_; -} - # TODO(agrieve): Remove once we start to use Android U SDK. -dontwarn android.window.BackEvent -dontwarn android.window.OnBackAnimationCallback diff --git a/components/cronet/android/cronet_combined_impl_native_proguard_golden.cfg b/components/cronet/android/cronet_combined_impl_native_proguard_golden.cfg index f2737579aa6853..11890807a5530d 100644 --- a/components/cronet/android/cronet_combined_impl_native_proguard_golden.cfg +++ b/components/cronet/android/cronet_combined_impl_native_proguard_golden.cfg @@ -44,11 +44,6 @@ (); } -# Required to remove fields until b/274802355 is resolved. --assumevalues class !cr_allowunused,** { - final org.chromium.base.ThreadUtils$ThreadChecker * return _NONNULL_; -} - # TODO(agrieve): Remove once we start to use Android U SDK. -dontwarn android.window.BackEvent -dontwarn android.window.OnBackAnimationCallback