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_WEBCONTENTDECRYPTIONMODULERESULT_HELPER_H_ | |
6 #define CONTENT_RENDERER_MEDIA_WEBCONTENTDECRYPTIONMODULERESULT_HELPER_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 template <typename T> | |
22 class CdmResultPromise : public media::CdmPromiseTemplate<T> { | |
23 public: | |
24 CdmResultPromise(blink::WebContentDecryptionModuleResult result); | |
25 CdmResultPromise(blink::WebContentDecryptionModuleResult result, | |
26 const std::string& uma_name); | |
27 | |
28 protected: | |
29 virtual void OnResolve(const T& result); | |
30 void OnReject(media::MediaKeys::Exception exception_code, | |
31 uint32 system_code, | |
32 const std::string& error_message); | |
33 | |
34 blink::WebContentDecryptionModuleResult webCDMResult_; | |
35 | |
36 private: | |
37 DISALLOW_COPY_AND_ASSIGN(CdmResultPromise); | |
38 }; | |
39 | |
40 // Specialization for no parameter to resolve(). | |
41 template <> | |
42 class CdmResultPromise<void> : public media::CdmPromiseTemplate<void> { | |
43 public: | |
44 CdmResultPromise(blink::WebContentDecryptionModuleResult result); | |
45 CdmResultPromise(blink::WebContentDecryptionModuleResult result, | |
46 const std::string& uma_name); | |
47 | |
48 protected: | |
49 virtual void OnResolve(); | |
50 void OnReject(media::MediaKeys::Exception exception_code, | |
51 uint32 system_code, | |
52 const std::string& error_message); | |
53 | |
54 blink::WebContentDecryptionModuleResult webCDMResult_; | |
55 | |
56 private: | |
57 DISALLOW_COPY_AND_ASSIGN(CdmResultPromise); | |
58 }; | |
59 | |
60 typedef CdmResultPromise<void> SimpleCdmResultPromise; | |
61 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
| |
62 | |
63 } // namespace content | |
64 | |
65 #endif // CONTENT_RENDERER_MEDIA_WEBCONTENTDECRYPTIONMODULERESULT_HELPER_H_ | |
OLD | NEW |