Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(129)

Side by Side Diff: media/blink/cdm_result_promise.h

Issue 2444683002: Move MediaKeys::Exception to CdmPromise::Exception (Closed)
Patch Set: include "media/base/media_keys.h" Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « media/base/media_keys.h ('k') | media/blink/cdm_result_promise_helper.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef MEDIA_BLINK_CDM_RESULT_PROMISE_H_ 5 #ifndef MEDIA_BLINK_CDM_RESULT_PROMISE_H_
6 #define MEDIA_BLINK_CDM_RESULT_PROMISE_H_ 6 #define MEDIA_BLINK_CDM_RESULT_PROMISE_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "media/base/cdm_promise.h"
12 #include "media/base/media_keys.h"
13 #include "media/blink/cdm_result_promise_helper.h" 11 #include "media/blink/cdm_result_promise_helper.h"
14 #include "third_party/WebKit/public/platform/WebContentDecryptionModuleResult.h" 12 #include "third_party/WebKit/public/platform/WebContentDecryptionModuleResult.h"
15 #include "third_party/WebKit/public/platform/WebString.h" 13 #include "third_party/WebKit/public/platform/WebString.h"
16 14
17 namespace media { 15 namespace media {
18 16
19 // Used to convert a WebContentDecryptionModuleResult into a CdmPromiseTemplate 17 // Used to convert a WebContentDecryptionModuleResult into a CdmPromiseTemplate
20 // so that it can be passed through Chromium. When resolve(T) is called, the 18 // so that it can be passed through Chromium. When resolve(T) is called, the
21 // appropriate complete...() method on WebContentDecryptionModuleResult will be 19 // appropriate complete...() method on WebContentDecryptionModuleResult will be
22 // invoked. If reject() is called instead, 20 // invoked. If reject() is called instead,
23 // WebContentDecryptionModuleResult::completeWithError() is called. 21 // WebContentDecryptionModuleResult::completeWithError() is called.
24 // If constructed with a |uma_name|, CdmResultPromise will report the promise 22 // If constructed with a |uma_name|, CdmResultPromise will report the promise
25 // result (success or rejection code) to UMA. 23 // result (success or rejection code) to UMA.
26 template <typename... T> 24 template <typename... T>
27 class CdmResultPromise : public CdmPromiseTemplate<T...> { 25 class CdmResultPromise : public CdmPromiseTemplate<T...> {
28 public: 26 public:
29 CdmResultPromise(const blink::WebContentDecryptionModuleResult& result, 27 CdmResultPromise(const blink::WebContentDecryptionModuleResult& result,
30 const std::string& uma_name); 28 const std::string& uma_name);
31 ~CdmResultPromise() override; 29 ~CdmResultPromise() override;
32 30
33 // CdmPromiseTemplate<T> implementation. 31 // CdmPromiseTemplate<T> implementation.
34 void resolve(const T&... result) override; 32 void resolve(const T&... result) override;
35 void reject(MediaKeys::Exception exception_code, 33 void reject(CdmPromise::Exception exception_code,
36 uint32_t system_code, 34 uint32_t system_code,
37 const std::string& error_message) override; 35 const std::string& error_message) override;
38 36
39 private: 37 private:
40 using CdmPromiseTemplate<T...>::IsPromiseSettled; 38 using CdmPromiseTemplate<T...>::IsPromiseSettled;
41 using CdmPromiseTemplate<T...>::MarkPromiseSettled; 39 using CdmPromiseTemplate<T...>::MarkPromiseSettled;
42 using CdmPromiseTemplate<T...>::RejectPromiseOnDestruction; 40 using CdmPromiseTemplate<T...>::RejectPromiseOnDestruction;
43 41
44 blink::WebContentDecryptionModuleResult web_cdm_result_; 42 blink::WebContentDecryptionModuleResult web_cdm_result_;
45 43
(...skipping 19 matching lines...) Expand all
65 // "inline" is needed to prevent multiple definition error. 63 // "inline" is needed to prevent multiple definition error.
66 64
67 template <> 65 template <>
68 inline void CdmResultPromise<>::resolve() { 66 inline void CdmResultPromise<>::resolve() {
69 MarkPromiseSettled(); 67 MarkPromiseSettled();
70 ReportCdmResultUMA(uma_name_, SUCCESS); 68 ReportCdmResultUMA(uma_name_, SUCCESS);
71 web_cdm_result_.complete(); 69 web_cdm_result_.complete();
72 } 70 }
73 71
74 template <typename... T> 72 template <typename... T>
75 void CdmResultPromise<T...>::reject(MediaKeys::Exception exception_code, 73 void CdmResultPromise<T...>::reject(CdmPromise::Exception exception_code,
76 uint32_t system_code, 74 uint32_t system_code,
77 const std::string& error_message) { 75 const std::string& error_message) {
78 MarkPromiseSettled(); 76 MarkPromiseSettled();
79 ReportCdmResultUMA(uma_name_, 77 ReportCdmResultUMA(uma_name_,
80 ConvertCdmExceptionToResultForUMA(exception_code)); 78 ConvertCdmExceptionToResultForUMA(exception_code));
81 web_cdm_result_.completeWithError(ConvertCdmException(exception_code), 79 web_cdm_result_.completeWithError(ConvertCdmException(exception_code),
82 system_code, 80 system_code,
83 blink::WebString::fromUTF8(error_message)); 81 blink::WebString::fromUTF8(error_message));
84 } 82 }
85 83
86 } // namespace media 84 } // namespace media
87 85
88 #endif // MEDIA_BLINK_CDM_RESULT_PROMISE_H_ 86 #endif // MEDIA_BLINK_CDM_RESULT_PROMISE_H_
OLDNEW
« no previous file with comments | « media/base/media_keys.h ('k') | media/blink/cdm_result_promise_helper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698