Source: externs/shaka/abortable.js

  1. /**
  2. * @license
  3. * Copyright 2016 Google Inc.
  4. *
  5. * Licensed under the Apache License, Version 2.0 (the "License");
  6. * you may not use this file except in compliance with the License.
  7. * You may obtain a copy of the License at
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. */
  17. /**
  18. * @externs
  19. */
  20. /**
  21. * A representation of an abortable operation. Note that these are not
  22. * cancelable. Cancelation implies undoing what has been done so far,
  23. * whereas aborting only means that further work is stopped.
  24. *
  25. * @interface
  26. * @template T
  27. * @exportDoc
  28. */
  29. shaka.extern.IAbortableOperation = function() {};
  30. /**
  31. * A Promise which represents the underlying operation. It is resolved when
  32. * the operation is complete, and rejected if the operation fails or is
  33. * aborted. Aborted operations should be rejected with a shaka.util.Error
  34. * object using the error code OPERATION_ABORTED.
  35. *
  36. * @const {!Promise.<T>}
  37. * @exportDoc
  38. */
  39. shaka.extern.IAbortableOperation.prototype.promise;
  40. /**
  41. * Can be called by anyone holding this object to abort the underlying
  42. * operation. This is not cancelation, and will not necessarily result in
  43. * any work being undone. abort() should return a Promise which is resolved
  44. * when the underlying operation has been aborted. The returned Promise
  45. * should never be rejected.
  46. *
  47. * @return {!Promise}
  48. * @exportDoc
  49. */
  50. shaka.extern.IAbortableOperation.prototype.abort = function() {};
  51. /**
  52. * @param {function(boolean)} onFinal A callback to be invoked after the
  53. * operation succeeds or fails. The boolean argument is true if the operation
  54. * succeeded and false if it failed.
  55. * @return {!shaka.extern.IAbortableOperation.<T>} Returns this.
  56. * @exportDoc
  57. */
  58. shaka.extern.IAbortableOperation.prototype.finally = function(onFinal) {};