GDTCORStorage.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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. #import <Foundation/Foundation.h>
  17. #import <GoogleDataTransport/GDTCORLifecycle.h>
  18. @class GDTCOREvent;
  19. NS_ASSUME_NONNULL_BEGIN
  20. /** Manages the storage of events. This class is thread-safe. */
  21. @interface GDTCORStorage : NSObject <NSSecureCoding, GDTCORLifecycleProtocol>
  22. /** Creates and/or returns the storage singleton.
  23. *
  24. * @return The storage singleton.
  25. */
  26. + (instancetype)sharedInstance;
  27. /** Stores event.dataObject into a shared on-device folder and tracks the event via
  28. * a GDTCOREvent instance.
  29. *
  30. * @param event The event to store.
  31. * @param completion A block to run when an event was written to disk or dropped.
  32. */
  33. - (void)storeEvent:(GDTCOREvent *)event
  34. onComplete:(void (^_Nullable)(BOOL wasWritten, NSError *error))completion;
  35. /** Removes a set of events from storage specified by their hash.
  36. *
  37. * @param events The set of stored events to remove.
  38. */
  39. - (void)removeEvents:(NSSet<GDTCOREvent *> *)events;
  40. @end
  41. NS_ASSUME_NONNULL_END