Skip to content

Commit e1557cf

Browse files
authored
s/GDLUploader->GDLUploadCoordinator/g and s/GDLLogBackend/GDLLogUploader (#2256)
1 parent 6e95364 commit e1557cf

15 files changed

+50
-38
lines changed

GoogleDataLogger/GoogleDataLogger/Classes/GDLLogStorage.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
#import "GDLConsoleLogger.h"
2424
#import "GDLLogEvent_Private.h"
2525
#import "GDLRegistrar_Private.h"
26-
#import "GDLUploader.h"
26+
#import "GDLUploadCoordinator.h"
2727

2828
/** Creates and/or returns a singleton NSString that is the shared logging path.
2929
*
@@ -57,7 +57,7 @@ - (instancetype)init {
5757
_storageQueue = dispatch_queue_create("com.google.GDLLogStorage", DISPATCH_QUEUE_SERIAL);
5858
_logHashToLogFile = [[NSMutableDictionary alloc] init];
5959
_logTargetToLogFileSet = [[NSMutableDictionary alloc] init];
60-
_uploader = [GDLUploader sharedInstance];
60+
_uploader = [GDLUploadCoordinator sharedInstance];
6161
}
6262
return self;
6363
}

GoogleDataLogger/GoogleDataLogger/Classes/GDLRegistrar.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,12 @@ - (instancetype)init {
3838
return self;
3939
}
4040

41-
- (void)registerBackend:(id<GDLLogBackend>)backend forLogTarget:(NSInteger)logTarget {
41+
- (void)registerBackend:(id<GDLLogUploader>)backend forLogTarget:(GDLLogTarget)logTarget {
4242
self.logTargetToBackend[@(logTarget)] = backend;
4343
}
4444

4545
- (void)registerLogPrioritizer:(id<GDLLogPrioritizer>)prioritizer
46-
forLogTarget:(NSInteger)logTarget {
46+
forLogTarget:(GDLLogTarget)logTarget {
4747
self.logTargetToPrioritizer[@(logTarget)] = prioritizer;
4848
}
4949

GoogleDataLogger/GoogleDataLogger/Classes/GDLUploader.h renamed to GoogleDataLogger/GoogleDataLogger/Classes/GDLUploadCoordinator.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,14 @@
1616

1717
#import <Foundation/Foundation.h>
1818

19+
#import "GDLRegistrar.h"
20+
1921
NS_ASSUME_NONNULL_BEGIN
2022

2123
/** This class connects log storage and the backend implementations, providing logs to the uploaders
2224
* and informing the log storage what logs were successfully uploaded or not.
2325
*/
24-
@interface GDLUploader : NSObject
26+
@interface GDLUploadCoordinator : NSObject
2527

2628
/** Creates and/or returrns the singleton.
2729
*
@@ -32,7 +34,7 @@ NS_ASSUME_NONNULL_BEGIN
3234
/** Forces the backend specified by the target to upload the provided set of logs. This should only
3335
* ever happen when the QoS tier of a log requires it.
3436
*/
35-
- (void)forceUploadLogs:(NSSet<NSURL *> *)logFiles target:(NSInteger)logTarget;
37+
- (void)forceUploadLogs:(NSSet<NSURL *> *)logFiles target:(GDLLogTarget)logTarget;
3638

3739
@end
3840

GoogleDataLogger/GoogleDataLogger/Classes/GDLUploader.m renamed to GoogleDataLogger/GoogleDataLogger/Classes/GDLUploadCoordinator.m

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,23 @@
1414
* limitations under the License.
1515
*/
1616

17-
#import "GDLUploader.h"
17+
#import "GDLUploadCoordinator.h"
1818

19-
@implementation GDLUploader
19+
#import "GDLRegistrar_Private.h"
20+
21+
@implementation GDLUploadCoordinator
2022

2123
+ (instancetype)sharedInstance {
22-
static GDLUploader *sharedUploader;
24+
static GDLUploadCoordinator *sharedUploader;
2325
static dispatch_once_t onceToken;
2426
dispatch_once(&onceToken, ^{
25-
sharedUploader = [[GDLUploader alloc] init];
27+
sharedUploader = [[GDLUploadCoordinator alloc] init];
2628
});
2729
return sharedUploader;
2830
}
2931

30-
- (void)forceUploadLogs:(NSSet<NSURL *> *)logFiles target:(NSInteger)logTarget {
31-
// TODO
32+
- (void)forceUploadLogs:(NSSet<NSURL *> *)logFiles target:(GDLLogTarget)logTarget {
33+
// Ask the prioritizer of the target for some logs
3234
}
3335

3436
@end

GoogleDataLogger/GoogleDataLogger/Classes/Private/GDLLogStorage_Private.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
#import "GDLLogStorage.h"
1818

19-
@class GDLUploader;
19+
@class GDLUploadCoordinator;
2020

2121
@interface GDLLogStorage ()
2222

@@ -31,6 +31,6 @@
3131
NSMutableDictionary<NSNumber *, NSMutableSet<NSURL *> *> *logTargetToLogFileSet;
3232

3333
/** The log uploader instance to use. */
34-
@property(nonatomic) GDLUploader *uploader;
34+
@property(nonatomic) GDLUploadCoordinator *uploader;
3535

3636
@end

GoogleDataLogger/GoogleDataLogger/Classes/Private/GDLRegistrar_Private.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
@interface GDLRegistrar ()
2020

2121
/** A map of logTargets to backend implementations. */
22-
@property(nonatomic) NSMutableDictionary<NSNumber *, id<GDLLogBackend>> *logTargetToBackend;
22+
@property(nonatomic) NSMutableDictionary<NSNumber *, id<GDLLogUploader>> *logTargetToBackend;
2323

2424
/** A map of logTargets to prioritizer implementations. */
2525
@property(nonatomic) NSMutableDictionary<NSNumber *, id<GDLLogPrioritizer>> *logTargetToPrioritizer;

GoogleDataLogger/GoogleDataLogger/Classes/Public/GDLLogBackend.h renamed to GoogleDataLogger/GoogleDataLogger/Classes/Public/GDLLogUploader.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ typedef void (^GDLBackendCompletionBlock)(NSSet<NSURL *> *_Nullable successfulUp
2525
NSSet<NSURL *> *_Nullable unsuccessfulUploads);
2626

2727
/** This protocol defines the common interface for logging backend implementations. */
28-
@protocol GDLLogBackend <NSObject>
28+
@protocol GDLLogUploader <NSObject>
2929

3030
@required
3131

GoogleDataLogger/GoogleDataLogger/Classes/Public/GDLRegistrar.h

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,18 @@
1616

1717
#import <Foundation/Foundation.h>
1818

19-
#import <GoogleDataLogger/GDLLogBackend.h>
2019
#import <GoogleDataLogger/GDLLogPrioritizer.h>
20+
#import <GoogleDataLogger/GDLLogUploader.h>
2121

2222
NS_ASSUME_NONNULL_BEGIN
2323

24+
/** The list of targets supported by the shared logging infrastructure. */
25+
typedef NS_ENUM(NSInteger, GDLLogTarget) {
26+
27+
/** The CCT log target. */
28+
kGDLLogTargetCCT = 1000
29+
};
30+
2431
/** Manages the registration of log targets with the logging SDK. */
2532
@interface GDLRegistrar : NSObject
2633

@@ -35,14 +42,15 @@ NS_ASSUME_NONNULL_BEGIN
3542
* @param backend The backend object to register.
3643
* @param logTarget The logTarget this backend object will be responsible for.
3744
*/
38-
- (void)registerBackend:(id<GDLLogBackend>)backend forLogTarget:(NSInteger)logTarget;
45+
- (void)registerBackend:(id<GDLLogUploader>)backend forLogTarget:(GDLLogTarget)logTarget;
3946

4047
/** Registers a log prioritizer implementation with the GoogleDataLogger infrastructure.
4148
*
4249
* @param prioritizer The prioritizer object to register.
4350
* @param logTarget The logTarget this prioritizer object will be responsible for.
4451
*/
45-
- (void)registerLogPrioritizer:(id<GDLLogPrioritizer>)prioritizer forLogTarget:(NSInteger)logTarget;
52+
- (void)registerLogPrioritizer:(id<GDLLogPrioritizer>)prioritizer
53+
forLogTarget:(GDLLogTarget)logTarget;
4654

4755
@end
4856

GoogleDataLogger/GoogleDataLogger/Classes/Public/GoogleDataLogger.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@
1414
* limitations under the License.
1515
*/
1616

17-
#import "GDLLogBackend.h"
1817
#import "GDLLogEvent.h"
1918
#import "GDLLogPrioritizer.h"
2019
#import "GDLLogProto.h"
2120
#import "GDLLogTransformer.h"
21+
#import "GDLLogUploader.h"
2222
#import "GDLLogger.h"
2323
#import "GDLRegistrar.h"

GoogleDataLogger/Tests/Unit/Fakes/GDLUploaderFake.h renamed to GoogleDataLogger/Tests/Unit/Fakes/GDLUploadCoordinatorFake.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@
1414
* limitations under the License.
1515
*/
1616

17-
#import "GDLUploader.h"
17+
#import "GDLUploadCoordinator.h"
1818

1919
NS_ASSUME_NONNULL_BEGIN
2020

21-
@interface GDLUploaderFake : GDLUploader
21+
@interface GDLUploadCoordinatorFake : GDLUploadCoordinator
2222

2323
@property(nonatomic) BOOL forceUploadCalled;
2424

GoogleDataLogger/Tests/Unit/Fakes/GDLUploaderFake.m renamed to GoogleDataLogger/Tests/Unit/Fakes/GDLUploadCoordinatorFake.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@
1414
* limitations under the License.
1515
*/
1616

17-
#import "GDLUploaderFake.h"
17+
#import "GDLUploadCoordinatorFake.h"
1818

19-
@implementation GDLUploaderFake
19+
@implementation GDLUploadCoordinatorFake
2020

21-
- (void)forceUploadLogs:(NSSet<NSURL *> *)logFiles target:(NSInteger)logTarget {
21+
- (void)forceUploadLogs:(NSSet<NSURL *> *)logFiles target:(GDLLogTarget)logTarget {
2222
self.forceUploadCalled = YES;
2323
}
2424

GoogleDataLogger/Tests/Unit/GDLLogStorageTest.m

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,38 +24,38 @@
2424
#import "GDLRegistrar.h"
2525
#import "GDLRegistrar_Private.h"
2626

27-
#import "GDLTestBackend.h"
2827
#import "GDLTestPrioritizer.h"
28+
#import "GDLTestUploader.h"
2929

3030
#import "GDLAssertHelper.h"
3131
#import "GDLLogStorage+Testing.h"
3232
#import "GDLRegistrar+Testing.h"
33-
#import "GDLUploaderFake.h"
33+
#import "GDLUploadCoordinatorFake.h"
3434

3535
static NSInteger logTarget = 1337;
3636

3737
@interface GDLLogStorageTest : GDLTestCase
3838

3939
/** The test backend implementation. */
40-
@property(nullable, nonatomic) GDLTestBackend *testBackend;
40+
@property(nullable, nonatomic) GDLTestUploader *testBackend;
4141

4242
/** The test prioritizer implementation. */
4343
@property(nullable, nonatomic) GDLTestPrioritizer *testPrioritizer;
4444

4545
/** The uploader fake. */
46-
@property(nonatomic) GDLUploaderFake *uploaderFake;
46+
@property(nonatomic) GDLUploadCoordinatorFake *uploaderFake;
4747

4848
@end
4949

5050
@implementation GDLLogStorageTest
5151

5252
- (void)setUp {
5353
[super setUp];
54-
self.testBackend = [[GDLTestBackend alloc] init];
54+
self.testBackend = [[GDLTestUploader alloc] init];
5555
self.testPrioritizer = [[GDLTestPrioritizer alloc] init];
5656
[[GDLRegistrar sharedInstance] registerBackend:_testBackend forLogTarget:logTarget];
5757
[[GDLRegistrar sharedInstance] registerLogPrioritizer:_testPrioritizer forLogTarget:logTarget];
58-
self.uploaderFake = [[GDLUploaderFake alloc] init];
58+
self.uploaderFake = [[GDLUploadCoordinatorFake alloc] init];
5959
[GDLLogStorage sharedInstance].uploader = self.uploaderFake;
6060
}
6161

@@ -66,7 +66,7 @@ - (void)tearDown {
6666
self.testPrioritizer = nil;
6767
[[GDLRegistrar sharedInstance] reset];
6868
[[GDLLogStorage sharedInstance] reset];
69-
[GDLLogStorage sharedInstance].uploader = [GDLUploader sharedInstance];
69+
[GDLLogStorage sharedInstance].uploader = [GDLUploadCoordinator sharedInstance];
7070
self.uploaderFake = nil;
7171
}
7272

GoogleDataLogger/Tests/Unit/GDLLogUploaderTest.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
#import "GDLTestCase.h"
1818

19-
#import "GDLUploader.h"
19+
#import "GDLUploadCoordinator.h"
2020

2121
@interface GDLUploaderTest : GDLTestCase
2222

@@ -26,7 +26,7 @@ @implementation GDLUploaderTest
2626

2727
/** Tests the default initializer. */
2828
- (void)testSharedInstance {
29-
XCTAssertEqual([GDLUploader sharedInstance], [GDLUploader sharedInstance]);
29+
XCTAssertEqual([GDLUploadCoordinator sharedInstance], [GDLUploadCoordinator sharedInstance]);
3030
}
3131

3232
@end

GoogleDataLogger/Tests/Unit/Helpers/GDLTestBackend.h renamed to GoogleDataLogger/Tests/Unit/Helpers/GDLTestUploader.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@
1616

1717
#import <Foundation/Foundation.h>
1818

19-
#import "GDLLogBackend.h"
19+
#import "GDLLogUploader.h"
2020

2121
NS_ASSUME_NONNULL_BEGIN
2222

2323
/** This class implements the log backend protocol for testing purposes, providing APIs to allow
2424
* tests to alter the uploader behavior without creating a bunch of specialized classes.
2525
*/
26-
@interface GDLTestBackend : NSObject <GDLLogBackend>
26+
@interface GDLTestUploader : NSObject <GDLLogUploader>
2727

2828
/** A block that can be ran in -uploadLogs:onComplete:. */
2929
@property(nullable, nonatomic) void (^uploadLogsBlock)

GoogleDataLogger/Tests/Unit/Helpers/GDLTestBackend.m renamed to GoogleDataLogger/Tests/Unit/Helpers/GDLTestUploader.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414
* limitations under the License.
1515
*/
1616

17-
#import "GDLTestBackend.h"
17+
#import "GDLTestUploader.h"
1818

19-
@implementation GDLTestBackend
19+
@implementation GDLTestUploader
2020

2121
- (void)uploadLogs:(NSSet<NSURL *> *)logFiles onComplete:(GDLBackendCompletionBlock)onComplete {
2222
if (_uploadLogsBlock) {

0 commit comments

Comments
 (0)