Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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 d795fa1
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion Libraries/Core/InitializeCore.js
Expand Up @@ -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'));
Expand Down
2 changes: 1 addition & 1 deletion React/Base/RCTBatchedBridge.mm
Expand Up @@ -837,7 +837,7 @@ - (void)_immediatelyCallTimer:(NSNumber *)timer
{
RCTAssertJSThread();
[_javaScriptExecutor executeAsyncBlockOnJavaScriptQueue:^{
[self _actuallyInvokeAndProcessModule:@"JSTimersExecution"
[self _actuallyInvokeAndProcessModule:@"JSTimers"
method:@"callTimers"
arguments:@[@[timer]]];
}];
Expand Down
2 changes: 1 addition & 1 deletion React/CxxBridge/RCTCxxBridge.mm
Expand Up @@ -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])));
}
}
Expand Down
6 changes: 3 additions & 3 deletions React/Modules/RCTTiming.m
Expand Up @@ -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.
Expand Down Expand Up @@ -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];
Expand All @@ -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];
Expand Down
Expand Up @@ -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);
Expand Down
Expand Up @@ -39,7 +39,7 @@ public final class Timing extends ReactContextBaseJavaModule implements Lifecycl

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.
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -157,7 +157,7 @@ public void run() {
}

if (sendIdleEvents) {
getReactApplicationContext().getJSModule(JSTimersExecution.class)
getReactApplicationContext().getJSModule(JSTimers.class)
.callIdleCallbacks(absoluteFrameStartTime);
}

Expand Down Expand Up @@ -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.");
Expand All @@ -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;
}
Expand Down
Expand Up @@ -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;

Expand Down Expand Up @@ -51,7 +51,7 @@ public class TimingModuleTest {
private PostFrameCallbackHandler mPostFrameCallbackHandler;
private PostFrameIdleCallbackHandler mIdlePostFrameCallbackHandler;
private long mCurrentTimeNs;
private JSTimersExecution mJSTimersMock;
private JSTimers mJSTimersMock;

@Rule
public PowerMockRule rule = new PowerMockRule();
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit d795fa1

Please sign in to comment.