Make UnpackingJSBundleLoader.prepare a public API.

Reviewed By: brosenfeld

Differential Revision: D4161585

fbshipit-source-id: b3b835610d11e043d2406cccff2da27f07878acc
This commit is contained in:
Michał Gregorczyk 2016-11-12 14:29:40 -08:00 committed by Facebook Github Bot
parent 927dcc689a
commit c612c61544

View File

@ -72,6 +72,11 @@ public class UnpackingJSBundleLoader extends JSBundleLoader {
private final boolean mFinishOnBackgroundThread;
private final @Nullable Runnable mOnUnpackedCallback;
/**
* True if prepare was called.
*/
private boolean mPrepared;
/**
* Synchronizes unpacking within this process.
*/
@ -96,13 +101,20 @@ public class UnpackingJSBundleLoader extends JSBundleLoader {
mFinishOnBackgroundThread = builder.finishOnBackgroundThread;
mOnUnpackedCallback = builder.callback;
mFileLocker = null;
mPrepared = false;
}
/**
* Checks if any file needs to be extracted again, and if so, clears the destination
* directory and unpacks everything again.
*
* This method does not do anything if called for the second time
*/
/* package */ void prepare() {
public synchronized void prepare() {
if (mPrepared) {
return;
}
ReactMarker.logMarker(ReactMarkerConstants.UNPACKER_CHECK_START);
boolean unpacked = false;
@ -131,6 +143,8 @@ public class UnpackingJSBundleLoader extends JSBundleLoader {
}
ReactMarker.logMarker(ReactMarkerConstants.UNPACKER_CHECK_END);
mPrepared = true;
}
private boolean prepareLocked() throws IOException {