Permalink
Browse files

Update native references to JSTimers

Reviewed By: AaaChiuuu

Differential Revision: D5294997

fbshipit-source-id: 3003d56f744af0c35b1ffef7bdd71617d4f948c3
  • Loading branch information...
javache authored and facebook-github-bot committed Jun 22, 2017
1 parent 0ae11f1 commit d795fa1b2c2eed7b46a759acd1295fce59d47946
@@ -112,7 +112,7 @@ ExceptionsManager.installConsoleErrorReporter();
// TODO: Move these around to solve the cycle in a cleaner way
const BatchedBridge = require('BatchedBridge');
BatchedBridge.registerLazyCallableModule('Systrace', () => require('Systrace'));
BatchedBridge.registerLazyCallableModule('JSTimersExecution', () => require('JSTimers'));
BatchedBridge.registerLazyCallableModule('JSTimers', () => require('JSTimers'));
BatchedBridge.registerLazyCallableModule('HeapCapture', () => require('HeapCapture'));
BatchedBridge.registerLazyCallableModule('SamplingProfiler', () => require('SamplingProfiler'));
BatchedBridge.registerLazyCallableModule('RCTLog', () => require('RCTLog'));
@@ -837,7 +837,7 @@ - (void)_immediatelyCallTimer:(NSNumber *)timer
{
RCTAssertJSThread();
[_javaScriptExecutor executeAsyncBlockOnJavaScriptQueue:^{
[self _actuallyInvokeAndProcessModule:@"JSTimersExecution"
[self _actuallyInvokeAndProcessModule:@"JSTimers"
method:@"callTimers"
arguments:@[@[timer]]];
}];
@@ -1054,7 +1054,7 @@ - (void)_immediatelyCallTimer:(NSNumber *)timer
RCTAssertJSThread();
if (_reactInstance) {
_reactInstance->callJSFunction("JSTimersExecution", "callTimers",
_reactInstance->callJSFunction("JSTimers", "callTimers",
folly::dynamic::array(folly::dynamic::array([timer doubleValue])));
}
}
@@ -17,7 +17,7 @@
static const NSTimeInterval kMinimumSleepInterval = 1;
// These timing contants should be kept in sync with the ones in `JSTimersExecution.js`.
// These timing contants should be kept in sync with the ones in `JSTimers.js`.
// The duration of a frame. This assumes that we want to run at 60 fps.
static const NSTimeInterval kFrameDuration = 1.0 / 60.0;
// The minimum time left in a frame to trigger the idle callback.
@@ -197,7 +197,7 @@ - (void)didUpdateFrame:(RCTFrameUpdate *)update
NSArray<NSNumber *> *sortedTimers = [[timersToCall sortedArrayUsingComparator:^(_RCTTimer *a, _RCTTimer *b) {
return [a.target compare:b.target];
}] valueForKey:@"callbackID"];
[_bridge enqueueJSCall:@"JSTimersExecution"
[_bridge enqueueJSCall:@"JSTimers"
method:@"callTimers"
args:@[sortedTimers]
completion:NULL];
@@ -217,7 +217,7 @@ - (void)didUpdateFrame:(RCTFrameUpdate *)update
if (kFrameDuration - frameElapsed >= kIdleCallbackFrameDeadline) {
NSTimeInterval currentTimestamp = [[NSDate date] timeIntervalSince1970];
NSNumber *absoluteFrameStartMS = @((currentTimestamp - frameElapsed) * 1000);
[_bridge enqueueJSCall:@"JSTimersExecution"
[_bridge enqueueJSCall:@"JSTimers"
method:@"callIdleCallbacks"
args:@[absoluteFrameStartMS]
completion:NULL];
@@ -12,7 +12,7 @@
import com.facebook.react.bridge.JavaScriptModule;
import com.facebook.react.bridge.WritableArray;
public interface JSTimersExecution extends JavaScriptModule {
public interface JSTimers extends JavaScriptModule {
void callTimers(WritableArray timerIDs);
void callIdleCallbacks(double frameTime);
void emitTimeDriftWarning(String warningMessage);
@@ -39,7 +39,7 @@
protected static final String NAME = "Timing";
// These timing contants should be kept in sync with the ones in `JSTimersExecution.js`.
// These timing contants should be kept in sync with the ones in `JSTimers.js`.
// The minimum time in milliseconds left in the frame to call idle callbacks.
private static final float IDLE_CALLBACK_FRAME_DEADLINE_MS = 1.f;
// The total duration of a frame in milliseconds, this assumes that devices run at 60 fps.
@@ -99,7 +99,7 @@ public void doFrame(long frameTimeNanos) {
}
if (mTimersToCall != null) {
getReactApplicationContext().getJSModule(JSTimersExecution.class).callTimers(mTimersToCall);
getReactApplicationContext().getJSModule(JSTimers.class).callTimers(mTimersToCall);
mTimersToCall = null;
}
@@ -157,7 +157,7 @@ public void run() {
}
if (sendIdleEvents) {
getReactApplicationContext().getJSModule(JSTimersExecution.class)
getReactApplicationContext().getJSModule(JSTimers.class)
.callIdleCallbacks(absoluteFrameStartTime);
}
@@ -337,7 +337,7 @@ public void createTimer(
if (mDevSupportManager.getDevSupportEnabled()) {
long driftTime = Math.abs(remoteTime - deviceTime);
if (driftTime > 60000) {
getReactApplicationContext().getJSModule(JSTimersExecution.class)
getReactApplicationContext().getJSModule(JSTimers.class)
.emitTimeDriftWarning(
"Debugger and device times have drifted by more than 60s. Please correct this by " +
"running adb shell \"date `date +%m%d%H%M%Y.%S`\" on your debugger machine.");
@@ -349,7 +349,7 @@ public void createTimer(
if (duration == 0 && !repeat) {
WritableArray timerToCall = Arguments.createArray();
timerToCall.pushInt(callbackID);
getReactApplicationContext().getJSModule(JSTimersExecution.class)
getReactApplicationContext().getJSModule(JSTimers.class)
.callTimers(timerToCall);
return;
}
@@ -16,7 +16,7 @@
import com.facebook.react.devsupport.interfaces.DevSupportManager;
import com.facebook.react.common.SystemClock;
import com.facebook.react.modules.core.ChoreographerCompat;
import com.facebook.react.modules.core.JSTimersExecution;
import com.facebook.react.modules.core.JSTimers;
import com.facebook.react.modules.core.ReactChoreographer;
import com.facebook.react.modules.core.Timing;
@@ -51,7 +51,7 @@
private PostFrameCallbackHandler mPostFrameCallbackHandler;
private PostFrameIdleCallbackHandler mIdlePostFrameCallbackHandler;
private long mCurrentTimeNs;
private JSTimersExecution mJSTimersMock;
private JSTimers mJSTimersMock;
@Rule
public PowerMockRule rule = new PowerMockRule();
@@ -97,8 +97,8 @@ public Object answer(InvocationOnMock invocation) throws Throwable {
any(ChoreographerCompat.FrameCallback.class));
mTiming = new Timing(reactContext, mock(DevSupportManager.class));
mJSTimersMock = mock(JSTimersExecution.class);
when(reactContext.getJSModule(JSTimersExecution.class)).thenReturn(mJSTimersMock);
mJSTimersMock = mock(JSTimers.class);
when(reactContext.getJSModule(JSTimers.class)).thenReturn(mJSTimersMock);
doAnswer(new Answer() {
@Override

0 comments on commit d795fa1

Please sign in to comment.