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); |
klobag.chromium
2013/06/28 20:57:13
nativeDoRunLoopOnce will do one normal, one delaye
Kristian Monsen
2013/06/28 21:04:41
Yes, I am aware of this. But not sure how to handl
klobag.chromium
2013/06/28 21:55:23
I am afraid that will delay PostDelayedTask().
Ca
Kristian Monsen
2013/06/28 22:48:57
Do you want a separate native method handling the
klobag.chromium
2013/06/28 23:18:12
Yes. So it is almost 1:1. Normal calls normal, del
Kristian Monsen
2013/06/28 23:43:05
I will implement this and test in the weekend.
joth
2013/07/01 19:28:54
What if nativeDoRunLoopOnce() returns true?
Kristian Monsen
2013/07/02 21:32:27
That is not important with the current implementat
Kristian Monsen
2013/07/02 21:32:27
I tested this, and I don't think it is optimal for
klobag.chromium
2013/07/02 22:53:02
Took another look, now wondering whether this chan
Kristian Monsen
2013/07/02 23:05:29
That is sort of the problem with sharing the messa
|
} |
+ @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); |
aberent
2013/06/28 21:52:28
The current (mTimerFired) code only allows one nor
boliu
2013/06/28 22:32:06
The motivation for this change is that in android
klobag.chromium
2013/06/28 23:18:12
I am not surprised that it is bad in the webview a
|
} |
- // 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 |