WebWorkers: Add ExecutorToken to route native module calls to/from workers

Summary:To support native modules in web workers, native modules need to have an notion of the JS executor/thread that called into them in order to respond via Callback or JS module call to the right executor on the right thread.

ExecutorToken is an object that only serves as a token that can be used to identify an executor/message queue thread in the bridge. It doesn't expose any methods. Native modules Callback objects automatically have this ExecutionContext attached -- JSModule calls for modules that support workers will need to supply an appropriate ExecutorToken when retrieving the JSModule implementation from the ReactContext.

Reviewed By: mhorowitz

Differential Revision: D2965458

fb-gh-sync-id: 6e354d4df8536d40b12d02bd055f6d06b4ca595d
shipit-source-id: 6e354d4df8536d40b12d02bd055f6d06b4ca595d
This commit is contained in:
Andy Street
2016-03-01 07:57:11 -08:00
committed by Facebook Github Bot 4
parent f67fa82008
commit bd95b22844
26 changed files with 614 additions and 116 deletions

View File

@@ -52,21 +52,21 @@ public class BaseJavaModuleTest {
public void testCallMethodWithoutEnoughArgs() throws Exception {
BaseJavaModule.NativeMethod regularMethod = mMethods.get("regularMethod");
Mockito.stub(mArguments.size()).toReturn(1);
regularMethod.invoke(null, mArguments);
regularMethod.invoke(null, null, mArguments);
}
@Test(expected = NativeArgumentsParseException.class)
public void testCallAsyncMethodWithoutEnoughArgs() throws Exception {
BaseJavaModule.NativeMethod asyncMethod = mMethods.get("asyncMethod");
Mockito.stub(mArguments.size()).toReturn(2);
asyncMethod.invoke(null, mArguments);
asyncMethod.invoke(null, null, mArguments);
}
@Test()
public void testCallAsyncMethodWithEnoughArgs() throws Exception {
BaseJavaModule.NativeMethod asyncMethod = mMethods.get("asyncMethod");
Mockito.stub(mArguments.size()).toReturn(3);
asyncMethod.invoke(null, mArguments);
asyncMethod.invoke(null, null, mArguments);
}
private static class MethodsModule extends BaseJavaModule {