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.annotation.SuppressLint; | 7 import android.annotation.SuppressLint; |
8 import android.os.Build; | 8 import android.os.Build; |
9 import android.os.Handler; | 9 import android.os.Handler; |
10 import android.os.Message; | 10 import android.os.Message; |
11 | 11 |
12 import org.chromium.base.annotations.CalledByNative; | 12 import org.chromium.base.annotations.CalledByNative; |
13 import org.chromium.base.annotations.MainDex; | 13 import org.chromium.base.annotations.MainDex; |
14 | 14 |
15 import java.lang.reflect.InvocationTargetException; | 15 import java.lang.reflect.InvocationTargetException; |
16 import java.lang.reflect.Method; | 16 import java.lang.reflect.Method; |
17 | 17 |
18 @MainDex | 18 @MainDex |
19 class SystemMessageHandler extends Handler { | 19 class SystemMessageHandler extends Handler { |
20 | 20 |
21 private static final String TAG = "cr.SysMessageHandler"; | 21 private static final String TAG = "cr.SysMessageHandler"; |
22 | 22 |
23 private static final int SCHEDULED_WORK = 1; | 23 private static final int SCHEDULED_WORK = 1; |
24 private static final int DELAYED_SCHEDULED_WORK = 2; | 24 private static final int DELAYED_SCHEDULED_WORK = 2; |
25 | 25 |
26 // Native class pointer set by the constructor of the SharedClient native cl ass. | 26 // Native class pointer set by the constructor of the SharedClient native cl ass. |
27 private long mMessagePumpDelegateNative = 0; | 27 private long mMessagePumpDelegateNative = 0; |
28 private long mMessagePumpNative = 0; | |
28 private long mDelayedScheduledTimeTicks = 0; | 29 private long mDelayedScheduledTimeTicks = 0; |
29 | 30 |
30 private SystemMessageHandler(long messagePumpDelegateNative) { | 31 protected SystemMessageHandler(long messagePumpDelegateNative, long messageP umpNative) { |
31 mMessagePumpDelegateNative = messagePumpDelegateNative; | 32 mMessagePumpDelegateNative = messagePumpDelegateNative; |
33 mMessagePumpNative = messagePumpNative; | |
32 } | 34 } |
33 | 35 |
34 @Override | 36 @Override |
35 public void handleMessage(Message msg) { | 37 public void handleMessage(Message msg) { |
36 if (msg.what == DELAYED_SCHEDULED_WORK) { | 38 if (msg.what == DELAYED_SCHEDULED_WORK) { |
37 mDelayedScheduledTimeTicks = 0; | 39 mDelayedScheduledTimeTicks = 0; |
38 } | 40 } |
39 nativeDoRunLoopOnce(mMessagePumpDelegateNative, mDelayedScheduledTimeTic ks); | 41 nativeDoRunLoopOnce( |
42 mMessagePumpDelegateNative, mMessagePumpNative, mDelayedSchedule dTimeTicks); | |
43 } | |
44 | |
45 protected long getMessagePumpNative() { | |
gsennton
2016/08/16 15:27:36
Ooops, will remove this.
gsennton
2016/08/17 17:05:47
Done.
| |
46 return mMessagePumpNative; | |
40 } | 47 } |
41 | 48 |
42 @SuppressWarnings("unused") | 49 @SuppressWarnings("unused") |
43 @CalledByNative | 50 @CalledByNative |
44 private void scheduleWork() { | 51 private void scheduleWork() { |
45 sendMessage(obtainAsyncMessage(SCHEDULED_WORK)); | 52 sendMessage(obtainAsyncMessage(SCHEDULED_WORK)); |
46 } | 53 } |
47 | 54 |
48 @SuppressWarnings("unused") | 55 @SuppressWarnings("unused") |
49 @CalledByNative | 56 @CalledByNative |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
146 mMessageMethodSetAsynchronous = null; | 153 mMessageMethodSetAsynchronous = null; |
147 } catch (RuntimeException e) { | 154 } catch (RuntimeException e) { |
148 Log.e(TAG, "Runtime exception during async message creation, disabling."); | 155 Log.e(TAG, "Runtime exception during async message creation, disabling."); |
149 mMessageMethodSetAsynchronous = null; | 156 mMessageMethodSetAsynchronous = null; |
150 } | 157 } |
151 } | 158 } |
152 } | 159 } |
153 } | 160 } |
154 | 161 |
155 @CalledByNative | 162 @CalledByNative |
156 private static SystemMessageHandler create(long messagePumpDelegateNative) { | 163 private static SystemMessageHandler create( |
157 return new SystemMessageHandler(messagePumpDelegateNative); | 164 long messagePumpDelegateNative, long messagePumpNative) { |
165 return new SystemMessageHandler(messagePumpDelegateNative, messagePumpNa tive); | |
158 } | 166 } |
159 | 167 |
160 private native void nativeDoRunLoopOnce( | 168 private native void nativeDoRunLoopOnce( |
161 long messagePumpDelegateNative, long delayedScheduledTimeTicks); | 169 long messagePumpDelegateNative, long messagePumpNative, long delayed ScheduledTimeTicks); |
162 } | 170 } |
OLD | NEW |