| 1 |
efrain |
1 |
// Copyright 2020 Google LLC
|
|
|
2 |
//
|
|
|
3 |
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
4 |
// you may not use this file except in compliance with the License.
|
|
|
5 |
// You may obtain a copy of the License at
|
|
|
6 |
//
|
|
|
7 |
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
8 |
//
|
|
|
9 |
// Unless required by applicable law or agreed to in writing, software
|
|
|
10 |
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
11 |
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
12 |
// See the License for the specific language governing permissions and
|
|
|
13 |
// limitations under the License.
|
|
|
14 |
|
|
|
15 |
#import "FirebasePerformance/Sources/AppActivity/FPRSessionDetails.h"
|
|
|
16 |
|
|
|
17 |
@interface FPRSessionDetails ()
|
|
|
18 |
|
|
|
19 |
/** @brief Time at which the session was created. */
|
|
|
20 |
@property(nonatomic) NSDate *sessionCreationTime;
|
|
|
21 |
|
|
|
22 |
@end
|
|
|
23 |
|
|
|
24 |
@implementation FPRSessionDetails
|
|
|
25 |
|
|
|
26 |
- (instancetype)initWithSessionId:(NSString *)sessionId options:(FPRSessionOptions)options {
|
|
|
27 |
self = [super init];
|
|
|
28 |
if (self) {
|
|
|
29 |
_sessionId = sessionId;
|
|
|
30 |
_options = options;
|
|
|
31 |
_sessionCreationTime = [NSDate date];
|
|
|
32 |
}
|
|
|
33 |
return self;
|
|
|
34 |
}
|
|
|
35 |
|
|
|
36 |
- (FPRSessionDetails *)copyWithZone:(NSZone *)zone {
|
|
|
37 |
FPRSessionDetails *detailsCopy = [[[self class] allocWithZone:zone] initWithSessionId:_sessionId
|
|
|
38 |
options:_options];
|
|
|
39 |
detailsCopy.sessionCreationTime = _sessionCreationTime;
|
|
|
40 |
return detailsCopy;
|
|
|
41 |
}
|
|
|
42 |
|
|
|
43 |
- (NSUInteger)sessionLengthInMinutes {
|
|
|
44 |
NSTimeInterval sessionLengthInSeconds = ABS([self.sessionCreationTime timeIntervalSinceNow]);
|
|
|
45 |
return (NSUInteger)(sessionLengthInSeconds / 60);
|
|
|
46 |
}
|
|
|
47 |
|
|
|
48 |
- (BOOL)isEqual:(FPRSessionDetails *)detailsObject {
|
|
|
49 |
if (self.sessionId == detailsObject.sessionId) {
|
|
|
50 |
return YES;
|
|
|
51 |
}
|
|
|
52 |
return NO;
|
|
|
53 |
}
|
|
|
54 |
|
|
|
55 |
- (BOOL)isVerbose {
|
|
|
56 |
return (self.options > FPRSessionOptionsNone);
|
|
|
57 |
}
|
|
|
58 |
|
|
|
59 |
@end
|