cdm_initialized_promise.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. // Copyright 2015 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef MEDIA_BASE_CDM_INITIALIZED_PROMISE_H_
  5. #define MEDIA_BASE_CDM_INITIALIZED_PROMISE_H_
  6. #include <stdint.h>
  7. #include "base/callback.h"
  8. #include "base/memory/ref_counted.h"
  9. #include "media/base/cdm_factory.h"
  10. #include "media/base/cdm_promise.h"
  11. #include "media/base/media_export.h"
  12. namespace media {
  13. class ContentDecryptionModule;
  14. // Promise to be resolved when the CDM is initialized. It owns the
  15. // ContentDecryptionModule object until the initialization completes, which it
  16. // then passes to |cdm_created_cb|.
  17. class MEDIA_EXPORT CdmInitializedPromise : public SimpleCdmPromise {
  18. public:
  19. CdmInitializedPromise(CdmCreatedCB cdm_created_cb,
  20. scoped_refptr<ContentDecryptionModule> cdm);
  21. ~CdmInitializedPromise() override;
  22. // SimpleCdmPromise implementation.
  23. void resolve() override;
  24. void reject(CdmPromise::Exception exception_code,
  25. uint32_t system_code,
  26. const std::string& error_message) override;
  27. private:
  28. CdmCreatedCB cdm_created_cb_;
  29. // Holds a ref-count of the CDM.
  30. scoped_refptr<ContentDecryptionModule> cdm_;
  31. };
  32. } // namespace media
  33. #endif // MEDIA_BASE_CDM_INITIALIZED_PROMISE_H_