| 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 |
| 11 import org.chromium.base.annotations.CalledByNative; | 11 import org.chromium.base.annotations.CalledByNative; |
| 12 | 12 |
| 13 import java.util.concurrent.Callable; | 13 import java.util.concurrent.Callable; |
| 14 import java.util.concurrent.ExecutionException; | 14 import java.util.concurrent.ExecutionException; |
| 15 import java.util.concurrent.FutureTask; | 15 import java.util.concurrent.FutureTask; |
| 16 | 16 |
| 17 /** | 17 /** |
| 18 * Helper methods to deal with threading related tasks. | 18 * Helper methods to deal with threading related tasks. |
| 19 */ | 19 */ |
| 20 public class ThreadUtils { | 20 public class ThreadUtils { |
| 21 | 21 |
| 22 private static final Object sLock = new Object(); | 22 private static final Object sLock = new Object(); |
| 23 | 23 |
| 24 private static boolean sWillOverride = false; | 24 private static boolean sWillOverride; |
| 25 | 25 |
| 26 private static Handler sUiThreadHandler = null; | 26 private static Handler sUiThreadHandler; |
| 27 | 27 |
| 28 public static void setWillOverrideUiThread() { | 28 public static void setWillOverrideUiThread() { |
| 29 synchronized (sLock) { | 29 synchronized (sLock) { |
| 30 sWillOverride = true; | 30 sWillOverride = true; |
| 31 } | 31 } |
| 32 } | 32 } |
| 33 | 33 |
| 34 @VisibleForTesting | 34 @VisibleForTesting |
| 35 public static void setUiThread(Looper looper) { | 35 public static void setUiThread(Looper looper) { |
| 36 synchronized (sLock) { | 36 synchronized (sLock) { |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after 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 |