1 |
efrain |
1 |
/*
|
|
|
2 |
* Copyright 2018 Google
|
|
|
3 |
*
|
|
|
4 |
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
5 |
* you may not use this file except in compliance with the License.
|
|
|
6 |
* You may obtain a copy of the License at
|
|
|
7 |
*
|
|
|
8 |
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
9 |
*
|
|
|
10 |
* Unless required by applicable law or agreed to in writing, software
|
|
|
11 |
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
12 |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
13 |
* See the License for the specific language governing permissions and
|
|
|
14 |
* limitations under the License.
|
|
|
15 |
*/
|
|
|
16 |
|
|
|
17 |
#import <Foundation/Foundation.h>
|
|
|
18 |
|
|
|
19 |
#import "GoogleDataTransport/GDTCORLibrary/Internal/GDTCORLifecycle.h"
|
|
|
20 |
#import "GoogleDataTransport/GDTCORLibrary/Internal/GDTCORRegistrar.h"
|
|
|
21 |
|
|
|
22 |
@class GDTCORClock;
|
|
|
23 |
|
|
|
24 |
NS_ASSUME_NONNULL_BEGIN
|
|
|
25 |
|
|
|
26 |
/** This class connects storage and uploader implementations, providing events to an uploader
|
|
|
27 |
* and informing the storage what events were successfully uploaded or not.
|
|
|
28 |
*/
|
|
|
29 |
@interface GDTCORUploadCoordinator : NSObject <GDTCORLifecycleProtocol>
|
|
|
30 |
|
|
|
31 |
/** The queue on which all upload coordination will occur. Also used by a dispatch timer. */
|
|
|
32 |
/** Creates and/or returrns the singleton.
|
|
|
33 |
*
|
|
|
34 |
* @return The singleton instance of this class.
|
|
|
35 |
*/
|
|
|
36 |
+ (instancetype)sharedInstance;
|
|
|
37 |
|
|
|
38 |
/** The queue on which all upload coordination will occur. */
|
|
|
39 |
@property(nonatomic, readonly) dispatch_queue_t coordinationQueue;
|
|
|
40 |
|
|
|
41 |
/** A timer that will causes regular checks for events to upload. */
|
|
|
42 |
@property(nonatomic, readonly, nullable) dispatch_source_t timer;
|
|
|
43 |
|
|
|
44 |
/** The interval the timer will fire. */
|
|
|
45 |
@property(nonatomic, readonly) uint64_t timerInterval;
|
|
|
46 |
|
|
|
47 |
/** Some leeway given to libdispatch for the timer interval event. */
|
|
|
48 |
@property(nonatomic, readonly) uint64_t timerLeeway;
|
|
|
49 |
|
|
|
50 |
/** The registrar object the coordinator will use. Generally used for testing. */
|
|
|
51 |
@property(nonatomic) GDTCORRegistrar *registrar;
|
|
|
52 |
|
|
|
53 |
/** Forces the backend specified by the target to upload the provided set of events. This should
|
|
|
54 |
* only ever happen when the QoS tier of an event requires it.
|
|
|
55 |
*
|
|
|
56 |
* @param target The target that should force an upload.
|
|
|
57 |
*/
|
|
|
58 |
- (void)forceUploadForTarget:(GDTCORTarget)target;
|
|
|
59 |
|
|
|
60 |
/** Starts the upload timer. */
|
|
|
61 |
- (void)startTimer;
|
|
|
62 |
|
|
|
63 |
/** Stops the upload timer from running. */
|
|
|
64 |
- (void)stopTimer;
|
|
|
65 |
|
|
|
66 |
@end
|
|
|
67 |
|
|
|
68 |
NS_ASSUME_NONNULL_END
|