Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Performance] Migrate to GoogleUtilities's storage container #12759

Merged
merged 1 commit into from
Apr 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions FirebasePerformance.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,10 @@ Firebase Performance library to measure performance of Mobile and Web Apps.
s.dependency 'FirebaseRemoteConfig', '~> 10.0'
s.dependency 'FirebaseSessions', '~> 10.5'
s.dependency 'GoogleDataTransport', '~> 9.2'
s.dependency 'GoogleUtilities/Environment', '~> 7.8'
s.dependency 'GoogleUtilities/ISASwizzler', '~> 7.8'
s.dependency 'GoogleUtilities/MethodSwizzler', '~> 7.8'
s.dependency 'GoogleUtilities/Environment', '~> 7.13'
s.dependency 'GoogleUtilities/ISASwizzler', '~> 7.13'
s.dependency 'GoogleUtilities/MethodSwizzler', '~> 7.13'
s.dependency 'GoogleUtilities/UserDefaults', '~> 7.13'
s.dependency 'nanopb', '>= 2.30908.0', '< 2.30911.0'

s.test_spec 'unit' do |unit_tests|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

NS_ASSUME_NONNULL_BEGIN

@class GULUserDefaults;

/** List of gauges the gauge manager controls. */
typedef NS_OPTIONS(NSUInteger, FPRConfigurationSource) {
FPRConfigurationSourceNone = 0,
Expand All @@ -36,7 +38,7 @@ typedef NS_OPTIONS(NSUInteger, FPRConfigurationSource) {
@property(nonatomic) Class FIRAppClass;

/** @brief User defaults used for user preference config fetches . */
@property(nonatomic) NSUserDefaults *userDefaults;
@property(nonatomic) GULUserDefaults *userDefaults;

/** @brief The main bundle identifier used by config system. */
@property(nonatomic) NSString *mainBundleIdentifier;
Expand Down
20 changes: 11 additions & 9 deletions FirebasePerformance/Sources/Configurations/FPRConfigurations.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

#import <UIKit/UIKit.h>

#import <GoogleUtilities/GULUserDefaults.h>

#import "FirebasePerformance/Sources/Common/FPRConstants.h"
#import "FirebasePerformance/Sources/Configurations/FPRConfigurations+Private.h"
#import "FirebasePerformance/Sources/Configurations/FPRConfigurations.h"
Expand Down Expand Up @@ -58,9 +60,9 @@ + (instancetype)sharedInstance {
+ (void)reset {
// TODO(b/120032990): Reset the singletons that this singleton uses.
gSharedInstanceToken = 0;
[[NSUserDefaults standardUserDefaults]
[[GULUserDefaults standardUserDefaults]
removeObjectForKey:kFPRConfigInstrumentationUserPreference];
[[NSUserDefaults standardUserDefaults] removeObjectForKey:kFPRConfigCollectionUserPreference];
[[GULUserDefaults standardUserDefaults] removeObjectForKey:kFPRConfigCollectionUserPreference];
}

- (instancetype)initWithSources:(FPRConfigurationSource)source {
Expand All @@ -73,7 +75,7 @@ - (instancetype)initWithSources:(FPRConfigurationSource)source {
[self registerForNotifications];

self.FIRAppClass = [FIRApp class];
self.userDefaults = [NSUserDefaults standardUserDefaults];
self.userDefaults = [GULUserDefaults standardUserDefaults];
self.infoDictionary = [NSBundle mainBundle].infoDictionary;
self.mainBundleIdentifier = [NSBundle mainBundle].bundleIdentifier;
self.updateQueue = dispatch_queue_create("com.google.perf.configUpdate", DISPATCH_QUEUE_SERIAL);
Expand Down Expand Up @@ -141,7 +143,7 @@ - (void)setDataCollectionEnabled:(BOOL)dataCollectionEnabled {

// The data collection flag is determined by this order:
// 1. A plist flag for permanently disabling data collection
// 2. The runtime flag (NSUserDefaults)
// 2. The runtime flag (GULUserDefaults)
// 3. A plist flag for enabling/disabling (overrideable)
// 4. The global data collection switch from Core.
- (BOOL)isDataCollectionEnabled {
Expand All @@ -165,7 +167,7 @@ - (BOOL)isDataCollectionEnabled {
}
}
/**
* Check if the performance collection preference key is available in NSUserDefaults.
* Check if the performance collection preference key is available in GULUserDefaults.
* If it exists - Just honor that and return that value.
* If it does not exist - Check if firebase_performance_collection_enabled exists in Info.plist.
* If it exists - honor that and return that value.
Expand Down Expand Up @@ -196,7 +198,7 @@ - (BOOL)isInstrumentationEnabled {
[self.userDefaults objectForKey:kFPRConfigInstrumentationUserPreference];

/**
* Check if the performance instrumentation preference key is available in NSUserDefaults.
* Check if the performance instrumentation preference key is available in GULUserDefaults.
* If it exists - Just honor that and return that value.
* If not - Check if firebase_performance_instrumentation_enabled exists in Info.plist.
* If it exists - honor that and return that value.
Expand Down Expand Up @@ -242,7 +244,7 @@ - (BOOL)diagnosticsEnabled {
BOOL enabled = NO;

/**
* Check if the diagnostics preference key is available in NSUserDefaults.
* Check if the diagnostics preference key is available in GULUserDefaults.
* If it exists - Just honor that and return that value.
* If not - Check if firebase_performance_instrumentation_enabled exists in Info.plist.
* If it exists - honor that and return that value.
Expand Down Expand Up @@ -282,8 +284,8 @@ - (int)logSource {
* Order of preference of returning the log source.
* If it is an autopush build (based on environment variable), always return
* LogRequest_LogSource_FireperfAutopush (461). If there is a recent value of remote config fetch,
* honor that value. If logSource cached value (NSUserDefaults value) exists, honor that. Fallback
* to the default value LogRequest_LogSource_Fireperf (462).
* honor that value. If logSource cached value (GULUserDefaults value) exists, honor that.
* Fallback to the default value LogRequest_LogSource_Fireperf (462).
*/
int logSource = 462;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

NS_ASSUME_NONNULL_BEGIN

@class GULUserDefaults;

static NSString *const kFPRConfigPrefix = @"com.fireperf";

/** Interval at which the configurations can be fetched. Specified in seconds. */
Expand All @@ -36,7 +38,7 @@ static NSInteger const kFPRMinAppStartConfigFetchDelayInSeconds = 5;
@property(atomic, nullable) NSDate *lastFetchedTime;

/** @brief User defaults used for caching. */
@property(nonatomic) NSUserDefaults *userDefaults;
@property(nonatomic) GULUserDefaults *userDefaults;

/** @brief Last activated time of the configurations. */
@property(nonatomic) NSDate *applicationStartTime;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#import "FirebasePerformance/Sources/Configurations/FPRRemoteConfigFlags.h"
#import <GoogleUtilities/GULUserDefaults.h>

#import "FirebasePerformance/Sources/Configurations/FPRConfigurations+Private.h"
#import "FirebasePerformance/Sources/Configurations/FPRConfigurations.h"
#import "FirebasePerformance/Sources/Configurations/FPRRemoteConfigFlags+Private.h"
#import "FirebasePerformance/Sources/Configurations/FPRRemoteConfigFlags.h"

#import "FirebasePerformance/Sources/FPRConsoleLogger.h"

Expand Down
Loading
Loading