| 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 11 matching lines...) Expand all Loading... |
| 22 private static boolean sWillOverride = false; | 22 private static boolean sWillOverride = false; |
| 23 | 23 |
| 24 private static Handler sUiThreadHandler = null; | 24 private static Handler sUiThreadHandler = null; |
| 25 | 25 |
| 26 public static void setWillOverrideUiThread() { | 26 public static void setWillOverrideUiThread() { |
| 27 synchronized (sLock) { | 27 synchronized (sLock) { |
| 28 sWillOverride = true; | 28 sWillOverride = true; |
| 29 } | 29 } |
| 30 } | 30 } |
| 31 | 31 |
| 32 @VisibleForTesting |
| 32 public static void setUiThread(Looper looper) { | 33 public static void setUiThread(Looper looper) { |
| 33 synchronized (sLock) { | 34 synchronized (sLock) { |
| 34 if (sUiThreadHandler != null && sUiThreadHandler.getLooper() != loop
er) { | 35 if (sUiThreadHandler != null && sUiThreadHandler.getLooper() != loop
er) { |
| 35 throw new RuntimeException("UI thread looper is already set to " | 36 throw new RuntimeException("UI thread looper is already set to " |
| 36 + sUiThreadHandler.getLooper() + " (Main thread looper i
s " | 37 + sUiThreadHandler.getLooper() + " (Main thread looper i
s " |
| 37 + Looper.getMainLooper() + "), cannot set to new looper
" + looper); | 38 + Looper.getMainLooper() + "), cannot set to new looper
" + looper); |
| 38 } else { | 39 } else { |
| 39 sUiThreadHandler = new Handler(looper); | 40 sUiThreadHandler = new Handler(looper); |
| 40 } | 41 } |
| 41 } | 42 } |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 } | 201 } |
| 201 | 202 |
| 202 /** | 203 /** |
| 203 * Set thread priority to audio. | 204 * Set thread priority to audio. |
| 204 */ | 205 */ |
| 205 @CalledByNative | 206 @CalledByNative |
| 206 public static void setThreadPriorityAudio(int tid) { | 207 public static void setThreadPriorityAudio(int tid) { |
| 207 Process.setThreadPriority(tid, Process.THREAD_PRIORITY_AUDIO); | 208 Process.setThreadPriority(tid, Process.THREAD_PRIORITY_AUDIO); |
| 208 } | 209 } |
| 209 } | 210 } |
| OLD | NEW |