Fabric: ContextContainer was moved to utils module

Summary: That allows avoiding circular deps and unnecessary deps on uimanager module.

Reviewed By: PeteTheHeat

Differential Revision: D14917227

fbshipit-source-id: fe7962ee528aa659d8bd23e3e46627722551d995
This commit is contained in:
Valentin Shergin
2019-04-12 15:10:40 -07:00
committed by Facebook Github Bot
parent 108c4190ed
commit 792585fd48
17 changed files with 22 additions and 23 deletions

View File

@@ -18,7 +18,7 @@
#include <react/config/ReactNativeConfig.h>
#include <react/uimanager/ComponentDescriptorFactory.h>
#include <react/uimanager/ComponentDescriptorRegistry.h>
#include <react/uimanager/ContextContainer.h>
#include <react/utils/ContextContainer.h>
namespace facebook {
namespace react {

View File

@@ -9,9 +9,9 @@
#import <react/debug/SystraceSection.h>
#import <react/uimanager/ComponentDescriptorFactory.h>
#import <react/uimanager/ContextContainer.h>
#import <react/uimanager/Scheduler.h>
#import <react/uimanager/SchedulerDelegate.h>
#import <react/utils/ContextContainer.h>
#import <React/RCTFollyConvert.h>

View File

@@ -12,7 +12,7 @@
#import <React/RCTComponentViewFactory.h>
#import <React/RCTPrimitives.h>
#import <react/config/ReactNativeConfig.h>
#import <react/uimanager/ContextContainer.h>
#import <react/utils/ContextContainer.h>
NS_ASSUME_NONNULL_BEGIN

View File

@@ -29,7 +29,7 @@
#import <react/core/LayoutConstraints.h>
#import <react/core/LayoutContext.h>
#import <react/imagemanager/ImageManager.h>
#import <react/uimanager/ContextContainer.h>
#import <react/utils/ContextContainer.h>
#import "MainRunLoopEventBeat.h"
#import "RuntimeEventBeat.h"

View File

@@ -16,7 +16,7 @@
#include <react/core/EventBeat.h>
#include <react/core/EventEmitter.h>
#include <react/uimanager/ComponentDescriptorFactory.h>
#include <react/uimanager/ContextContainer.h>
#include <react/utils/ContextContainer.h>
#include <react/uimanager/Scheduler.h>
#include <react/uimanager/SchedulerDelegate.h>
#include <react/uimanager/primitives.h>

View File

@@ -7,7 +7,7 @@
#include <fb/fbjni.h>
#include <jsi/jsi.h>
#include <react/uimanager/ComponentDescriptorRegistry.h>
#include <react/uimanager/ContextContainer.h>
#include <react/utils/ContextContainer.h>
#include <react/uimanager/Scheduler.h>
#include <mutex>
#include <unordered_set>

View File

@@ -10,7 +10,7 @@
#include <react/components/image/ImageShadowNode.h>
#include <react/core/ConcreteComponentDescriptor.h>
#include <react/imagemanager/ImageManager.h>
#include <react/uimanager/ContextContainer.h>
#include <react/utils/ContextContainer.h>
namespace facebook {
namespace react {

View File

@@ -9,7 +9,7 @@
#include <react/core/ConcreteComponentDescriptor.h>
#include <react/core/LayoutConstraints.h>
#include <react/uimanager/ContextContainer.h>
#include <react/utils/ContextContainer.h>
namespace facebook {
namespace react {

View File

@@ -9,7 +9,7 @@
#include <react/core/ConcreteComponentDescriptor.h>
#include <react/core/LayoutConstraints.h>
#include <react/uimanager/ContextContainer.h>
#include <react/utils/ContextContainer.h>
namespace facebook {
namespace react {

View File

@@ -11,10 +11,10 @@
#include "ParagraphShadowNode.h"
#include <folly/container/EvictingCacheMap.h>
#include <react/config/ReactNativeConfig.h>
#include <react/core/ConcreteComponentDescriptor.h>
#include <react/textlayoutmanager/TextLayoutManager.h>
#include <react/uimanager/ContextContainer.h>
#include <react/config/ReactNativeConfig.h>
#include <react/utils/ContextContainer.h>
namespace facebook {
namespace react {

View File

@@ -7,7 +7,7 @@
#include <react/uimanager/ComponentDescriptorFactory.h>
#include <react/uimanager/ComponentDescriptorRegistry.h>
#include <react/uimanager/ContextContainer.h>
#include <react/utils/ContextContainer.h>
namespace facebook {
namespace react {

View File

@@ -12,7 +12,7 @@
#include <react/attributedstring/AttributedString.h>
#include <react/attributedstring/ParagraphAttributes.h>
#include <react/core/LayoutConstraints.h>
#include <react/uimanager/ContextContainer.h>
#include <react/utils/ContextContainer.h>
namespace facebook {
namespace react {

View File

@@ -12,7 +12,7 @@
#include <react/attributedstring/AttributedString.h>
#include <react/attributedstring/ParagraphAttributes.h>
#include <react/core/LayoutConstraints.h>
#include <react/uimanager/ContextContainer.h>
#include <react/utils/ContextContainer.h>
namespace facebook {
namespace react {

View File

@@ -11,7 +11,7 @@
#include <react/core/ComponentDescriptor.h>
#include <react/core/EventDispatcher.h>
#include <react/uimanager/ContextContainer.h>
#include <react/utils/ContextContainer.h>
#include "ComponentDescriptorRegistry.h"

View File

@@ -17,11 +17,11 @@
#include <react/mounting/ShadowTreeRegistry.h>
#include <react/uimanager/ComponentDescriptorFactory.h>
#include <react/uimanager/ComponentDescriptorRegistry.h>
#include <react/uimanager/ContextContainer.h>
#include <react/uimanager/SchedulerDelegate.h>
#include <react/uimanager/UIManagerBinding.h>
#include <react/uimanager/UIManagerDelegate.h>
#include <react/uimanager/primitives.h>
#include <react/utils/ContextContainer.h>
namespace facebook {
namespace react {

View File

@@ -23,7 +23,7 @@ using namespace facebook::react;
#include <react/config/ReactNativeConfig.h>
#include <react/uimanager/ComponentDescriptorFactory.h>
#include <react/uimanager/ComponentDescriptorRegistry.h>
#include <react/uimanager/ContextContainer.h>
#include <react/utils/ContextContainer.h>
namespace facebook {
namespace react {

View File

@@ -8,10 +8,7 @@
#include <memory>
#include <mutex>
#include <string>
#include <typeindex>
#include <typeinfo>
#include <unordered_map>
#include <utility>
#include <glog/logging.h>
@@ -28,6 +25,8 @@ using SharedContextContainer = std::shared_ptr<ContextContainer>;
*/
class ContextContainer final {
public:
using Shared = std::shared_ptr<ContextContainer>;
/*
* Registers an instance of the particular type `T` in the container
* using the provided `key`. Only one instance can be registered per key.
@@ -39,10 +38,10 @@ class ContextContainer final {
*`EmptyReactNativeConfig`.
*/
template <typename T>
void registerInstance(const T &instance, const std::string &key) {
void registerInstance(T const &instance, std::string const &key) {
std::lock_guard<std::mutex> lock(mutex_);
const auto res = instances_.insert({key, std::make_shared<T>(instance)});
auto res = instances_.insert({key, std::make_shared<T>(instance)});
if (res.second == false) {
LOG(FATAL) << "ContextContainer already had instance for key '" << key
<< "'";
@@ -54,7 +53,7 @@ class ContextContainer final {
* for `key`.
*/
template <typename T>
T getInstance(const std::string &key) const {
T getInstance(std::string const &key) const {
std::lock_guard<std::mutex> lock(mutex_);
return *std::static_pointer_cast<T>(instances_.at(key));