Skip to content

Commit

Permalink
clean up ModuleHolder.java
Browse files Browse the repository at this point in the history
Reviewed By: achen1

Differential Revision: D4548524

fbshipit-source-id: 5fab273e7a461c0312fa555aaccb8869843d9d95
  • Loading branch information
aaronechiu authored and facebook-github-bot committed Feb 14, 2017
1 parent 7880179 commit 7c82803
Showing 1 changed file with 6 additions and 15 deletions.
Expand Up @@ -48,7 +48,7 @@ public ModuleHolder(
mSupportsWebWorkers = supportsWebWorkers;
mProvider = provider;
if (needsEagerInit) {
mModule = doCreate();
mModule = create();
}
}

Expand Down Expand Up @@ -91,34 +91,25 @@ public boolean getSupportsWebWorkers() {

public synchronized NativeModule getModule() {
if (mModule == null) {
mModule = doCreate();
mModule = create();
}
return mModule;
}

private NativeModule doCreate() {
NativeModule module = create();
mProvider = null;
return module;
}

private NativeModule create() {
boolean isEagerModule = mModule != null;
if (!isEagerModule) {
ReactMarker.logMarker(CREATE_MODULE_START, mName);
}
SoftAssertions.assertCondition(mModule == null, "Creating an already created module.");
ReactMarker.logMarker(CREATE_MODULE_START, mName);
SystraceMessage.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "createModule")
.arg("name", mName)
.flush();
NativeModule module = assertNotNull(mProvider).get();
mProvider = null;
if (mInitializeNeeded) {
doInitialize(module);
mInitializeNeeded = false;
}
Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE);
if (!isEagerModule) {
ReactMarker.logMarker(CREATE_MODULE_END);
}
ReactMarker.logMarker(CREATE_MODULE_END);
return module;
}

Expand Down

0 comments on commit 7c82803

Please sign in to comment.