| 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 "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "media/base/cdm_promise.h" | 9 #include "media/base/cdm_promise.h" |
| 10 #include "media/base/media_keys.h" | 10 #include "media/base/media_keys.h" |
| 11 #include "media/blink/cdm_result_promise_helper.h" | 11 #include "media/blink/cdm_result_promise_helper.h" |
| 12 #include "third_party/WebKit/public/platform/WebContentDecryptionModuleResult.h" | 12 #include "third_party/WebKit/public/platform/WebContentDecryptionModuleResult.h" |
| 13 #include "third_party/WebKit/public/platform/WebString.h" | 13 #include "third_party/WebKit/public/platform/WebString.h" |
| 14 | 14 |
| 15 namespace media { | 15 namespace media { |
| 16 | 16 |
| 17 // Used to convert a WebContentDecryptionModuleResult into a CdmPromiseTemplate | 17 // Used to convert a WebContentDecryptionModuleResult into a CdmPromiseTemplate |
| 18 // 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 |
| 19 // appropriate complete...() method on WebContentDecryptionModuleResult will be | 19 // appropriate complete...() method on WebContentDecryptionModuleResult will be |
| 20 // invoked. If reject() is called instead, | 20 // invoked. If reject() is called instead, |
| 21 // WebContentDecryptionModuleResult::completeWithError() is called. | 21 // WebContentDecryptionModuleResult::completeWithError() is called. |
| 22 // If constructed with a |uma_name|, CdmResultPromise will report the promise | 22 // If constructed with a |uma_name|, CdmResultPromise will report the promise |
| 23 // result (success or rejection code) to UMA. | 23 // result (success or rejection code) to UMA. |
| 24 template <typename... T> | 24 template <typename... T> |
| 25 class CdmResultPromise : public media::CdmPromiseTemplate<T...> { | 25 class CdmResultPromise : public media::CdmPromiseTemplate<T...> { |
| 26 public: | 26 public: |
| 27 CdmResultPromise(const blink::WebContentDecryptionModuleResult& result, | 27 CdmResultPromise(const blink::WebContentDecryptionModuleResult& result, |
| 28 const std::string& uma_name); | 28 const std::string& uma_name); |
| 29 virtual ~CdmResultPromise(); | 29 ~CdmResultPromise() override; |
| 30 | 30 |
| 31 // CdmPromiseTemplate<T> implementation. | 31 // CdmPromiseTemplate<T> implementation. |
| 32 virtual void resolve(const T&... result) override; | 32 void resolve(const T&... result) override; |
| 33 virtual void reject(media::MediaKeys::Exception exception_code, | 33 void reject(media::MediaKeys::Exception exception_code, |
| 34 uint32 system_code, | 34 uint32 system_code, |
| 35 const std::string& error_message) override; | 35 const std::string& error_message) override; |
| 36 | 36 |
| 37 private: | 37 private: |
| 38 using media::CdmPromiseTemplate<T...>::MarkPromiseSettled; | 38 using media::CdmPromiseTemplate<T...>::MarkPromiseSettled; |
| 39 | 39 |
| 40 blink::WebContentDecryptionModuleResult web_cdm_result_; | 40 blink::WebContentDecryptionModuleResult web_cdm_result_; |
| 41 | 41 |
| 42 // UMA name to report result to. | 42 // UMA name to report result to. |
| 43 std::string uma_name_; | 43 std::string uma_name_; |
| 44 | 44 |
| 45 DISALLOW_COPY_AND_ASSIGN(CdmResultPromise); | 45 DISALLOW_COPY_AND_ASSIGN(CdmResultPromise); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 ReportCdmResultUMA(uma_name_, | 81 ReportCdmResultUMA(uma_name_, |
| 82 ConvertCdmExceptionToResultForUMA(exception_code)); | 82 ConvertCdmExceptionToResultForUMA(exception_code)); |
| 83 web_cdm_result_.completeWithError(ConvertCdmException(exception_code), | 83 web_cdm_result_.completeWithError(ConvertCdmException(exception_code), |
| 84 system_code, | 84 system_code, |
| 85 blink::WebString::fromUTF8(error_message)); | 85 blink::WebString::fromUTF8(error_message)); |
| 86 } | 86 } |
| 87 | 87 |
| 88 } // namespace media | 88 } // namespace media |
| 89 | 89 |
| 90 #endif // MEDIA_BLINK_CDM_RESULT_PROMISE_H_ | 90 #endif // MEDIA_BLINK_CDM_RESULT_PROMISE_H_ |
| OLD | NEW |