FIRStorageTask.h 2.1 KB

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