Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2014 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 | |
| 5 #ifndef CONTENT_RENDERER_MEDIA_CDM_RESULT_PROMISE_H_ | |
| 6 #define CONTENT_RENDERER_MEDIA_CDM_RESULT_PROMISE_H_ | |
| 7 | |
| 8 #include <map> | |
| 9 | |
| 10 #include "base/basictypes.h" | |
| 11 #include "media/base/cdm_promise.h" | |
| 12 #include "third_party/WebKit/public/platform/WebContentDecryptionModuleResult.h" | |
| 13 | |
| 14 namespace content { | |
| 15 | |
| 16 // Used to convert a WebContentDecryptionModuleResult into a CdmPromise so that | |
| 17 // it can be passed through Chromium. When CdmPromise::resolve(T) is called, | |
| 18 // OnResolve(T) will be called and will call the appropriate complete...() | |
| 19 // method on WebContentDecryptionModuleResult. If CdmPromise::reject() is called | |
| 20 // instead, WebContentDecryptionModuleResult::completeWithError() is called. | |
| 21 // If constructed with a |uma_name| (which must be the name of a | |
| 22 // CdmPromiseResult UMA), CdmResultPromise will report the promise result | |
| 23 // (success or rejection code). | |
| 24 template <typename T> | |
| 25 class CdmResultPromise : public media::CdmPromiseTemplate<T> { | |
| 26 public: | |
| 27 explicit CdmResultPromise( | |
| 28 const blink::WebContentDecryptionModuleResult& result); | |
| 29 CdmResultPromise(const blink::WebContentDecryptionModuleResult& result, | |
| 30 const std::string& uma_name); | |
| 31 ~CdmResultPromise(); | |
|
xhwang
2014/09/25 21:01:52
virtual
jrummell
2014/09/25 21:25:54
Done.
| |
| 32 | |
| 33 protected: | |
| 34 // OnResolve() is virtual as it needs to be overridden and handled differently | |
| 35 // when a new session is created. | |
|
ddorwin
2014/09/25 20:54:05
nit: The base class shouldn't have such details. I
jrummell
2014/09/25 21:25:54
Done.
| |
| 36 virtual void OnResolve(const T& result); | |
| 37 void OnReject(media::MediaKeys::Exception exception_code, | |
| 38 uint32 system_code, | |
| 39 const std::string& error_message); | |
| 40 | |
| 41 blink::WebContentDecryptionModuleResult web_cdm_result_; | |
| 42 | |
| 43 private: | |
| 44 DISALLOW_COPY_AND_ASSIGN(CdmResultPromise); | |
| 45 }; | |
| 46 | |
| 47 // Specialization for no parameter to resolve(). | |
| 48 template <> | |
| 49 class CdmResultPromise<void> : public media::CdmPromiseTemplate<void> { | |
| 50 public: | |
| 51 explicit CdmResultPromise( | |
| 52 const blink::WebContentDecryptionModuleResult& result); | |
| 53 CdmResultPromise(const blink::WebContentDecryptionModuleResult& result, | |
| 54 const std::string& uma_name); | |
| 55 ~CdmResultPromise(); | |
|
xhwang
2014/09/25 21:01:52
virtual
jrummell
2014/09/25 21:25:54
Done.
| |
| 56 | |
| 57 protected: | |
| 58 virtual void OnResolve(); | |
| 59 void OnReject(media::MediaKeys::Exception exception_code, | |
| 60 uint32 system_code, | |
| 61 const std::string& error_message); | |
| 62 | |
| 63 blink::WebContentDecryptionModuleResult web_cdm_result_; | |
| 64 | |
| 65 private: | |
| 66 DISALLOW_COPY_AND_ASSIGN(CdmResultPromise); | |
| 67 }; | |
| 68 | |
| 69 typedef CdmResultPromise<void> SimpleCdmResultPromise; | |
| 70 | |
| 71 } // namespace content | |
| 72 | |
| 73 #endif // CONTENT_RENDERER_MEDIA_CDM_RESULT_PROMISE_H_ | |
| OLD | NEW |