FPRSessionDetails.m 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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. #import "FirebasePerformance/Sources/AppActivity/FPRSessionDetails.h"
  15. @interface FPRSessionDetails ()
  16. /** @brief Time at which the session was created. */
  17. @property(nonatomic) NSDate *sessionCreationTime;
  18. @end
  19. @implementation FPRSessionDetails
  20. - (instancetype)initWithSessionId:(NSString *)sessionId options:(FPRSessionOptions)options {
  21. self = [super init];
  22. if (self) {
  23. _sessionId = sessionId;
  24. _options = options;
  25. _sessionCreationTime = [NSDate date];
  26. }
  27. return self;
  28. }
  29. - (NSUInteger)sessionLengthInMinutes {
  30. NSTimeInterval sessionLengthInSeconds = ABS([self.sessionCreationTime timeIntervalSinceNow]);
  31. return (sessionLengthInSeconds / 60);
  32. }
  33. - (BOOL)isEqual:(FPRSessionDetails *)detailsObject {
  34. if (self.sessionId == detailsObject.sessionId) {
  35. return YES;
  36. }
  37. return NO;
  38. }
  39. - (BOOL)isVerbose {
  40. return (self.options > FPRSessionOptionsNone);
  41. }
  42. @end