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

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

Issue 1729063003: media: Reject pending CDM promise during destruction. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 months 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
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"
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 49
50 template <typename... T> 50 template <typename... T>
51 CdmResultPromise<T...>::CdmResultPromise( 51 CdmResultPromise<T...>::CdmResultPromise(
52 const blink::WebContentDecryptionModuleResult& result, 52 const blink::WebContentDecryptionModuleResult& result,
53 const std::string& uma_name) 53 const std::string& uma_name)
54 : web_cdm_result_(result), uma_name_(uma_name) { 54 : web_cdm_result_(result), uma_name_(uma_name) {
55 } 55 }
56 56
57 template <typename... T> 57 template <typename... T>
58 CdmResultPromise<T...>::~CdmResultPromise() { 58 CdmResultPromise<T...>::~CdmResultPromise() {
59 if (web_cdm_result_.isCompleted())
60 return;
61
62 std::string message =
63 "Unfulfilled promise rejected automatically during destruction.";
64 DVLOG(1) << message;
65 reject(MediaKeys::INVALID_STATE_ERROR, 0, message);
59 } 66 }
60 67
61 // "inline" is needed to prevent multiple definition error. 68 // "inline" is needed to prevent multiple definition error.
62 69
63 template <> 70 template <>
64 inline void CdmResultPromise<>::resolve() { 71 inline void CdmResultPromise<>::resolve() {
65 MarkPromiseSettled(); 72 MarkPromiseSettled();
66 ReportCdmResultUMA(uma_name_, SUCCESS); 73 ReportCdmResultUMA(uma_name_, SUCCESS);
67 web_cdm_result_.complete(); 74 web_cdm_result_.complete();
68 } 75 }
69 76
70 template <typename... T> 77 template <typename... T>
71 void CdmResultPromise<T...>::reject(media::MediaKeys::Exception exception_code, 78 void CdmResultPromise<T...>::reject(media::MediaKeys::Exception exception_code,
72 uint32_t system_code, 79 uint32_t system_code,
73 const std::string& error_message) { 80 const std::string& error_message) {
74 MarkPromiseSettled(); 81 MarkPromiseSettled();
75 ReportCdmResultUMA(uma_name_, 82 ReportCdmResultUMA(uma_name_,
76 ConvertCdmExceptionToResultForUMA(exception_code)); 83 ConvertCdmExceptionToResultForUMA(exception_code));
77 web_cdm_result_.completeWithError(ConvertCdmException(exception_code), 84 web_cdm_result_.completeWithError(ConvertCdmException(exception_code),
78 system_code, 85 system_code,
79 blink::WebString::fromUTF8(error_message)); 86 blink::WebString::fromUTF8(error_message));
80 } 87 }
81 88
82 } // namespace media 89 } // namespace media
83 90
84 #endif // MEDIA_BLINK_CDM_RESULT_PROMISE_H_ 91 #endif // MEDIA_BLINK_CDM_RESULT_PROMISE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698