Fabric: Removing `ComponentDescriptorProviderRegistry::remove()`

Summary:
This diff removes `ComponentDescriptorProviderRegistry::remove()` and two derivative interfaces.
First, we don't use that and there is no concrete idea why we would need to use that. Those were originally built only for symmetry with limited knowledge about what exactly we need.
Second, those methods are actually dangerous and probably must not be supported by design. Removing a ComponentDescriptorProvider destroys already registered `ComponentDescriptor`s, and at the same time we might have ShadowNodes referring to that (which will cause a crash), and there is no reasonable way to check for the existence of those nodes.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D18285497

fbshipit-source-id: b461e38b923c217a256e1155689311397a994feb
This commit is contained in:
Valentin Shergin 2019-11-06 14:40:51 -08:00 коммит произвёл Facebook Github Bot
Родитель 18e3303cd4
Коммит b642677a97
6 изменённых файлов: 4 добавлений и 49 удалений

Просмотреть файл

@ -30,11 +30,6 @@ NS_ASSUME_NONNULL_BEGIN
*/
- (void)registerComponentViewClass:(Class<RCTComponentViewProtocol>)componentViewClass;
/**
* Unregisters a component view class in the factory.
*/
- (void)unregisterComponentViewClass:(Class<RCTComponentViewProtocol>)componentViewClass;
/**
* Creates a component view with given component handle.
*/

Просмотреть файл

@ -111,15 +111,6 @@ using namespace facebook::react;
}
}
- (void)unregisterComponentViewClass:(Class<RCTComponentViewProtocol>)componentViewClass
{
std::unique_lock<better::shared_mutex> lock(_mutex);
auto componentDescriptorProvider = [componentViewClass componentDescriptorProvider];
_componentViewClasses.erase(componentDescriptorProvider.handle);
_providerRegistry.remove(componentDescriptorProvider);
}
- (RCTComponentViewDescriptor)createComponentViewWithComponentHandle:(facebook::react::ComponentHandle)componentHandle
{
RCTAssertMainQueue();

Просмотреть файл

@ -38,21 +38,6 @@ void ComponentDescriptorProviderRegistry::add(
}
}
void ComponentDescriptorProviderRegistry::remove(
ComponentDescriptorProvider provider) const {
std::unique_lock<better::shared_mutex> lock(mutex_);
componentDescriptorProviders_.erase(provider.handle);
for (auto const &weakRegistry : componentDescriptorRegistries_) {
auto registry = weakRegistry.lock();
if (!registry) {
continue;
}
registry->remove(provider);
}
}
void ComponentDescriptorProviderRegistry::setComponentDescriptorProviderRequest(
ComponentDescriptorProviderRequest componentDescriptorProviderRequest)
const {

Просмотреть файл

@ -28,12 +28,11 @@ using ComponentDescriptorProviderRequest =
class ComponentDescriptorProviderRegistry final {
public:
/*
* Adds (or removes) a `ComponentDescriptorProvider`s and update the managed
* Adds a `ComponentDescriptorProvider`s and update the managed
* `ComponentDescriptorRegistry`s accordingly.
* The methods can be called on any thread.
*/
void add(ComponentDescriptorProvider provider) const;
void remove(ComponentDescriptorProvider provider) const;
/*
* ComponenDescriptorRegistry will call the `request` in case if a component

Просмотреть файл

@ -47,21 +47,6 @@ void ComponentDescriptorRegistry::add(
}
}
void ComponentDescriptorRegistry::remove(
ComponentDescriptorProvider componentDescriptorProvider) const {
std::unique_lock<better::shared_mutex> lock(mutex_);
assert(
_registryByHandle.find(componentDescriptorProvider.handle) !=
_registryByHandle.end());
assert(
_registryByName.find(componentDescriptorProvider.name) !=
_registryByName.end());
_registryByHandle.erase(componentDescriptorProvider.handle);
_registryByName.erase(componentDescriptorProvider.name);
}
void ComponentDescriptorRegistry::registerComponentDescriptor(
SharedComponentDescriptor componentDescriptor) const {
ComponentHandle componentHandle = componentDescriptor->getComponentHandle();

Просмотреть файл

@ -59,13 +59,13 @@ class ComponentDescriptorRegistry {
SharedComponentDescriptor componentDescriptor) const;
/*
* Adds (or removes) a `ComponentDescriptor ` created using given
* `ComponentDescriptorProvider` and stored `ComponentDescriptorParameters`.
* Creates a `ComponentDescriptor` using specified
* `ComponentDescriptorProvider` and stored `ComponentDescriptorParameters`,
* and then adds that to the registry.
* To be used by `ComponentDescriptorProviderRegistry` only.
* Thread safe.
*/
void add(ComponentDescriptorProvider componentDescriptorProvider) const;
void remove(ComponentDescriptorProvider componentDescriptorProvider) const;
mutable better::shared_mutex mutex_;
mutable better::map<ComponentHandle, SharedComponentDescriptor>