Chromium Code Reviews| Index: content/renderer/media/webcontentdecryptionmoduleresult_helper.h |
| diff --git a/content/renderer/media/webcontentdecryptionmoduleresult_helper.h b/content/renderer/media/webcontentdecryptionmoduleresult_helper.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..4c586601c84b9a74df257c835a340f2ae98c1218 |
| --- /dev/null |
| +++ b/content/renderer/media/webcontentdecryptionmoduleresult_helper.h |
| @@ -0,0 +1,65 @@ |
| +// Copyright 2014 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CONTENT_RENDERER_MEDIA_WEBCONTENTDECRYPTIONMODULERESULT_HELPER_H_ |
| +#define CONTENT_RENDERER_MEDIA_WEBCONTENTDECRYPTIONMODULERESULT_HELPER_H_ |
| + |
| +#include <map> |
| + |
| +#include "base/basictypes.h" |
| +#include "media/base/cdm_promise.h" |
| +#include "third_party/WebKit/public/platform/WebContentDecryptionModuleResult.h" |
| + |
| +namespace content { |
| + |
| +// Used to convert a WebContentDecryptionModuleResult into a CdmPromise so that |
| +// it can be passed through Chromium. When CdmPromise::resolve(T) is called, |
| +// OnResolve(T) will be called and will call the appropriate complete...() |
| +// method on WebContentDecryptionModuleResult. If CdmPromise::reject() is called |
| +// instead, WebContentDecryptionModuleResult::completeWithError() is called. |
| +template <typename T> |
| +class CdmResultPromise : public media::CdmPromiseTemplate<T> { |
| + public: |
| + CdmResultPromise(blink::WebContentDecryptionModuleResult result); |
| + CdmResultPromise(blink::WebContentDecryptionModuleResult result, |
| + const std::string& uma_name); |
| + |
| + protected: |
| + virtual void OnResolve(const T& result); |
| + void OnReject(media::MediaKeys::Exception exception_code, |
| + uint32 system_code, |
| + const std::string& error_message); |
| + |
| + blink::WebContentDecryptionModuleResult webCDMResult_; |
| + |
| + private: |
| + DISALLOW_COPY_AND_ASSIGN(CdmResultPromise); |
| +}; |
| + |
| +// Specialization for no parameter to resolve(). |
| +template <> |
| +class CdmResultPromise<void> : public media::CdmPromiseTemplate<void> { |
| + public: |
| + CdmResultPromise(blink::WebContentDecryptionModuleResult result); |
| + CdmResultPromise(blink::WebContentDecryptionModuleResult result, |
| + const std::string& uma_name); |
| + |
| + protected: |
| + virtual void OnResolve(); |
| + void OnReject(media::MediaKeys::Exception exception_code, |
| + uint32 system_code, |
| + const std::string& error_message); |
| + |
| + blink::WebContentDecryptionModuleResult webCDMResult_; |
| + |
| + private: |
| + DISALLOW_COPY_AND_ASSIGN(CdmResultPromise); |
| +}; |
| + |
| +typedef CdmResultPromise<void> SimpleCdmResultPromise; |
| +typedef CdmResultPromise<media::KeyIdsVector> KeyIdsResultPromise; |
|
ddorwin
2014/09/24 22:47:30
Why does one have "Cdm" and the other not? They sh
jrummell
2014/09/24 23:57:51
To match the CdmPromise typedefs. Changed to inclu
|
| + |
| +} // namespace content |
| + |
| +#endif // CONTENT_RENDERER_MEDIA_WEBCONTENTDECRYPTIONMODULERESULT_HELPER_H_ |