From cd6ebcdd82f23fe0d867c4c8e0267617bb6c05d6 Mon Sep 17 00:00:00 2001 From: Paige Sun Date: Wed, 14 Oct 2020 03:12:50 -0700 Subject: [PATCH] Set MobileConfig for Fabric logging in FBReactModule Summary: Changelog: [RN][iOS] Allow gate to be set for Fabric logging from the React Module Reviewed By: fkgozali Differential Revision: D24256546 fbshipit-source-id: 7b290efb9abd3035559f743e6e5b6701e02053e1 --- Libraries/Image/RCTImageLoader.mm | 12 ++++++++++++ .../Image/RCTImageLoaderWithAttributionProtocol.h | 3 +++ 2 files changed, 15 insertions(+) diff --git a/Libraries/Image/RCTImageLoader.mm b/Libraries/Image/RCTImageLoader.mm index 723b64dbe6..6ff74f17f1 100644 --- a/Libraries/Image/RCTImageLoader.mm +++ b/Libraries/Image/RCTImageLoader.mm @@ -38,6 +38,18 @@ void RCTEnableImageLoadingPerfInstrumentation(BOOL enabled) imagePerfInstrumentationEnabled = enabled; } +static BOOL (^getImagePerfInstrumentationForFabricEnabled)() = (^BOOL () { + return NO; +}); + +BOOL RCTGetImageLoadingPerfInstrumentationForFabricEnabled() { + return getImagePerfInstrumentationForFabricEnabled(); +} + +void RCTSetImageLoadingPerfInstrumentationForFabricEnabledBlock(BOOL (^getMobileConfigEnabled)()) { + getImagePerfInstrumentationForFabricEnabled = getMobileConfigEnabled; +} + static NSInteger RCTImageBytesForImage(UIImage *image) { NSInteger singleImageBytes = image.size.width * image.size.height * image.scale * image.scale * 4; diff --git a/Libraries/Image/RCTImageLoaderWithAttributionProtocol.h b/Libraries/Image/RCTImageLoaderWithAttributionProtocol.h index 44f4ee849a..ee546a9b72 100644 --- a/Libraries/Image/RCTImageLoaderWithAttributionProtocol.h +++ b/Libraries/Image/RCTImageLoaderWithAttributionProtocol.h @@ -16,6 +16,9 @@ RCT_EXTERN BOOL RCTImageLoadingPerfInstrumentationEnabled(void); RCT_EXTERN void RCTEnableImageLoadingInstrumentation(BOOL enabled); RCT_EXTERN void RCTEnableImageLoadingPerfInstrumentation(BOOL enabled); +RCT_EXTERN BOOL RCTGetImageLoadingPerfInstrumentationForFabricEnabled(); +RCT_EXTERN void RCTSetImageLoadingPerfInstrumentationForFabricEnabledBlock(BOOL (^getEnabled)()); + @protocol RCTImageLoaderWithAttributionProtocol // TODO (T61325135): Remove C++ checks