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 |
NS_ASSUME_NONNULL_BEGIN
|
|
|
20 |
@interface FIRIAMClearcutLogRecord : NSObject <NSSecureCoding>
|
|
|
21 |
@property(nonatomic, copy, readonly) NSString *eventExtensionJsonString;
|
|
|
22 |
@property(nonatomic, readonly) NSInteger eventTimestampInSeconds;
|
|
|
23 |
- (instancetype)initWithExtensionJsonString:(NSString *)jsonString
|
|
|
24 |
eventTimestampInSeconds:(NSInteger)eventTimestampInSeconds;
|
|
|
25 |
@end
|
|
|
26 |
|
|
|
27 |
@protocol FIRIAMTimeFetcher;
|
|
|
28 |
|
|
|
29 |
// A local persistent storage for saving FIRIAMClearcutLogRecord objects
|
|
|
30 |
// so that they can be delivered to clearcut server.
|
|
|
31 |
// Based on the clearcut log structure, our strategy is to store the json string
|
|
|
32 |
// for the source extension since it does not need to be modified upon delivery retries.
|
|
|
33 |
// The envelope of the clearcut log will be reconstructed when delivery is
|
|
|
34 |
// attempted.
|
|
|
35 |
|
|
|
36 |
@interface FIRIAMClearcutLogStorage : NSObject
|
|
|
37 |
- (instancetype)initWithExpireAfterInSeconds:(NSInteger)expireInSeconds
|
|
|
38 |
withTimeFetcher:(id<FIRIAMTimeFetcher>)timeFetcher
|
|
|
39 |
cachePath:(nullable NSString *)cachePath;
|
|
|
40 |
|
|
|
41 |
- (instancetype)initWithExpireAfterInSeconds:(NSInteger)expireInSeconds
|
|
|
42 |
withTimeFetcher:(id<FIRIAMTimeFetcher>)timeFetcher;
|
|
|
43 |
|
|
|
44 |
// add new records into the storage
|
|
|
45 |
- (void)pushRecords:(NSArray<FIRIAMClearcutLogRecord *> *)newRecords;
|
|
|
46 |
|
|
|
47 |
// pop all the records that have not expired yet. With this call, these
|
|
|
48 |
// records are removed from the book of this local storage object.
|
|
|
49 |
// @param upTo the cap on how many records to be popped.
|
|
|
50 |
- (NSArray<FIRIAMClearcutLogRecord *> *)popStillValidRecordsForUpTo:(NSInteger)upTo;
|
|
|
51 |
@end
|
|
|
52 |
NS_ASSUME_NONNULL_END
|