Skip to content

Commit b05be68

Browse files
GDTCCTUploader: lazy initialize url session, use ephemeral session (#6870)
* GDTCCTUploader: lazy initialize url session, use ephemeral session * Changelog * typo
1 parent 6c91a8f commit b05be68

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

GoogleDataTransport/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Unreleased
22
- Remove `GCC_TREAT_WARNINGS_AS_ERRORS` from the podspec.
3+
- Reduce pre-main startup time footprint. (#6855)
34

45
# v8.0.0
56
- Source restructuring to limit the public API surface.

GoogleDataTransport/GDTCCTLibrary/GDTCCTUploader.m

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ @interface GDTCCTUploader () <NSURLSessionDelegate>
8080

8181
@implementation GDTCCTUploader
8282

83+
@synthesize uploaderSession = _uploaderSession;
84+
8385
+ (void)load {
8486
GDTCCTUploader *uploader = [GDTCCTUploader sharedInstance];
8587
[[GDTCORRegistrar sharedInstance] registerUploader:uploader target:kGDTCORTargetCCT];
@@ -101,12 +103,18 @@ - (instancetype)init {
101103
self = [super init];
102104
if (self) {
103105
_uploaderQueue = dispatch_queue_create("com.google.GDTCCTUploader", DISPATCH_QUEUE_SERIAL);
104-
NSURLSessionConfiguration *config = [NSURLSessionConfiguration defaultSessionConfiguration];
106+
}
107+
return self;
108+
}
109+
110+
- (NSURLSession *)uploaderSession {
111+
if (_uploaderSession == nil) {
112+
NSURLSessionConfiguration *config = [NSURLSessionConfiguration ephemeralSessionConfiguration];
105113
_uploaderSession = [NSURLSession sessionWithConfiguration:config
106114
delegate:self
107115
delegateQueue:nil];
108116
}
109-
return self;
117+
return _uploaderSession;
110118
}
111119

112120
/**

0 commit comments

Comments
 (0)