Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3053)

Unified Diff: base/android/java/src/org/chromium/base/SystemMessageHandler.java

Issue 18181011: Make a fairer combined message loop (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: caching the result from MessagePump::NeedsScheduleWorkPerTask Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | base/message_loop/message_loop.h » ('j') | base/message_loop/message_loop.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/android/java/src/org/chromium/base/SystemMessageHandler.java
diff --git a/base/android/java/src/org/chromium/base/SystemMessageHandler.java b/base/android/java/src/org/chromium/base/SystemMessageHandler.java
index f7bb19f19e4e322c8dec3f281263368a2ece3983..6dca2a84f65aa67b44984627777909109e328902 100644
--- a/base/android/java/src/org/chromium/base/SystemMessageHandler.java
+++ b/base/android/java/src/org/chromium/base/SystemMessageHandler.java
@@ -13,75 +13,35 @@ import java.util.concurrent.atomic.AtomicBoolean;
class SystemMessageHandler extends Handler {
private static final int TIMER_MESSAGE = 1;
- private static final int DELAYED_TIMER_MESSAGE = 2;
// Native class pointer set by the constructor of the SharedClient native class.
private int mMessagePumpDelegateNative = 0;
- // Used to ensure we have at most one TIMER_MESSAGE pending at once.
- private AtomicBoolean mTimerFired = new AtomicBoolean(true);
-
- // Used to insert TIMER_MESSAGE on the front of the system message queue during startup only.
- // This is a wee hack, to give a priority boost to native tasks during startup as they tend to
- // be on the critical path. (After startup, handling the UI with minimum latency is more
- // important).
- private boolean mStartupComplete = false;
- private final long mStartupCompleteTime = System.currentTimeMillis() + 2000;
- private final boolean startupComplete() {
- if (!mStartupComplete && System.currentTimeMillis() > mStartupCompleteTime) {
- mStartupComplete = true;
- }
- return mStartupComplete;
- }
-
private SystemMessageHandler(int messagePumpDelegateNative) {
mMessagePumpDelegateNative = messagePumpDelegateNative;
}
@Override
public void handleMessage(Message msg) {
- if (msg.what == TIMER_MESSAGE) {
- mTimerFired.set(true);
- }
- while (nativeDoRunLoopOnce(mMessagePumpDelegateNative)) {
- if (startupComplete()) {
- setTimer();
- break;
- }
- }
+ nativeDoRunLoopOnce(mMessagePumpDelegateNative);
}
+ @SuppressWarnings("unused")
@CalledByNative
private void setTimer() {
- if (!mTimerFired.getAndSet(false)) {
- // mTimerFired was already false.
- return;
- }
- if (startupComplete()) {
- sendEmptyMessage(TIMER_MESSAGE);
- } else {
- sendMessageAtFrontOfQueue(obtainMessage(TIMER_MESSAGE));
- }
+ sendEmptyMessage(TIMER_MESSAGE);
}
- // If millis <=0, it'll send a TIMER_MESSAGE instead of
- // a DELAYED_TIMER_MESSAGE.
@SuppressWarnings("unused")
@CalledByNative
private void setDelayedTimer(long millis) {
- if (millis <= 0) {
- setTimer();
- } else {
- removeMessages(DELAYED_TIMER_MESSAGE);
- sendEmptyMessageDelayed(DELAYED_TIMER_MESSAGE, millis);
- }
+ sendEmptyMessageDelayed(TIMER_MESSAGE, millis);
}
@SuppressWarnings("unused")
@CalledByNative
private void removeTimer() {
removeMessages(TIMER_MESSAGE);
- removeMessages(DELAYED_TIMER_MESSAGE);
}
@CalledByNative
« no previous file with comments | « no previous file | base/message_loop/message_loop.h » ('j') | base/message_loop/message_loop.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698