Skip to content

Commit

Permalink
Remove the experimental concept of whitelisted modules
Browse files Browse the repository at this point in the history
Reviewed By: dcaspi

Differential Revision: D6124036

fbshipit-source-id: af3771ce2204b3695f79265d5aade7e321e12a3e
  • Loading branch information
Dan Zimmerman authored and facebook-github-bot committed Oct 25, 2017
1 parent fe792f5 commit 55f75df
Show file tree
Hide file tree
Showing 5 changed files with 2 additions and 82 deletions.
27 changes: 1 addition & 26 deletions React/Base/RCTBatchedBridge.mm
Original file line number Diff line number Diff line change
Expand Up @@ -246,17 +246,7 @@ - (BOOL)moduleIsInitialized:(Class)moduleClass

- (NSArray *)configForModuleName:(NSString *)moduleName
{
RCTModuleData *moduleData = _moduleDataByName[moduleName];
if (moduleData) {
#if RCT_DEV
if ([self.delegate respondsToSelector:@selector(whitelistedModulesForBridge:)]) {
NSArray *whitelisted = [self.delegate whitelistedModulesForBridge:self];
RCTAssert(!whitelisted || [whitelisted containsObject:[moduleData moduleClass]],
@"Required config for %@, which was not whitelisted", moduleName);
}
#endif
}
return moduleData.config;
return _moduleDataByName[moduleName].config;
}

- (void)initModulesWithDispatchGroup:(dispatch_group_t)dispatchGroup
Expand Down Expand Up @@ -399,11 +389,6 @@ - (void)prepareModulesWithDispatchGroup:(dispatch_group_t)dispatchGroup
{
RCT_PROFILE_BEGIN_EVENT(0, @"-[RCTBatchedBridge prepareModulesWithDispatch]", nil);

NSArray<Class> *whitelistedModules = nil;
if ([self.delegate respondsToSelector:@selector(whitelistedModulesForBridge:)]) {
whitelistedModules = [self.delegate whitelistedModulesForBridge:self];
}

BOOL initializeImmediately = NO;
if (dispatchGroup == NULL) {
// If no dispatchGroup is passed in, we must prepare everything immediately.
Expand All @@ -414,10 +399,6 @@ - (void)prepareModulesWithDispatchGroup:(dispatch_group_t)dispatchGroup

// Set up modules that require main thread init or constants export
for (RCTModuleData *moduleData in _moduleDataByID) {
if (whitelistedModules && ![whitelistedModules containsObject:[moduleData moduleClass]]) {
continue;
}

if (moduleData.requiresMainQueueSetup || moduleData.hasConstantsToExport) {
// Modules that need to be set up on the main thread cannot be initialized
// lazily when required without doing a dispatch_sync to the main thread,
Expand Down Expand Up @@ -450,12 +431,6 @@ - (void)prepareModulesWithDispatchGroup:(dispatch_group_t)dispatchGroup
RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @"");
}

- (void)whitelistedModulesDidChange
{
RCTAssertMainQueue();
[self prepareModulesWithDispatchGroup:NULL];
}

- (void)setUpExecutor
{
[_javaScriptExecutor setUp];
Expand Down
11 changes: 0 additions & 11 deletions React/Base/RCTBridge.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,17 +161,6 @@ RCT_EXTERN NSString *RCTBridgeModuleNameForClass(Class bridgeModuleClass);
*/
- (BOOL)moduleIsInitialized:(Class)moduleClass;

/**
* Call when your delegate's `whitelistedModulesForBridge:` value has changed.
* In response to this, the bridge will immediately instantiate any (whitelisted)
* native modules that require main thread initialization. Modules that do not require
* main thread initialization will still be created lazily.
*
* This method must be called on the main thread, as any pending native modules
* will be initialized immediately.
*/
- (void)whitelistedModulesDidChange;

/**
* All registered bridge module classes.
*/
Expand Down
5 changes: 0 additions & 5 deletions React/Base/RCTBridge.m
Original file line number Diff line number Diff line change
Expand Up @@ -252,11 +252,6 @@ - (BOOL)moduleIsInitialized:(Class)moduleClass
return [self.batchedBridge moduleIsInitialized:moduleClass];
}

- (void)whitelistedModulesDidChange
{
[self.batchedBridge whitelistedModulesDidChange];
}

- (void)reload
{
#if RCT_ENABLE_INSPECTOR
Expand Down
14 changes: 0 additions & 14 deletions React/Base/RCTBridgeDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,6 @@
*/
- (NSArray<id<RCTBridgeModule>> *)extraModulesForBridge:(RCTBridge *)bridge;

/**
* Customize how bridge native modules are initialized.
*
* By default all modules are created lazily except those that have constants to export
* or require main thread initialization. If you want to limit the set of native
* modules that this should be considered for, implement this method.
*
* Return nil to whitelist all modules found. Modules passed in extraModulesForBridge:
* are automatically whitelisted.
*
* @experimental
*/
- (NSArray<Class> *)whitelistedModulesForBridge:(RCTBridge *)bridge;

/**
* Configure whether the JSCExecutor created should use the system JSC API or
* alternative hooks provided. When returning YES from this method, you must have
Expand Down
27 changes: 1 addition & 26 deletions React/CxxBridge/RCTCxxBridge.mm
Original file line number Diff line number Diff line change
Expand Up @@ -522,17 +522,7 @@ - (void)_initializeBridge:(std::shared_ptr<JSExecutorFactory>)executorFactory

- (NSArray *)configForModuleName:(NSString *)moduleName
{
RCTModuleData *moduleData = _moduleDataByName[moduleName];
if (moduleData) {
#if RCT_DEV
if ([self.delegate respondsToSelector:@selector(whitelistedModulesForBridge:)]) {
NSArray *whitelisted = [self.delegate whitelistedModulesForBridge:self];
RCTAssert(!whitelisted || [whitelisted containsObject:[moduleData moduleClass]],
@"Required config for %@, which was not whitelisted", moduleName);
}
#endif
}
return moduleData.config;
return _moduleDataByName[moduleName].config;
}

- (NSArray<RCTModuleData *> *)registerModulesForClasses:(NSArray<Class> *)moduleClasses
Expand Down Expand Up @@ -695,11 +685,6 @@ - (void)_prepareModulesWithDispatchGroup:(dispatch_group_t)dispatchGroup
{
RCT_PROFILE_BEGIN_EVENT(0, @"-[RCTBatchedBridge prepareModulesWithDispatch]", nil);

NSArray<Class> *whitelistedModules = nil;
if ([self.delegate respondsToSelector:@selector(whitelistedModulesForBridge:)]) {
whitelistedModules = [self.delegate whitelistedModulesForBridge:self];
}

BOOL initializeImmediately = NO;
if (dispatchGroup == NULL) {
// If no dispatchGroup is passed in, we must prepare everything immediately.
Expand All @@ -712,10 +697,6 @@ - (void)_prepareModulesWithDispatchGroup:(dispatch_group_t)dispatchGroup
[_performanceLogger setValue:0 forTag:RCTPLNativeModuleMainThread];

for (RCTModuleData *moduleData in _moduleDataByID) {
if (whitelistedModules && ![whitelistedModules containsObject:[moduleData moduleClass]]) {
continue;
}

if (moduleData.requiresMainQueueSetup) {
// Modules that need to be set up on the main thread cannot be initialized
// lazily when required without doing a dispatch_sync to the main thread,
Expand Down Expand Up @@ -747,12 +728,6 @@ - (void)_prepareModulesWithDispatchGroup:(dispatch_group_t)dispatchGroup
RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @"");
}

- (void)whitelistedModulesDidChange
{
RCTAssertMainQueue();
[self _prepareModulesWithDispatchGroup:NULL];
}

- (void)registerModuleForFrameUpdates:(id<RCTBridgeModule>)module
withModuleData:(RCTModuleData *)moduleData
{
Expand Down

0 comments on commit 55f75df

Please sign in to comment.