| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package org.chromium.base; | 5 package org.chromium.base; |
| 6 | 6 |
| 7 import android.os.Handler; | 7 import android.os.Handler; |
| 8 import android.os.Looper; | 8 import android.os.Looper; |
| 9 import android.os.Process; | 9 import android.os.Process; |
| 10 | 10 |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 */ | 182 */ |
| 183 @VisibleForTesting | 183 @VisibleForTesting |
| 184 public static void postOnUiThreadDelayed(Runnable task, long delayMillis) { | 184 public static void postOnUiThreadDelayed(Runnable task, long delayMillis) { |
| 185 getUiThreadHandler().postDelayed(task, delayMillis); | 185 getUiThreadHandler().postDelayed(task, delayMillis); |
| 186 } | 186 } |
| 187 | 187 |
| 188 /** | 188 /** |
| 189 * Asserts that the current thread is running on the main thread. | 189 * Asserts that the current thread is running on the main thread. |
| 190 */ | 190 */ |
| 191 public static void assertOnUiThread() { | 191 public static void assertOnUiThread() { |
| 192 if (BuildConfig.IS_DEBUG && !runningOnUiThread()) { | 192 if (BuildConfig.DCHECK_IS_ON && !runningOnUiThread()) { |
| 193 throw new IllegalStateException("Must be called on the Ui thread."); | 193 throw new IllegalStateException("Must be called on the Ui thread."); |
| 194 } | 194 } |
| 195 } | 195 } |
| 196 | 196 |
| 197 /** | 197 /** |
| 198 * @return true iff the current thread is the main (UI) thread. | 198 * @return true iff the current thread is the main (UI) thread. |
| 199 */ | 199 */ |
| 200 public static boolean runningOnUiThread() { | 200 public static boolean runningOnUiThread() { |
| 201 return getUiThreadHandler().getLooper() == Looper.myLooper(); | 201 return getUiThreadHandler().getLooper() == Looper.myLooper(); |
| 202 } | 202 } |
| (...skipping 13 matching lines...) Expand all Loading... |
| 216 /** | 216 /** |
| 217 * Checks whether Thread priority is THREAD_PRIORITY_AUDIO or not. | 217 * Checks whether Thread priority is THREAD_PRIORITY_AUDIO or not. |
| 218 * @param tid Thread id. | 218 * @param tid Thread id. |
| 219 * @return true for THREAD_PRIORITY_AUDIO and false otherwise. | 219 * @return true for THREAD_PRIORITY_AUDIO and false otherwise. |
| 220 */ | 220 */ |
| 221 @CalledByNative | 221 @CalledByNative |
| 222 private static boolean isThreadPriorityAudio(int tid) { | 222 private static boolean isThreadPriorityAudio(int tid) { |
| 223 return Process.getThreadPriority(tid) == Process.THREAD_PRIORITY_AUDIO; | 223 return Process.getThreadPriority(tid) == Process.THREAD_PRIORITY_AUDIO; |
| 224 } | 224 } |
| 225 } | 225 } |
| OLD | NEW |