firebase log level
This commit is contained in:
58
Pods/FirebaseCrashlytics/Crashlytics/Shared/FIRCLSOperation/FIRCLSCompoundOperation.h
generated
Normal file
58
Pods/FirebaseCrashlytics/Crashlytics/Shared/FIRCLSOperation/FIRCLSCompoundOperation.h
generated
Normal file
@ -0,0 +1,58 @@
|
||||
// Copyright 2019 Google
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#import "Crashlytics/Shared/FIRCLSOperation/FIRCLSFABAsyncOperation.h"
|
||||
|
||||
/**
|
||||
* If the compound operation is sent a @c -[cancel] message while executing, it will attempt to
|
||||
* cancel all operations on its internal queue, and will return an error in its @c asyncCompletion
|
||||
* block with this value as its code.
|
||||
*/
|
||||
FOUNDATION_EXPORT const NSUInteger FIRCLSCompoundOperationErrorCodeCancelled;
|
||||
|
||||
/**
|
||||
* If one or more of the operations on the @c compoundQueue fail, this operation returns an error
|
||||
* in its @c asyncCompletion block with this code, and an array of @c NSErrors keyed on @c
|
||||
* FIRCLSCompoundOperationErrorUserInfoKeyUnderlyingErrors in the @c userInfo dictionary.
|
||||
*/
|
||||
FOUNDATION_EXPORT const NSUInteger FIRCLSCompoundOperationErrorCodeSuboperationFailed;
|
||||
|
||||
/**
|
||||
* When all the operations complete, this @c FIRCLSCompoundOperation instance's @c asyncCompletion
|
||||
* block is called. If any errors were passed by the suboperations' @c asyncCompletion blocks, they
|
||||
* are put in an array which can be accessed in the @c userInfo dictionary in the error parameter
|
||||
* for this instance's @c asyncCompletion block.
|
||||
*/
|
||||
FOUNDATION_EXPORT NSString *const FIRCLSCompoundOperationErrorUserInfoKeyUnderlyingErrors;
|
||||
|
||||
/**
|
||||
* An operation that executes a collection of suboperations on an internal private queue. Any
|
||||
* instance of @c FIRCLSFABAsyncOperation passed into this instance's @c operations property has the
|
||||
* potential to return an @c NSError in its @c asyncCompletion block. This instance's @c
|
||||
* asyncCompletion block will put all such errors in an @c NSArray and return an @c NSError whose @c
|
||||
* userInfo contains that array keyed by @c FIRCLSCompoundOperationErrorUserInfoKeyUnderlyingErrors.
|
||||
*/
|
||||
@interface FIRCLSCompoundOperation : FIRCLSFABAsyncOperation
|
||||
|
||||
/**
|
||||
* An array of @c NSOperations to execute, which can include instances of @c FIRCLSFABAsyncOperation
|
||||
* or
|
||||
* @c FIRCLSCompoundOperation. This operation will not be marked as finished until all suboperations
|
||||
* are marked as finished.
|
||||
*/
|
||||
@property(copy, nonatomic) NSArray<NSOperation *> *operations;
|
||||
|
||||
@property(strong, nonatomic, readonly) NSOperationQueue *compoundQueue;
|
||||
|
||||
@end
|
||||
165
Pods/FirebaseCrashlytics/Crashlytics/Shared/FIRCLSOperation/FIRCLSCompoundOperation.m
generated
Normal file
165
Pods/FirebaseCrashlytics/Crashlytics/Shared/FIRCLSOperation/FIRCLSCompoundOperation.m
generated
Normal file
@ -0,0 +1,165 @@
|
||||
// Copyright 2019 Google
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#import "Crashlytics/Shared/FIRCLSOperation/FIRCLSCompoundOperation.h"
|
||||
|
||||
#import "Crashlytics/Shared/FIRCLSOperation/FIRCLSFABAsyncOperation_Private.h"
|
||||
|
||||
#define FIRCLS_DISPATCH_QUEUES_AS_OBJECTS OS_OBJECT_USE_OBJC_RETAIN_RELEASE
|
||||
|
||||
const NSUInteger FIRCLSCompoundOperationErrorCodeCancelled = UINT_MAX - 1;
|
||||
const NSUInteger FIRCLSCompoundOperationErrorCodeSuboperationFailed = UINT_MAX - 2;
|
||||
|
||||
NSString *const FIRCLSCompoundOperationErrorUserInfoKeyUnderlyingErrors =
|
||||
@"com.google.firebase.crashlytics.FIRCLSCompoundOperation.error.user-info-key.underlying-"
|
||||
@"errors";
|
||||
|
||||
static NSString *const FIRCLSCompoundOperationErrorDomain =
|
||||
@"com.google.firebase.crashlytics.FIRCLSCompoundOperation.error";
|
||||
static char *const FIRCLSCompoundOperationCountingQueueLabel =
|
||||
"com.google.firebase.crashlytics.FIRCLSCompoundOperation.dispatch-queue.counting-queue";
|
||||
|
||||
@interface FIRCLSCompoundOperation ()
|
||||
|
||||
@property(strong, nonatomic, readwrite) NSOperationQueue *compoundQueue;
|
||||
@property(assign, nonatomic) NSUInteger completedOperations;
|
||||
@property(strong, nonatomic) NSMutableArray *errors;
|
||||
#if FIRCLS_DISPATCH_QUEUES_AS_OBJECTS
|
||||
@property(strong, nonatomic) dispatch_queue_t countingQueue;
|
||||
#else
|
||||
@property(assign, nonatomic) dispatch_queue_t countingQueue;
|
||||
#endif
|
||||
|
||||
@end
|
||||
|
||||
@implementation FIRCLSCompoundOperation
|
||||
|
||||
- (instancetype)init {
|
||||
self = [super init];
|
||||
if (!self) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
_compoundQueue = [[NSOperationQueue alloc] init];
|
||||
_completedOperations = 0;
|
||||
_errors = [NSMutableArray array];
|
||||
_countingQueue =
|
||||
dispatch_queue_create(FIRCLSCompoundOperationCountingQueueLabel, DISPATCH_QUEUE_SERIAL);
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
#if !FIRCLS_DISPATCH_QUEUES_AS_OBJECTS
|
||||
- (void)dealloc {
|
||||
if (_countingQueue) {
|
||||
dispatch_release(_countingQueue);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
- (void)main {
|
||||
for (FIRCLSFABAsyncOperation *operation in self.operations) {
|
||||
[self injectCompoundAsyncCompletionInOperation:operation];
|
||||
[self injectCompoundSyncCompletionInOperation:operation];
|
||||
|
||||
[self.compoundQueue addOperation:operation];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)cancel {
|
||||
if (self.compoundQueue.operations.count > 0) {
|
||||
[self.compoundQueue cancelAllOperations];
|
||||
dispatch_sync(self.countingQueue, ^{
|
||||
[self attemptCompoundCompletion];
|
||||
});
|
||||
} else {
|
||||
for (NSOperation *operation in self.operations) {
|
||||
[operation cancel];
|
||||
}
|
||||
|
||||
// we have to add the operations to the queue in order for their isFinished property to be set
|
||||
// to true.
|
||||
[self.compoundQueue addOperations:self.operations waitUntilFinished:NO];
|
||||
}
|
||||
[super cancel];
|
||||
}
|
||||
|
||||
- (void)injectCompoundAsyncCompletionInOperation:(FIRCLSFABAsyncOperation *)operation {
|
||||
__weak FIRCLSCompoundOperation *weakSelf = self;
|
||||
FIRCLSFABAsyncOperationCompletionBlock originalAsyncCompletion = [operation.asyncCompletion copy];
|
||||
FIRCLSFABAsyncOperationCompletionBlock completion = ^(NSError *error) {
|
||||
__strong FIRCLSCompoundOperation *strongSelf = weakSelf;
|
||||
|
||||
if (originalAsyncCompletion) {
|
||||
dispatch_sync(strongSelf.countingQueue, ^{
|
||||
originalAsyncCompletion(error);
|
||||
});
|
||||
}
|
||||
|
||||
[strongSelf updateCompletionCountsWithError:error];
|
||||
};
|
||||
operation.asyncCompletion = completion;
|
||||
}
|
||||
|
||||
- (void)injectCompoundSyncCompletionInOperation:(FIRCLSFABAsyncOperation *)operation {
|
||||
__weak FIRCLSCompoundOperation *weakSelf = self;
|
||||
void (^originalSyncCompletion)(void) = [operation.completionBlock copy];
|
||||
void (^completion)(void) = ^{
|
||||
__strong FIRCLSCompoundOperation *strongSelf = weakSelf;
|
||||
|
||||
if (originalSyncCompletion) {
|
||||
dispatch_sync(strongSelf.countingQueue, ^{
|
||||
originalSyncCompletion();
|
||||
});
|
||||
}
|
||||
|
||||
dispatch_sync(strongSelf.countingQueue, ^{
|
||||
[strongSelf attemptCompoundCompletion];
|
||||
});
|
||||
};
|
||||
operation.completionBlock = completion;
|
||||
}
|
||||
|
||||
- (void)updateCompletionCountsWithError:(NSError *)error {
|
||||
dispatch_sync(self.countingQueue, ^{
|
||||
if (!error) {
|
||||
self.completedOperations += 1;
|
||||
} else {
|
||||
[self.errors addObject:error];
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
- (void)attemptCompoundCompletion {
|
||||
if (self.isCancelled) {
|
||||
[self finishWithError:[NSError errorWithDomain:FIRCLSCompoundOperationErrorDomain
|
||||
code:FIRCLSCompoundOperationErrorCodeCancelled
|
||||
userInfo:@{
|
||||
NSLocalizedDescriptionKey : [NSString
|
||||
stringWithFormat:@"%@ cancelled", self.name]
|
||||
}]];
|
||||
self.asyncCompletion = nil;
|
||||
} else if (self.completedOperations + self.errors.count == self.operations.count) {
|
||||
NSError *error = nil;
|
||||
if (self.errors.count > 0) {
|
||||
error = [NSError
|
||||
errorWithDomain:FIRCLSCompoundOperationErrorDomain
|
||||
code:FIRCLSCompoundOperationErrorCodeSuboperationFailed
|
||||
userInfo:@{FIRCLSCompoundOperationErrorUserInfoKeyUnderlyingErrors : self.errors}];
|
||||
}
|
||||
[self finishWithError:error];
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
39
Pods/FirebaseCrashlytics/Crashlytics/Shared/FIRCLSOperation/FIRCLSFABAsyncOperation.h
generated
Normal file
39
Pods/FirebaseCrashlytics/Crashlytics/Shared/FIRCLSOperation/FIRCLSFABAsyncOperation.h
generated
Normal file
@ -0,0 +1,39 @@
|
||||
// Copyright 2019 Google
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
/**
|
||||
* Completion block that can be called in your subclass implementation. It is up to you when you
|
||||
* want to call it.
|
||||
*/
|
||||
typedef void (^FIRCLSFABAsyncOperationCompletionBlock)(NSError *__nullable error);
|
||||
|
||||
/**
|
||||
* FIRCLSFABAsyncOperation is a subclass of NSOperation that allows for asynchronous work to be
|
||||
* performed, for things like networking, IPC or UI-driven logic. Create your own subclasses to
|
||||
* encapsulate custom logic.
|
||||
* @warning When subclassing to create your own operations, be sure to call -[finishWithError:] at
|
||||
* some point, or program execution will hang.
|
||||
* @see -[finishWithError:] in FIRCLSFABAsyncOperation_Private.h
|
||||
*/
|
||||
@interface FIRCLSFABAsyncOperation : NSOperation
|
||||
|
||||
/**
|
||||
* Add a callback method for consumers of your subclasses to set when the asynchronous work is
|
||||
* marked as complete with -[finishWithError:].
|
||||
*/
|
||||
@property(copy, nonatomic, nullable) FIRCLSFABAsyncOperationCompletionBlock asyncCompletion;
|
||||
|
||||
@end
|
||||
146
Pods/FirebaseCrashlytics/Crashlytics/Shared/FIRCLSOperation/FIRCLSFABAsyncOperation.m
generated
Normal file
146
Pods/FirebaseCrashlytics/Crashlytics/Shared/FIRCLSOperation/FIRCLSFABAsyncOperation.m
generated
Normal file
@ -0,0 +1,146 @@
|
||||
// Copyright 2019 Google
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#import "Crashlytics/Shared/FIRCLSOperation/FIRCLSFABAsyncOperation.h"
|
||||
|
||||
#import "Crashlytics/Shared/FIRCLSOperation/FIRCLSFABAsyncOperation_Private.h"
|
||||
|
||||
@interface FIRCLSFABAsyncOperation () {
|
||||
BOOL _internalExecuting;
|
||||
BOOL _internalFinished;
|
||||
}
|
||||
|
||||
@property(nonatomic, strong) NSRecursiveLock *lock;
|
||||
|
||||
@end
|
||||
|
||||
@implementation FIRCLSFABAsyncOperation
|
||||
|
||||
- (instancetype)init {
|
||||
self = [super init];
|
||||
if (!self) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
_internalExecuting = NO;
|
||||
_internalFinished = NO;
|
||||
|
||||
_lock = [[NSRecursiveLock alloc] init];
|
||||
_lock.name = [NSString stringWithFormat:@"com.google.firebase.crashlytics.%@-lock", [self class]];
|
||||
;
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
#pragma mark - NSOperation Overrides
|
||||
- (BOOL)isConcurrent {
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (BOOL)isAsynchronous {
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (BOOL)isExecuting {
|
||||
[self.lock lock];
|
||||
BOOL result = _internalExecuting;
|
||||
[self.lock unlock];
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
- (BOOL)isFinished {
|
||||
[self.lock lock];
|
||||
BOOL result = _internalFinished;
|
||||
[self.lock unlock];
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
- (void)start {
|
||||
if ([self checkForCancellation]) {
|
||||
return;
|
||||
}
|
||||
|
||||
[self markStarted];
|
||||
|
||||
[self main];
|
||||
}
|
||||
|
||||
#pragma mark - Utilities
|
||||
- (void)changeValueForKey:(NSString *)key inBlock:(void (^)(void))block {
|
||||
[self willChangeValueForKey:key];
|
||||
block();
|
||||
[self didChangeValueForKey:key];
|
||||
}
|
||||
|
||||
- (void)lock:(void (^)(void))block {
|
||||
[self.lock lock];
|
||||
block();
|
||||
[self.lock unlock];
|
||||
}
|
||||
|
||||
- (BOOL)checkForCancellation {
|
||||
if ([self isCancelled]) {
|
||||
[self markDone];
|
||||
return YES;
|
||||
}
|
||||
|
||||
return NO;
|
||||
}
|
||||
|
||||
#pragma mark - State Management
|
||||
- (void)unlockedMarkFinished {
|
||||
[self changeValueForKey:@"isFinished"
|
||||
inBlock:^{
|
||||
self->_internalFinished = YES;
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)unlockedMarkStarted {
|
||||
[self changeValueForKey:@"isExecuting"
|
||||
inBlock:^{
|
||||
self->_internalExecuting = YES;
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)unlockedMarkComplete {
|
||||
[self changeValueForKey:@"isExecuting"
|
||||
inBlock:^{
|
||||
self->_internalExecuting = NO;
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)markStarted {
|
||||
[self lock:^{
|
||||
[self unlockedMarkStarted];
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)markDone {
|
||||
[self lock:^{
|
||||
[self unlockedMarkComplete];
|
||||
[self unlockedMarkFinished];
|
||||
}];
|
||||
}
|
||||
|
||||
#pragma mark - Protected
|
||||
- (void)finishWithError:(NSError *)error {
|
||||
if (self.asyncCompletion) {
|
||||
self.asyncCompletion(error);
|
||||
}
|
||||
[self markDone];
|
||||
}
|
||||
|
||||
@end
|
||||
32
Pods/FirebaseCrashlytics/Crashlytics/Shared/FIRCLSOperation/FIRCLSFABAsyncOperation_Private.h
generated
Normal file
32
Pods/FirebaseCrashlytics/Crashlytics/Shared/FIRCLSOperation/FIRCLSFABAsyncOperation_Private.h
generated
Normal file
@ -0,0 +1,32 @@
|
||||
// Copyright 2019 Google
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#import "Crashlytics/Shared/FIRCLSOperation/FIRCLSFABAsyncOperation.h"
|
||||
|
||||
@interface FIRCLSFABAsyncOperation (Private)
|
||||
|
||||
/**
|
||||
* Subclasses must call this method when they are done performing work. When it is called is up to
|
||||
* you; it can be directly after kicking of a network request, say, or in the callback for its
|
||||
* response. Once this method is called, the operation queue it is on will begin executing the next
|
||||
* waiting operation. If you directly invoked -[start] on the instance, execution will proceed to
|
||||
* the next code statement.
|
||||
* @note as soon as this method is called, @c NSOperation's standard @c completionBlock will be
|
||||
* executed if one exists, as a result of setting the operation's isFinished property to YES, and
|
||||
* the asyncCompletion block is called.
|
||||
* @param error Any error to pass to asyncCompletion, or nil if there is none.
|
||||
*/
|
||||
- (void)finishWithError:(NSError *__nullable)error;
|
||||
|
||||
@end
|
||||
19
Pods/FirebaseCrashlytics/Crashlytics/Shared/FIRCLSOperation/FIRCLSOperation.h
generated
Normal file
19
Pods/FirebaseCrashlytics/Crashlytics/Shared/FIRCLSOperation/FIRCLSOperation.h
generated
Normal file
@ -0,0 +1,19 @@
|
||||
// Copyright 2019 Google
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
#import "Crashlytics/Shared/FIRCLSOperation/FIRCLSCompoundOperation.h"
|
||||
#import "Crashlytics/Shared/FIRCLSOperation/FIRCLSFABAsyncOperation.h"
|
||||
#import "Crashlytics/Shared/FIRCLSOperation/FIRCLSFABAsyncOperation_Private.h"
|
||||
Reference in New Issue
Block a user