FIRStorageTask.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /*
  2. * Copyright 2017 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 "FIRStorageConstants.h"
  18. #import "FIRStorageMetadata.h"
  19. NS_ASSUME_NONNULL_BEGIN
  20. /**
  21. * A superclass to all FIRStorage*Tasks, including FIRStorageUploadTask
  22. * and FIRStorageDownloadTask, to provide state transitions, event raising, and common storage
  23. * or metadata and errors.
  24. * Callbacks are always fired on the developer specified callback queue.
  25. * If no queue is specified by the developer, it defaults to the main queue.
  26. * Currently not thread safe, so only call methods on the main thread.
  27. */
  28. NS_SWIFT_NAME(StorageTask)
  29. @interface FIRStorageTask : NSObject
  30. /**
  31. * An immutable view of the task and associated metadata, progress, error, etc.
  32. */
  33. @property(strong, readonly, nonatomic, nonnull) FIRStorageTaskSnapshot *snapshot;
  34. @end
  35. /**
  36. * Defines task operations such as pause, resume, cancel, and enqueue for all tasks.
  37. * All tasks are required to implement enqueue, which begins the task, and may optionally
  38. * implement pause, resume, and cancel, which operate on the task to pause, resume, and cancel
  39. * operations.
  40. */
  41. NS_SWIFT_NAME(StorageTaskManagement)
  42. @protocol FIRStorageTaskManagement <NSObject>
  43. @required
  44. /**
  45. * Prepares a task and begins execution.
  46. */
  47. - (void)enqueue;
  48. @optional
  49. /**
  50. * Pauses a task currently in progress.
  51. */
  52. - (void)pause;
  53. /**
  54. * Cancels a task currently in progress.
  55. */
  56. - (void)cancel;
  57. /**
  58. * Resumes a task that is paused.
  59. */
  60. - (void)resume;
  61. @end
  62. NS_ASSUME_NONNULL_END