From f1258181eec84f73651d2fabd0d23764b8990ff8 Mon Sep 17 00:00:00 2001 From: Alex Dvornikov Date: Mon, 6 Nov 2017 17:55:38 -0800 Subject: [PATCH] Rename "js-bundles" to "js-segments" Differential Revision: D6244399 fbshipit-source-id: d1606d126e3b598b19fa8a0955438c8dec76f5d0 --- React/Base/RCTBridgeDelegate.h | 2 +- React/CxxBridge/RCTCxxBridge.mm | 8 ++++---- .../com/facebook/react/bridge/CatalystInstanceImpl.java | 6 +++--- .../java/com/facebook/react/bridge/JSBundleLoader.java | 6 +++--- .../src/main/jni/react/jni/CatalystInstanceImpl.cpp | 8 ++++---- .../src/main/jni/react/jni/CatalystInstanceImpl.h | 6 +++--- 6 files changed, 18 insertions(+), 18 deletions(-) diff --git a/React/Base/RCTBridgeDelegate.h b/React/Base/RCTBridgeDelegate.h index 631e1825535ec9..fb048769ead2c9 100644 --- a/React/Base/RCTBridgeDelegate.h +++ b/React/Base/RCTBridgeDelegate.h @@ -99,6 +99,6 @@ * * @experimental */ -- (NSURL *)jsBundlesDirectory; +- (NSURL *)jsSegmentsDirectory; @end diff --git a/React/CxxBridge/RCTCxxBridge.mm b/React/CxxBridge/RCTCxxBridge.mm index 24cf7f6c111095..e0af63b2533422 100644 --- a/React/CxxBridge/RCTCxxBridge.mm +++ b/React/CxxBridge/RCTCxxBridge.mm @@ -1144,11 +1144,11 @@ - (void)executeApplicationScript:(NSData *)script [self->_performanceLogger markStopForTag:RCTPLRAMBundleLoad]; [self->_performanceLogger setValue:scriptStr->size() forTag:RCTPLRAMStartupCodeSize]; if (self->_reactInstance) { - NSString *jsBundlesDirectory = [self.delegate respondsToSelector:@selector(jsBundlesDirectory)] - ? [[self.delegate jsBundlesDirectory].path stringByAppendingString:@"/"] + NSString *jsSegmentsDirectory = [self.delegate respondsToSelector:@selector(jsSegmentsDirectory)] + ? [[self.delegate jsSegmentsDirectory].path stringByAppendingString:@"/"] : nil; - auto registry = jsBundlesDirectory != nil - ? std::make_unique(std::move(ramBundle), jsBundlesDirectory.UTF8String) + auto registry = jsSegmentsDirectory != nil + ? std::make_unique(std::move(ramBundle), jsSegmentsDirectory.UTF8String) : std::make_unique(std::move(ramBundle)); self->_reactInstance->loadRAMBundle(std::move(registry), std::move(scriptStr), sourceUrlStr.UTF8String, !async); diff --git a/ReactAndroid/src/main/java/com/facebook/react/bridge/CatalystInstanceImpl.java b/ReactAndroid/src/main/java/com/facebook/react/bridge/CatalystInstanceImpl.java index c0aacb67a2a21d..960f252917cc76 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/bridge/CatalystInstanceImpl.java +++ b/ReactAndroid/src/main/java/com/facebook/react/bridge/CatalystInstanceImpl.java @@ -210,8 +210,8 @@ private native void initializeBridge( jniSetSourceURL(remoteURL); } - /* package */ void setJsBundlesDirectory(String directoryPath) { - jniSetJsBundlesDirectory(directoryPath); + /* package */ void setJsSegmentsDirectory(String directoryPath) { + jniSetJsSegmentsDirectory(directoryPath); } /* package */ void loadScriptFromAssets(AssetManager assetManager, String assetURL, boolean loadSynchronously) { @@ -225,7 +225,7 @@ private native void initializeBridge( } private native void jniSetSourceURL(String sourceURL); - private native void jniSetJsBundlesDirectory(String directoryPath); + private native void jniSetJsSegmentsDirectory(String directoryPath); private native void jniLoadScriptFromAssets(AssetManager assetManager, String assetURL, boolean loadSynchronously); private native void jniLoadScriptFromFile(String fileName, String sourceURL, boolean loadSynchronously); diff --git a/ReactAndroid/src/main/java/com/facebook/react/bridge/JSBundleLoader.java b/ReactAndroid/src/main/java/com/facebook/react/bridge/JSBundleLoader.java index 0c5476bbfe6448..d2f3aa566d7367 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/bridge/JSBundleLoader.java +++ b/ReactAndroid/src/main/java/com/facebook/react/bridge/JSBundleLoader.java @@ -97,15 +97,15 @@ public String loadScript(CatalystInstanceImpl instance) { } /** - * This loader is used to wrap other loaders and set js bundles directory before executing + * This loader is used to wrap other loaders and set js segments directory before executing * application script. */ public static JSBundleLoader createSplitBundlesLoader( - final String jsBundlesDirectory, final JSBundleLoader delegate) { + final String jsSegmentsDirectory, final JSBundleLoader delegate) { return new JSBundleLoader() { @Override public String loadScript(CatalystInstanceImpl instance) { - instance.setJsBundlesDirectory(jsBundlesDirectory); + instance.setJsSegmentsDirectory(jsSegmentsDirectory); return delegate.loadScript(instance); } }; diff --git a/ReactAndroid/src/main/jni/react/jni/CatalystInstanceImpl.cpp b/ReactAndroid/src/main/jni/react/jni/CatalystInstanceImpl.cpp index 1706e2d3e65f0c..5183a252145dc5 100644 --- a/ReactAndroid/src/main/jni/react/jni/CatalystInstanceImpl.cpp +++ b/ReactAndroid/src/main/jni/react/jni/CatalystInstanceImpl.cpp @@ -101,7 +101,7 @@ void CatalystInstanceImpl::registerNatives() { makeNativeMethod("initializeBridge", CatalystInstanceImpl::initializeBridge), makeNativeMethod("jniExtendNativeModules", CatalystInstanceImpl::extendNativeModules), makeNativeMethod("jniSetSourceURL", CatalystInstanceImpl::jniSetSourceURL), - makeNativeMethod("jniSetJsBundlesDirectory", CatalystInstanceImpl::jniSetJsBundlesDirectory), + makeNativeMethod("jniSetJsSegmentsDirectory", CatalystInstanceImpl::jniSetJsSegmentsDirectory), makeNativeMethod("jniLoadScriptFromAssets", CatalystInstanceImpl::jniLoadScriptFromAssets), makeNativeMethod("jniLoadScriptFromFile", CatalystInstanceImpl::jniLoadScriptFromFile), makeNativeMethod("jniCallJSFunction", CatalystInstanceImpl::jniCallJSFunction), @@ -178,8 +178,8 @@ void CatalystInstanceImpl::jniSetSourceURL(const std::string& sourceURL) { instance_->setSourceURL(sourceURL); } -void CatalystInstanceImpl::jniSetJsBundlesDirectory(const std::string& directoryPath) { - jsBundlesDirectory_ = directoryPath; +void CatalystInstanceImpl::jniSetJsSegmentsDirectory(const std::string& directoryPath) { + jsSegmentsDirectory_ = directoryPath; } void CatalystInstanceImpl::jniLoadScriptFromAssets( @@ -193,7 +193,7 @@ void CatalystInstanceImpl::jniLoadScriptFromAssets( auto script = loadScriptFromAssets(manager, sourceURL); if (JniJSModulesUnbundle::isUnbundle(manager, sourceURL)) { auto bundle = JniJSModulesUnbundle::fromEntryFile(manager, sourceURL); - auto registry = jsBundlesDirectory_.empty() + auto registry = jsSegmentsDirectory_.empty() ? folly::make_unique(std::move(bundle)) : folly::make_unique(std::move(bundle), manager, sourceURL); instance_->loadRAMBundle( diff --git a/ReactAndroid/src/main/jni/react/jni/CatalystInstanceImpl.h b/ReactAndroid/src/main/jni/react/jni/CatalystInstanceImpl.h index f1bd47e8e8d9d5..01abcd87136ec7 100644 --- a/ReactAndroid/src/main/jni/react/jni/CatalystInstanceImpl.h +++ b/ReactAndroid/src/main/jni/react/jni/CatalystInstanceImpl.h @@ -63,7 +63,7 @@ class CatalystInstanceImpl : public jni::HybridClass { * Sets the path to folder where additional bundles are located. * Needs to be invoked before "loadScript" methods are called. */ - void jniSetJsBundlesDirectory(const std::string& directoryPath); + void jniSetJsSegmentsDirectory(const std::string& directoryPath); void jniLoadScriptFromAssets(jni::alias_ref assetManager, const std::string& assetURL, bool loadSynchronously); void jniLoadScriptFromFile(const std::string& fileName, const std::string& sourceURL, bool loadSynchronously); @@ -74,8 +74,8 @@ class CatalystInstanceImpl : public jni::HybridClass { jlong getJavaScriptContext(); void handleMemoryPressure(int pressureLevel); - std::string jsBundlesDirectory_; - + std::string jsSegmentsDirectory_; + // This should be the only long-lived strong reference, but every C++ class // will have a weak reference. std::shared_ptr instance_;