Archived
Configured colours and added additional images to ready app for iOS 13 dark mode
This commit is contained in:
Pods/GoogleDataTransportCCTSupport/GoogleDataTransportCCTSupport/GDTCCTLibrary/GDTCCTNanopbHelpers.m
Generated
+14
-13
@@ -22,7 +22,7 @@
|
||||
#import <AppKit/AppKit.h>
|
||||
#endif // TARGET_OS_IOS || TARGET_OS_TV
|
||||
|
||||
#import <GoogleDataTransport/GDTConsoleLogger.h>
|
||||
#import <GoogleDataTransport/GDTCORConsoleLogger.h>
|
||||
|
||||
#import <nanopb/pb.h>
|
||||
#import <nanopb/pb_decode.h>
|
||||
@@ -50,8 +50,8 @@ NSData *_Nullable GDTCCTEncodeBatchedLogRequest(gdt_cct_BatchedLogRequest *batch
|
||||
pb_ostream_t sizestream = PB_OSTREAM_SIZING;
|
||||
// Encode 1 time to determine the size.
|
||||
if (!pb_encode(&sizestream, gdt_cct_BatchedLogRequest_fields, batchedLogRequest)) {
|
||||
GDTLogError(GDTMCEGeneralError, @"Error in nanopb encoding for size: %s",
|
||||
PB_GET_ERROR(&sizestream));
|
||||
GDTCORLogError(GDTCORMCEGeneralError, @"Error in nanopb encoding for size: %s",
|
||||
PB_GET_ERROR(&sizestream));
|
||||
}
|
||||
|
||||
// Encode a 2nd time to actually get the bytes from it.
|
||||
@@ -59,8 +59,8 @@ NSData *_Nullable GDTCCTEncodeBatchedLogRequest(gdt_cct_BatchedLogRequest *batch
|
||||
CFMutableDataRef dataRef = CFDataCreateMutable(CFAllocatorGetDefault(), bufferSize);
|
||||
pb_ostream_t ostream = pb_ostream_from_buffer((void *)CFDataGetBytePtr(dataRef), bufferSize);
|
||||
if (!pb_encode(&ostream, gdt_cct_BatchedLogRequest_fields, batchedLogRequest)) {
|
||||
GDTLogError(GDTMCEGeneralError, @"Error in nanopb encoding for bytes: %s",
|
||||
PB_GET_ERROR(&ostream));
|
||||
GDTCORLogError(GDTCORMCEGeneralError, @"Error in nanopb encoding for bytes: %s",
|
||||
PB_GET_ERROR(&ostream));
|
||||
}
|
||||
CFDataSetLength(dataRef, ostream.bytes_written);
|
||||
|
||||
@@ -68,7 +68,7 @@ NSData *_Nullable GDTCCTEncodeBatchedLogRequest(gdt_cct_BatchedLogRequest *batch
|
||||
}
|
||||
|
||||
gdt_cct_BatchedLogRequest GDTCCTConstructBatchedLogRequest(
|
||||
NSDictionary<NSString *, NSSet<GDTStoredEvent *> *> *logMappingIDToLogSet) {
|
||||
NSDictionary<NSString *, NSSet<GDTCORStoredEvent *> *> *logMappingIDToLogSet) {
|
||||
gdt_cct_BatchedLogRequest batchedLogRequest = gdt_cct_BatchedLogRequest_init_default;
|
||||
NSUInteger numberOfLogRequests = logMappingIDToLogSet.count;
|
||||
gdt_cct_LogRequest *logRequests = malloc(sizeof(gdt_cct_LogRequest) * numberOfLogRequests);
|
||||
@@ -76,7 +76,7 @@ gdt_cct_BatchedLogRequest GDTCCTConstructBatchedLogRequest(
|
||||
__block int i = 0;
|
||||
[logMappingIDToLogSet enumerateKeysAndObjectsUsingBlock:^(
|
||||
NSString *_Nonnull logMappingID,
|
||||
NSSet<GDTStoredEvent *> *_Nonnull logSet, BOOL *_Nonnull stop) {
|
||||
NSSet<GDTCORStoredEvent *> *_Nonnull logSet, BOOL *_Nonnull stop) {
|
||||
int32_t logSource = [logMappingID intValue];
|
||||
gdt_cct_LogRequest logRequest = GDTCCTConstructLogRequest(logSource, logSet);
|
||||
logRequests[i] = logRequest;
|
||||
@@ -89,9 +89,10 @@ gdt_cct_BatchedLogRequest GDTCCTConstructBatchedLogRequest(
|
||||
}
|
||||
|
||||
gdt_cct_LogRequest GDTCCTConstructLogRequest(int32_t logSource,
|
||||
NSSet<GDTStoredEvent *> *_Nonnull logSet) {
|
||||
NSSet<GDTCORStoredEvent *> *_Nonnull logSet) {
|
||||
if (logSet.count == 0) {
|
||||
GDTLogError(GDTMCEGeneralError, @"%@", @"An empty event set can't be serialized to proto.");
|
||||
GDTCORLogError(GDTCORMCEGeneralError, @"%@",
|
||||
@"An empty event set can't be serialized to proto.");
|
||||
gdt_cct_LogRequest logRequest = gdt_cct_LogRequest_init_default;
|
||||
return logRequest;
|
||||
}
|
||||
@@ -102,7 +103,7 @@ gdt_cct_LogRequest GDTCCTConstructLogRequest(int32_t logSource,
|
||||
logRequest.has_client_info = 1;
|
||||
logRequest.log_event = malloc(sizeof(gdt_cct_LogEvent) * logSet.count);
|
||||
int i = 0;
|
||||
for (GDTStoredEvent *log in logSet) {
|
||||
for (GDTCORStoredEvent *log in logSet) {
|
||||
gdt_cct_LogEvent logEvent = GDTCCTConstructLogEvent(log);
|
||||
logRequest.log_event[i] = logEvent;
|
||||
i++;
|
||||
@@ -112,7 +113,7 @@ gdt_cct_LogRequest GDTCCTConstructLogRequest(int32_t logSource,
|
||||
return logRequest;
|
||||
}
|
||||
|
||||
gdt_cct_LogEvent GDTCCTConstructLogEvent(GDTStoredEvent *event) {
|
||||
gdt_cct_LogEvent GDTCCTConstructLogEvent(GDTCORStoredEvent *event) {
|
||||
gdt_cct_LogEvent logEvent = gdt_cct_LogEvent_init_default;
|
||||
logEvent.event_time_ms = event.clockSnapshot.timeMillis;
|
||||
logEvent.has_event_time_ms = 1;
|
||||
@@ -127,8 +128,8 @@ gdt_cct_LogEvent GDTCCTConstructLogEvent(GDTStoredEvent *event) {
|
||||
options:0
|
||||
error:&error];
|
||||
if (error) {
|
||||
GDTLogError(GDTMCEGeneralError, @"There was an error reading extension bytes from disk: %@",
|
||||
error);
|
||||
GDTCORLogError(GDTCORMCEGeneralError,
|
||||
@"There was an error reading extension bytes from disk: %@", error);
|
||||
return logEvent;
|
||||
}
|
||||
logEvent.source_extension = GDTCCTEncodeData(extensionBytes); // read bytes from the file.
|
||||
|
||||
Generated
+37
-37
@@ -16,10 +16,10 @@
|
||||
|
||||
#import "GDTCCTLibrary/Private/GDTCCTPrioritizer.h"
|
||||
|
||||
#import <GoogleDataTransport/GDTEvent.h>
|
||||
#import <GoogleDataTransport/GDTRegistrar.h>
|
||||
#import <GoogleDataTransport/GDTStoredEvent.h>
|
||||
#import <GoogleDataTransport/GDTTargets.h>
|
||||
#import <GoogleDataTransport/GDTCOREvent.h>
|
||||
#import <GoogleDataTransport/GDTCORRegistrar.h>
|
||||
#import <GoogleDataTransport/GDTCORStoredEvent.h>
|
||||
#import <GoogleDataTransport/GDTCORTargets.h>
|
||||
|
||||
const static int64_t kMillisPerDay = 8.64e+7;
|
||||
|
||||
@@ -27,7 +27,7 @@ const static int64_t kMillisPerDay = 8.64e+7;
|
||||
|
||||
+ (void)load {
|
||||
GDTCCTPrioritizer *prioritizer = [GDTCCTPrioritizer sharedInstance];
|
||||
[[GDTRegistrar sharedInstance] registerPrioritizer:prioritizer target:kGDTTargetCCT];
|
||||
[[GDTCORRegistrar sharedInstance] registerPrioritizer:prioritizer target:kGDTCORTargetCCT];
|
||||
}
|
||||
|
||||
+ (instancetype)sharedInstance {
|
||||
@@ -48,26 +48,26 @@ const static int64_t kMillisPerDay = 8.64e+7;
|
||||
return self;
|
||||
}
|
||||
|
||||
#pragma mark - GDTPrioritizer Protocol
|
||||
#pragma mark - GDTCORPrioritizer Protocol
|
||||
|
||||
- (void)prioritizeEvent:(GDTStoredEvent *)event {
|
||||
- (void)prioritizeEvent:(GDTCORStoredEvent *)event {
|
||||
dispatch_async(_queue, ^{
|
||||
[self.events addObject:event];
|
||||
});
|
||||
}
|
||||
|
||||
- (GDTUploadPackage *)uploadPackageWithConditions:(GDTUploadConditions)conditions {
|
||||
GDTUploadPackage *package = [[GDTUploadPackage alloc] initWithTarget:kGDTTargetCCT];
|
||||
- (GDTCORUploadPackage *)uploadPackageWithConditions:(GDTCORUploadConditions)conditions {
|
||||
GDTCORUploadPackage *package = [[GDTCORUploadPackage alloc] initWithTarget:kGDTCORTargetCCT];
|
||||
dispatch_sync(_queue, ^{
|
||||
NSSet<GDTStoredEvent *> *logEventsThatWillBeSent;
|
||||
NSSet<GDTCORStoredEvent *> *logEventsThatWillBeSent;
|
||||
// A high priority event effectively flushes all events to be sent.
|
||||
if ((conditions & GDTUploadConditionHighPriority) == GDTUploadConditionHighPriority) {
|
||||
if ((conditions & GDTCORUploadConditionHighPriority) == GDTCORUploadConditionHighPriority) {
|
||||
package.events = self.events;
|
||||
return;
|
||||
}
|
||||
|
||||
// If on wifi, upload logs that are ok to send on wifi.
|
||||
if ((conditions & GDTUploadConditionWifiData) == GDTUploadConditionWifiData) {
|
||||
if ((conditions & GDTCORUploadConditionWifiData) == GDTCORUploadConditionWifiData) {
|
||||
logEventsThatWillBeSent = [self logEventsOkToSendOnWifi];
|
||||
} else {
|
||||
logEventsThatWillBeSent = [self logEventsOkToSendOnMobileData];
|
||||
@@ -76,13 +76,13 @@ const static int64_t kMillisPerDay = 8.64e+7;
|
||||
// If it's been > 24h since the last daily upload, upload logs with the daily QoS.
|
||||
if (self.timeOfLastDailyUpload) {
|
||||
int64_t millisSinceLastUpload =
|
||||
[GDTClock snapshot].timeMillis - self.timeOfLastDailyUpload.timeMillis;
|
||||
[GDTCORClock snapshot].timeMillis - self.timeOfLastDailyUpload.timeMillis;
|
||||
if (millisSinceLastUpload > kMillisPerDay) {
|
||||
logEventsThatWillBeSent =
|
||||
[logEventsThatWillBeSent setByAddingObjectsFromSet:[self logEventsOkToSendDaily]];
|
||||
}
|
||||
} else {
|
||||
self.timeOfLastDailyUpload = [GDTClock snapshot];
|
||||
self.timeOfLastDailyUpload = [GDTCORClock snapshot];
|
||||
logEventsThatWillBeSent =
|
||||
[logEventsThatWillBeSent setByAddingObjectsFromSet:[self logEventsOkToSendDaily]];
|
||||
}
|
||||
@@ -108,21 +108,21 @@ typedef NS_ENUM(NSInteger, GDTCCTQoSTier) {
|
||||
GDTCCTQoSWifiOnly = 5,
|
||||
};
|
||||
|
||||
/** Converts a GDTEventQoS to a GDTCCTQoS tier.
|
||||
/** Converts a GDTCOREventQoS to a GDTCCTQoS tier.
|
||||
*
|
||||
* @param qosTier The GDTEventQoS value.
|
||||
* @param qosTier The GDTCOREventQoS value.
|
||||
* @return A static NSNumber that represents the CCT QoS tier.
|
||||
*/
|
||||
FOUNDATION_STATIC_INLINE
|
||||
NSNumber *GDTCCTQosTierFromGDTEventQosTier(GDTEventQoS qosTier) {
|
||||
NSNumber *GDTCCTQosTierFromGDTCOREventQosTier(GDTCOREventQoS qosTier) {
|
||||
switch (qosTier) {
|
||||
case GDTEventQoSWifiOnly:
|
||||
case GDTCOREventQoSWifiOnly:
|
||||
return @(GDTCCTQoSWifiOnly);
|
||||
break;
|
||||
|
||||
case GDTEventQoSTelemetry:
|
||||
case GDTCOREventQoSTelemetry:
|
||||
// falls through.
|
||||
case GDTEventQoSDaily:
|
||||
case GDTCOREventQoSDaily:
|
||||
return @(GDTCCTQoSDaily);
|
||||
break;
|
||||
|
||||
@@ -137,10 +137,10 @@ NSNumber *GDTCCTQosTierFromGDTEventQosTier(GDTEventQoS qosTier) {
|
||||
* @note This should be called from a thread safe method.
|
||||
* @return A set of logs that are ok to upload whilst on mobile data.
|
||||
*/
|
||||
- (NSSet<GDTStoredEvent *> *)logEventsOkToSendOnMobileData {
|
||||
return
|
||||
[self.events objectsPassingTest:^BOOL(GDTStoredEvent *_Nonnull event, BOOL *_Nonnull stop) {
|
||||
return [GDTCCTQosTierFromGDTEventQosTier(event.qosTier) isEqual:@(GDTCCTQoSDefault)];
|
||||
- (NSSet<GDTCORStoredEvent *> *)logEventsOkToSendOnMobileData {
|
||||
return [self.events
|
||||
objectsPassingTest:^BOOL(GDTCORStoredEvent *_Nonnull event, BOOL *_Nonnull stop) {
|
||||
return [GDTCCTQosTierFromGDTCOREventQosTier(event.qosTier) isEqual:@(GDTCCTQoSDefault)];
|
||||
}];
|
||||
}
|
||||
|
||||
@@ -149,10 +149,10 @@ NSNumber *GDTCCTQosTierFromGDTEventQosTier(GDTEventQoS qosTier) {
|
||||
* @note This should be called from a thread safe method.
|
||||
* @return A set of logs that are ok to upload whilst on wifi.
|
||||
*/
|
||||
- (NSSet<GDTStoredEvent *> *)logEventsOkToSendOnWifi {
|
||||
return
|
||||
[self.events objectsPassingTest:^BOOL(GDTStoredEvent *_Nonnull event, BOOL *_Nonnull stop) {
|
||||
NSNumber *qosTier = GDTCCTQosTierFromGDTEventQosTier(event.qosTier);
|
||||
- (NSSet<GDTCORStoredEvent *> *)logEventsOkToSendOnWifi {
|
||||
return [self.events
|
||||
objectsPassingTest:^BOOL(GDTCORStoredEvent *_Nonnull event, BOOL *_Nonnull stop) {
|
||||
NSNumber *qosTier = GDTCCTQosTierFromGDTCOREventQosTier(event.qosTier);
|
||||
return [qosTier isEqual:@(GDTCCTQoSDefault)] || [qosTier isEqual:@(GDTCCTQoSWifiOnly)] ||
|
||||
[qosTier isEqual:@(GDTCCTQoSDaily)];
|
||||
}];
|
||||
@@ -163,25 +163,25 @@ NSNumber *GDTCCTQosTierFromGDTEventQosTier(GDTEventQoS qosTier) {
|
||||
* @note This should be called from a thread safe method.
|
||||
* @return A set of logs that are ok to upload only once per day.
|
||||
*/
|
||||
- (NSSet<GDTStoredEvent *> *)logEventsOkToSendDaily {
|
||||
return
|
||||
[self.events objectsPassingTest:^BOOL(GDTStoredEvent *_Nonnull event, BOOL *_Nonnull stop) {
|
||||
return [GDTCCTQosTierFromGDTEventQosTier(event.qosTier) isEqual:@(GDTCCTQoSDaily)];
|
||||
- (NSSet<GDTCORStoredEvent *> *)logEventsOkToSendDaily {
|
||||
return [self.events
|
||||
objectsPassingTest:^BOOL(GDTCORStoredEvent *_Nonnull event, BOOL *_Nonnull stop) {
|
||||
return [GDTCCTQosTierFromGDTCOREventQosTier(event.qosTier) isEqual:@(GDTCCTQoSDaily)];
|
||||
}];
|
||||
}
|
||||
|
||||
#pragma mark - GDTUploadPackageProtocol
|
||||
#pragma mark - GDTCORUploadPackageProtocol
|
||||
|
||||
- (void)packageDelivered:(GDTUploadPackage *)package successful:(BOOL)successful {
|
||||
- (void)packageDelivered:(GDTCORUploadPackage *)package successful:(BOOL)successful {
|
||||
dispatch_async(_queue, ^{
|
||||
NSSet<GDTStoredEvent *> *events = [package.events copy];
|
||||
for (GDTStoredEvent *event in events) {
|
||||
NSSet<GDTCORStoredEvent *> *events = [package.events copy];
|
||||
for (GDTCORStoredEvent *event in events) {
|
||||
[self.events removeObject:event];
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
- (void)packageExpired:(GDTUploadPackage *)package {
|
||||
- (void)packageExpired:(GDTCORUploadPackage *)package {
|
||||
[self packageDelivered:package successful:YES];
|
||||
}
|
||||
|
||||
|
||||
Generated
+68
-46
@@ -16,9 +16,9 @@
|
||||
|
||||
#import "GDTCCTLibrary/Private/GDTCCTUploader.h"
|
||||
|
||||
#import <GoogleDataTransport/GDTConsoleLogger.h>
|
||||
#import <GoogleDataTransport/GDTPlatform.h>
|
||||
#import <GoogleDataTransport/GDTRegistrar.h>
|
||||
#import <GoogleDataTransport/GDTCORConsoleLogger.h>
|
||||
#import <GoogleDataTransport/GDTCORPlatform.h>
|
||||
#import <GoogleDataTransport/GDTCORRegistrar.h>
|
||||
|
||||
#import <nanopb/pb.h>
|
||||
#import <nanopb/pb_decode.h>
|
||||
@@ -35,7 +35,7 @@
|
||||
@property(nullable, nonatomic, readwrite) NSURLSessionUploadTask *currentTask;
|
||||
|
||||
/** If running in the background, the current background ID. */
|
||||
@property(nonatomic) GDTBackgroundIdentifier backgroundID;
|
||||
@property(nonatomic) BOOL runningInBackground;
|
||||
|
||||
@end
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
|
||||
+ (void)load {
|
||||
GDTCCTUploader *uploader = [GDTCCTUploader sharedInstance];
|
||||
[[GDTRegistrar sharedInstance] registerUploader:uploader target:kGDTTargetCCT];
|
||||
[[GDTCORRegistrar sharedInstance] registerUploader:uploader target:kGDTCORTargetCCT];
|
||||
}
|
||||
|
||||
+ (instancetype)sharedInstance {
|
||||
@@ -61,7 +61,6 @@
|
||||
_uploaderQueue = dispatch_queue_create("com.google.GDTCCTUploader", DISPATCH_QUEUE_SERIAL);
|
||||
NSURLSessionConfiguration *config = [NSURLSessionConfiguration defaultSessionConfiguration];
|
||||
_uploaderSession = [NSURLSession sessionWithConfiguration:config];
|
||||
_backgroundID = GDTBackgroundIdentifierInvalid;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
@@ -85,42 +84,53 @@
|
||||
return defaultServerURL;
|
||||
}
|
||||
|
||||
- (void)uploadPackage:(GDTUploadPackage *)package {
|
||||
- (void)uploadPackage:(GDTCORUploadPackage *)package {
|
||||
GDTCORBackgroundIdentifier bgID = GDTCORBackgroundIdentifierInvalid;
|
||||
if (_runningInBackground) {
|
||||
bgID = [[GDTCORApplication sharedApplication] beginBackgroundTaskWithExpirationHandler:^{
|
||||
if (bgID != GDTCORBackgroundIdentifierInvalid) {
|
||||
[[GDTCORApplication sharedApplication] endBackgroundTask:bgID];
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
dispatch_async(_uploaderQueue, ^{
|
||||
if (self->_currentTask || self->_currentUploadPackage) {
|
||||
GDTLogWarning(GDTMCWUploadFailed, @"%@",
|
||||
@"An upload shouldn't be initiated with another in progress.");
|
||||
GDTCORLogWarning(GDTCORMCWUploadFailed, @"%@",
|
||||
@"An upload shouldn't be initiated with another in progress.");
|
||||
return;
|
||||
}
|
||||
NSURL *serverURL = self.serverURL ? self.serverURL : [self defaultServerURL];
|
||||
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:serverURL];
|
||||
request.HTTPMethod = @"POST";
|
||||
|
||||
id completionHandler =
|
||||
^(NSData *_Nullable data, NSURLResponse *_Nullable response, NSError *_Nullable error) {
|
||||
if (error) {
|
||||
GDTLogWarning(GDTMCWUploadFailed, @"There was an error uploading events: %@", error);
|
||||
}
|
||||
NSError *decodingError;
|
||||
gdt_cct_LogResponse logResponse = GDTCCTDecodeLogResponse(data, &decodingError);
|
||||
if (!decodingError && logResponse.has_next_request_wait_millis) {
|
||||
self->_nextUploadTime =
|
||||
[GDTClock clockSnapshotInTheFuture:logResponse.next_request_wait_millis];
|
||||
} else {
|
||||
// 15 minutes from now.
|
||||
self->_nextUploadTime = [GDTClock clockSnapshotInTheFuture:15 * 60 * 1000];
|
||||
}
|
||||
pb_release(gdt_cct_LogResponse_fields, &logResponse);
|
||||
[package completeDelivery];
|
||||
if (self->_backgroundID != GDTBackgroundIdentifierInvalid) {
|
||||
[[GDTApplication sharedApplication] endBackgroundTask:self->_backgroundID];
|
||||
self->_backgroundID = GDTBackgroundIdentifierInvalid;
|
||||
}
|
||||
self.currentTask = nil;
|
||||
self.currentUploadPackage = nil;
|
||||
};
|
||||
id completionHandler = ^(NSData *_Nullable data, NSURLResponse *_Nullable response,
|
||||
NSError *_Nullable error) {
|
||||
if (error) {
|
||||
GDTCORLogWarning(GDTCORMCWUploadFailed, @"There was an error uploading events: %@", error);
|
||||
}
|
||||
NSError *decodingError;
|
||||
gdt_cct_LogResponse logResponse = GDTCCTDecodeLogResponse(data, &decodingError);
|
||||
if (!decodingError && logResponse.has_next_request_wait_millis) {
|
||||
self->_nextUploadTime =
|
||||
[GDTCORClock clockSnapshotInTheFuture:logResponse.next_request_wait_millis];
|
||||
} else {
|
||||
// 15 minutes from now.
|
||||
self->_nextUploadTime = [GDTCORClock clockSnapshotInTheFuture:15 * 60 * 1000];
|
||||
}
|
||||
pb_release(gdt_cct_LogResponse_fields, &logResponse);
|
||||
[package completeDelivery];
|
||||
|
||||
// End the background task if there was one.
|
||||
if (bgID != GDTCORBackgroundIdentifierInvalid) {
|
||||
[[GDTCORApplication sharedApplication] endBackgroundTask:bgID];
|
||||
}
|
||||
self.currentTask = nil;
|
||||
self.currentUploadPackage = nil;
|
||||
};
|
||||
self->_currentUploadPackage = package;
|
||||
NSData *requestProtoData = [self constructRequestProtoFromPackage:(GDTUploadPackage *)package];
|
||||
NSData *requestProtoData =
|
||||
[self constructRequestProtoFromPackage:(GDTCORUploadPackage *)package];
|
||||
self.currentTask = [self.uploaderSession uploadTaskWithRequest:request
|
||||
fromData:requestProtoData
|
||||
completionHandler:completionHandler];
|
||||
@@ -128,7 +138,7 @@
|
||||
});
|
||||
}
|
||||
|
||||
- (BOOL)readyToUploadWithConditions:(GDTUploadConditions)conditions {
|
||||
- (BOOL)readyToUploadWithConditions:(GDTCORUploadConditions)conditions {
|
||||
__block BOOL result = NO;
|
||||
dispatch_sync(_uploaderQueue, ^{
|
||||
if (self->_currentUploadPackage) {
|
||||
@@ -139,11 +149,11 @@
|
||||
result = NO;
|
||||
return;
|
||||
}
|
||||
if ((conditions & GDTUploadConditionHighPriority) == GDTUploadConditionHighPriority) {
|
||||
if ((conditions & GDTCORUploadConditionHighPriority) == GDTCORUploadConditionHighPriority) {
|
||||
result = YES;
|
||||
return;
|
||||
} else if (self->_nextUploadTime) {
|
||||
result = [[GDTClock snapshot] isAfter:self->_nextUploadTime];
|
||||
result = [[GDTCORClock snapshot] isAfter:self->_nextUploadTime];
|
||||
return;
|
||||
}
|
||||
result = YES;
|
||||
@@ -158,12 +168,12 @@
|
||||
* @param package The upload package used to construct the request proto bytes.
|
||||
* @return Proto bytes representing a gdt_cct_LogRequest object.
|
||||
*/
|
||||
- (nonnull NSData *)constructRequestProtoFromPackage:(GDTUploadPackage *)package {
|
||||
- (nonnull NSData *)constructRequestProtoFromPackage:(GDTCORUploadPackage *)package {
|
||||
// Segment the log events by log type.
|
||||
NSMutableDictionary<NSString *, NSMutableSet<GDTStoredEvent *> *> *logMappingIDToLogSet =
|
||||
NSMutableDictionary<NSString *, NSMutableSet<GDTCORStoredEvent *> *> *logMappingIDToLogSet =
|
||||
[[NSMutableDictionary alloc] init];
|
||||
[package.events
|
||||
enumerateObjectsUsingBlock:^(GDTStoredEvent *_Nonnull event, BOOL *_Nonnull stop) {
|
||||
enumerateObjectsUsingBlock:^(GDTCORStoredEvent *_Nonnull event, BOOL *_Nonnull stop) {
|
||||
NSMutableSet *logSet = logMappingIDToLogSet[event.mappingID];
|
||||
logSet = logSet ? logSet : [[NSMutableSet alloc] init];
|
||||
[logSet addObject:event];
|
||||
@@ -178,9 +188,9 @@
|
||||
return data ? data : [[NSData alloc] init];
|
||||
}
|
||||
|
||||
#pragma mark - GDTUploadPackageProtocol
|
||||
#pragma mark - GDTCORUploadPackageProtocol
|
||||
|
||||
- (void)packageExpired:(GDTUploadPackage *)package {
|
||||
- (void)packageExpired:(GDTCORUploadPackage *)package {
|
||||
dispatch_async(_uploaderQueue, ^{
|
||||
[self.currentTask cancel];
|
||||
self.currentTask = nil;
|
||||
@@ -188,15 +198,27 @@
|
||||
});
|
||||
}
|
||||
|
||||
#pragma mark - GDTLifecycleProtocol
|
||||
#pragma mark - GDTCORLifecycleProtocol
|
||||
|
||||
- (void)appWillBackground:(GDTApplication *)app {
|
||||
_backgroundID = [app beginBackgroundTaskWithExpirationHandler:^{
|
||||
[app endBackgroundTask:self->_backgroundID];
|
||||
- (void)appWillBackground:(GDTCORApplication *)app {
|
||||
_runningInBackground = YES;
|
||||
__block GDTCORBackgroundIdentifier bgID = [app beginBackgroundTaskWithExpirationHandler:^{
|
||||
if (bgID != GDTCORBackgroundIdentifierInvalid) {
|
||||
[app endBackgroundTask:bgID];
|
||||
}
|
||||
}];
|
||||
if (bgID != GDTCORBackgroundIdentifierInvalid) {
|
||||
dispatch_async(_uploaderQueue, ^{
|
||||
[[GDTCORApplication sharedApplication] endBackgroundTask:bgID];
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
- (void)appWillTerminate:(GDTApplication *)application {
|
||||
- (void)appWillForeground:(GDTCORApplication *)app {
|
||||
_runningInBackground = NO;
|
||||
}
|
||||
|
||||
- (void)appWillTerminate:(GDTCORApplication *)application {
|
||||
dispatch_sync(_uploaderQueue, ^{
|
||||
[self.currentTask cancel];
|
||||
[self.currentUploadPackage completeDelivery];
|
||||
|
||||
+6
-6
@@ -16,7 +16,7 @@
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
#import <GoogleDataTransport/GDTStoredEvent.h>
|
||||
#import <GoogleDataTransport/GDTCORStoredEvent.h>
|
||||
|
||||
#import "GDTCCTLibrary/Protogen/nanopb/cct.nanopb.h"
|
||||
|
||||
@@ -63,7 +63,7 @@ NSData *GDTCCTEncodeBatchedLogRequest(gdt_cct_BatchedLogRequest *batchedLogReque
|
||||
*/
|
||||
FOUNDATION_EXPORT
|
||||
gdt_cct_BatchedLogRequest GDTCCTConstructBatchedLogRequest(
|
||||
NSDictionary<NSString *, NSSet<GDTStoredEvent *> *> *logMappingIDToLogSet);
|
||||
NSDictionary<NSString *, NSSet<GDTCORStoredEvent *> *> *logMappingIDToLogSet);
|
||||
|
||||
/** Constructs a log request given a log source and a set of events.
|
||||
*
|
||||
@@ -72,15 +72,15 @@ gdt_cct_BatchedLogRequest GDTCCTConstructBatchedLogRequest(
|
||||
* @param logSet The set of events to send in this log request.
|
||||
*/
|
||||
FOUNDATION_EXPORT
|
||||
gdt_cct_LogRequest GDTCCTConstructLogRequest(int32_t logSource, NSSet<GDTStoredEvent *> *logSet);
|
||||
gdt_cct_LogRequest GDTCCTConstructLogRequest(int32_t logSource, NSSet<GDTCORStoredEvent *> *logSet);
|
||||
|
||||
/** Constructs a gdt_cct_LogEvent given a GDTStoredEvent*.
|
||||
/** Constructs a gdt_cct_LogEvent given a GDTCORStoredEvent*.
|
||||
*
|
||||
* @param event The GDTStoredEvent to convert.
|
||||
* @param event The GDTCORStoredEvent to convert.
|
||||
* @return The new gdt_cct_LogEvent object.
|
||||
*/
|
||||
FOUNDATION_EXPORT
|
||||
gdt_cct_LogEvent GDTCCTConstructLogEvent(GDTStoredEvent *event);
|
||||
gdt_cct_LogEvent GDTCCTConstructLogEvent(GDTCORStoredEvent *event);
|
||||
|
||||
/** Constructs a gdt_cct_ClientInfo representing the client device.
|
||||
*
|
||||
|
||||
+5
-5
@@ -16,22 +16,22 @@
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
#import <GoogleDataTransport/GDTClock.h>
|
||||
#import <GoogleDataTransport/GDTPrioritizer.h>
|
||||
#import <GoogleDataTransport/GDTCORClock.h>
|
||||
#import <GoogleDataTransport/GDTCORPrioritizer.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/** Manages the prioritization of events from GoogleDataTransport. */
|
||||
@interface GDTCCTPrioritizer : NSObject <GDTPrioritizer>
|
||||
@interface GDTCCTPrioritizer : NSObject <GDTCORPrioritizer>
|
||||
|
||||
/** The queue on which this prioritizer operates. */
|
||||
@property(nonatomic) dispatch_queue_t queue;
|
||||
|
||||
/** All log events that have been processed by this prioritizer. */
|
||||
@property(nonatomic) NSMutableSet<GDTStoredEvent *> *events;
|
||||
@property(nonatomic) NSMutableSet<GDTCORStoredEvent *> *events;
|
||||
|
||||
/** The most recent attempted upload of daily uploaded logs. */
|
||||
@property(nonatomic) GDTClock *timeOfLastDailyUpload;
|
||||
@property(nonatomic) GDTCORClock *timeOfLastDailyUpload;
|
||||
|
||||
/** Creates and/or returns the singleton instance of this class.
|
||||
*
|
||||
|
||||
+4
-4
@@ -16,12 +16,12 @@
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
#import <GoogleDataTransport/GDTUploader.h>
|
||||
#import <GoogleDataTransport/GDTCORUploader.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/** Class capable of uploading events to the CCT backend. */
|
||||
@interface GDTCCTUploader : NSObject <GDTUploader>
|
||||
@interface GDTCCTUploader : NSObject <GDTCORUploader>
|
||||
|
||||
/** The queue on which all CCT uploading will occur. */
|
||||
@property(nonatomic, readonly) dispatch_queue_t uploaderQueue;
|
||||
@@ -36,10 +36,10 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
@property(nullable, nonatomic, readonly) NSURLSessionUploadTask *currentTask;
|
||||
|
||||
/** Current upload package. */
|
||||
@property(nullable, nonatomic) GDTUploadPackage *currentUploadPackage;
|
||||
@property(nullable, nonatomic) GDTCORUploadPackage *currentUploadPackage;
|
||||
|
||||
/** The next upload time. */
|
||||
@property(nullable, nonatomic) GDTClock *nextUploadTime;
|
||||
@property(nullable, nonatomic) GDTCORClock *nextUploadTime;
|
||||
|
||||
/** Creates and/or returns the singleton instance of this class.
|
||||
*
|
||||
|
||||
+17
-10
@@ -1,9 +1,10 @@
|
||||
# Firebase iOS Open Source Development [](https://travis-ci.org/firebase/firebase-ios-sdk)
|
||||
|
||||
This repository contains a subset of the Firebase iOS SDK source. It currently
|
||||
includes FirebaseCore, FirebaseAuth, FirebaseDatabase, FirebaseFirestore,
|
||||
FirebaseFunctions, FirebaseInstanceID, FirebaseInAppMessaging,
|
||||
FirebaseInAppMessagingDisplay, FirebaseMessaging and FirebaseStorage.
|
||||
includes FirebaseCore, FirebaseABTesting, FirebaseAuth, FirebaseDatabase,
|
||||
FirebaseFirestore, FirebaseFunctions, FirebaseInstanceID, FirebaseInAppMessaging,
|
||||
FirebaseInAppMessagingDisplay, FirebaseMessaging, FirebaseRemoteConfig, and
|
||||
FirebaseStorage.
|
||||
|
||||
The repository also includes GoogleUtilities source. The
|
||||
[GoogleUtilities](GoogleUtilities/README.md) pod is
|
||||
@@ -80,9 +81,8 @@ For the pod that you want to develop:
|
||||
|
||||
`pod gen Firebase{name here}.podspec --local-sources=./ --auto-open`
|
||||
|
||||
Firestore and Functions have self contained Xcode projects. See
|
||||
[Firestore/README.md](Firestore/README.md) and
|
||||
[Functions/README.md](Functions/README.md).
|
||||
Firestore has a self contained Xcode project. See
|
||||
[Firestore/README.md](Firestore/README.md).
|
||||
|
||||
### Adding a New Firebase Pod
|
||||
|
||||
@@ -99,13 +99,17 @@ Travis will verify that any code changes are done in a style compliant way. Inst
|
||||
These commands will get the right versions:
|
||||
|
||||
```
|
||||
brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/773cb75d360b58f32048f5964038d09825a507c8/Formula/clang-format.rb
|
||||
brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/3dfea1004e0736754bbf49673cca8aaed8a94089/Formula/swiftformat.rb
|
||||
brew upgrade https://raw.githubusercontent.com/Homebrew/homebrew-core/e3496d9/Formula/clang-format.rb
|
||||
brew upgrade https://raw.githubusercontent.com/Homebrew/homebrew-core/7963c3d/Formula/swiftformat.rb
|
||||
```
|
||||
|
||||
Note: if you already have a newer version of these installed you may need to
|
||||
`brew switch` to this version.
|
||||
|
||||
To update this section, find the versions of clang-format and swiftformat.rb to
|
||||
match the versions in the CI failure logs
|
||||
[here](https://github.com/Homebrew/homebrew-core/tree/master/Formula).
|
||||
|
||||
### Running Unit Tests
|
||||
|
||||
Select a scheme and press Command-u to build a component and run its unit tests.
|
||||
@@ -179,8 +183,9 @@ very grateful! We'd like to empower as many developers as we can to be able to
|
||||
participate in the Firebase community.
|
||||
|
||||
### macOS and tvOS
|
||||
Thanks to contributions from the community, FirebaseAuth, FirebaseCore, FirebaseDatabase, FirebaseMessaging,
|
||||
FirebaseFirestore, FirebaseFunctions and FirebaseStorage now compile, run unit tests, and work on
|
||||
Thanks to contributions from the community, FirebaseABTesting, FirebaseAuth, FirebaseCore,
|
||||
FirebaseDatabase, FirebaseMessaging, FirebaseFirestore,
|
||||
FirebaseFunctions, FirebaseRemoteConfig, and FirebaseStorage now compile, run unit tests, and work on
|
||||
macOS and tvOS.
|
||||
|
||||
For tvOS, checkout the [Sample](Example/tvOSSample).
|
||||
@@ -195,12 +200,14 @@ Note that the Firebase pod is not available for macOS and tvOS.
|
||||
To install, add a subset of the following to the Podfile:
|
||||
|
||||
```
|
||||
pod 'FirebaseABTesting'
|
||||
pod 'FirebaseAuth'
|
||||
pod 'FirebaseCore'
|
||||
pod 'FirebaseDatabase'
|
||||
pod 'FirebaseFirestore'
|
||||
pod 'FirebaseFunctions'
|
||||
pod 'FirebaseMessaging'
|
||||
pod 'FirebaseRemoteConfig'
|
||||
pod 'FirebaseStorage'
|
||||
```
|
||||
|
||||
|
||||
Reference in New Issue
Block a user