Chromium Code Reviews| OLD | NEW |
|---|---|
| 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" | |
|
xhwang
2016/10/26 00:13:05
You should keep these headers since they are used
| |
| 15 #include "third_party/WebKit/public/platform/WebString.h" | 12 #include "third_party/WebKit/public/platform/WebString.h" |
| 16 | 13 |
| 17 namespace media { | 14 namespace media { |
| 18 | 15 |
| 19 // Used to convert a WebContentDecryptionModuleResult into a CdmPromiseTemplate | 16 // Used to convert a WebContentDecryptionModuleResult into a CdmPromiseTemplate |
| 20 // so that it can be passed through Chromium. When resolve(T) is called, the | 17 // so that it can be passed through Chromium. When resolve(T) is called, the |
| 21 // appropriate complete...() method on WebContentDecryptionModuleResult will be | 18 // appropriate complete...() method on WebContentDecryptionModuleResult will be |
| 22 // invoked. If reject() is called instead, | 19 // invoked. If reject() is called instead, |
| 23 // WebContentDecryptionModuleResult::completeWithError() is called. | 20 // WebContentDecryptionModuleResult::completeWithError() is called. |
| 24 // If constructed with a |uma_name|, CdmResultPromise will report the promise | 21 // If constructed with a |uma_name|, CdmResultPromise will report the promise |
| 25 // result (success or rejection code) to UMA. | 22 // result (success or rejection code) to UMA. |
| 26 template <typename... T> | 23 template <typename... T> |
| 27 class CdmResultPromise : public CdmPromiseTemplate<T...> { | 24 class CdmResultPromise : public CdmPromiseTemplate<T...> { |
| 28 public: | 25 public: |
| 29 CdmResultPromise(const blink::WebContentDecryptionModuleResult& result, | 26 CdmResultPromise(const blink::WebContentDecryptionModuleResult& result, |
| 30 const std::string& uma_name); | 27 const std::string& uma_name); |
| 31 ~CdmResultPromise() override; | 28 ~CdmResultPromise() override; |
| 32 | 29 |
| 33 // CdmPromiseTemplate<T> implementation. | 30 // CdmPromiseTemplate<T> implementation. |
| 34 void resolve(const T&... result) override; | 31 void resolve(const T&... result) override; |
| 35 void reject(MediaKeys::Exception exception_code, | 32 void reject(CdmPromise::Exception exception_code, |
| 36 uint32_t system_code, | 33 uint32_t system_code, |
| 37 const std::string& error_message) override; | 34 const std::string& error_message) override; |
| 38 | 35 |
| 39 private: | 36 private: |
| 40 using CdmPromiseTemplate<T...>::IsPromiseSettled; | 37 using CdmPromiseTemplate<T...>::IsPromiseSettled; |
| 41 using CdmPromiseTemplate<T...>::MarkPromiseSettled; | 38 using CdmPromiseTemplate<T...>::MarkPromiseSettled; |
| 42 using CdmPromiseTemplate<T...>::RejectPromiseOnDestruction; | 39 using CdmPromiseTemplate<T...>::RejectPromiseOnDestruction; |
| 43 | 40 |
| 44 blink::WebContentDecryptionModuleResult web_cdm_result_; | 41 blink::WebContentDecryptionModuleResult web_cdm_result_; |
| 45 | 42 |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 65 // "inline" is needed to prevent multiple definition error. | 62 // "inline" is needed to prevent multiple definition error. |
| 66 | 63 |
| 67 template <> | 64 template <> |
| 68 inline void CdmResultPromise<>::resolve() { | 65 inline void CdmResultPromise<>::resolve() { |
| 69 MarkPromiseSettled(); | 66 MarkPromiseSettled(); |
| 70 ReportCdmResultUMA(uma_name_, SUCCESS); | 67 ReportCdmResultUMA(uma_name_, SUCCESS); |
| 71 web_cdm_result_.complete(); | 68 web_cdm_result_.complete(); |
| 72 } | 69 } |
| 73 | 70 |
| 74 template <typename... T> | 71 template <typename... T> |
| 75 void CdmResultPromise<T...>::reject(MediaKeys::Exception exception_code, | 72 void CdmResultPromise<T...>::reject(CdmPromise::Exception exception_code, |
| 76 uint32_t system_code, | 73 uint32_t system_code, |
| 77 const std::string& error_message) { | 74 const std::string& error_message) { |
| 78 MarkPromiseSettled(); | 75 MarkPromiseSettled(); |
| 79 ReportCdmResultUMA(uma_name_, | 76 ReportCdmResultUMA(uma_name_, |
| 80 ConvertCdmExceptionToResultForUMA(exception_code)); | 77 ConvertCdmExceptionToResultForUMA(exception_code)); |
| 81 web_cdm_result_.completeWithError(ConvertCdmException(exception_code), | 78 web_cdm_result_.completeWithError(ConvertCdmException(exception_code), |
| 82 system_code, | 79 system_code, |
| 83 blink::WebString::fromUTF8(error_message)); | 80 blink::WebString::fromUTF8(error_message)); |
| 84 } | 81 } |
| 85 | 82 |
| 86 } // namespace media | 83 } // namespace media |
| 87 | 84 |
| 88 #endif // MEDIA_BLINK_CDM_RESULT_PROMISE_H_ | 85 #endif // MEDIA_BLINK_CDM_RESULT_PROMISE_H_ |
| OLD | NEW |