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

Side by Side Diff: media/blink/new_session_cdm_result_promise.cc

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, 9 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 #include "media/blink/new_session_cdm_result_promise.h" 5 #include "media/blink/new_session_cdm_result_promise.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "media/blink/cdm_result_promise_helper.h" 8 #include "media/blink/cdm_result_promise_helper.h"
9 #include "third_party/WebKit/public/platform/WebString.h" 9 #include "third_party/WebKit/public/platform/WebString.h"
10 10
(...skipping 18 matching lines...) Expand all
29 NewSessionCdmResultPromise::NewSessionCdmResultPromise( 29 NewSessionCdmResultPromise::NewSessionCdmResultPromise(
30 const blink::WebContentDecryptionModuleResult& result, 30 const blink::WebContentDecryptionModuleResult& result,
31 const std::string& uma_name, 31 const std::string& uma_name,
32 const SessionInitializedCB& new_session_created_cb) 32 const SessionInitializedCB& new_session_created_cb)
33 : web_cdm_result_(result), 33 : web_cdm_result_(result),
34 uma_name_(uma_name), 34 uma_name_(uma_name),
35 new_session_created_cb_(new_session_created_cb) { 35 new_session_created_cb_(new_session_created_cb) {
36 } 36 }
37 37
38 NewSessionCdmResultPromise::~NewSessionCdmResultPromise() { 38 NewSessionCdmResultPromise::~NewSessionCdmResultPromise() {
39 if (web_cdm_result_.isCompleted())
40 return;
41
42 std::string message =
43 "Unfulfilled promise rejected automatically during destruction.";
44 DVLOG(1) << message;
45 reject(MediaKeys::INVALID_STATE_ERROR, 0, message);
39 } 46 }
40 47
41 void NewSessionCdmResultPromise::resolve(const std::string& session_id) { 48 void NewSessionCdmResultPromise::resolve(const std::string& session_id) {
42 // |new_session_created_cb_| uses a WeakPtr<> and may not do anything 49 // |new_session_created_cb_| uses a WeakPtr<> and may not do anything
43 // if the session object has been destroyed. 50 // if the session object has been destroyed.
44 SessionInitStatus status = SessionInitStatus::UNKNOWN_STATUS; 51 SessionInitStatus status = SessionInitStatus::UNKNOWN_STATUS;
45 new_session_created_cb_.Run(session_id, &status); 52 new_session_created_cb_.Run(session_id, &status);
46 53
47 if (status == SessionInitStatus::UNKNOWN_STATUS) { 54 if (status == SessionInitStatus::UNKNOWN_STATUS) {
48 reject(MediaKeys::INVALID_STATE_ERROR, 0, 55 reject(MediaKeys::INVALID_STATE_ERROR, 0,
(...skipping 11 matching lines...) Expand all
60 const std::string& error_message) { 67 const std::string& error_message) {
61 MarkPromiseSettled(); 68 MarkPromiseSettled();
62 ReportCdmResultUMA(uma_name_, 69 ReportCdmResultUMA(uma_name_,
63 ConvertCdmExceptionToResultForUMA(exception_code)); 70 ConvertCdmExceptionToResultForUMA(exception_code));
64 web_cdm_result_.completeWithError(ConvertCdmException(exception_code), 71 web_cdm_result_.completeWithError(ConvertCdmException(exception_code),
65 system_code, 72 system_code,
66 blink::WebString::fromUTF8(error_message)); 73 blink::WebString::fromUTF8(error_message));
67 } 74 }
68 75
69 } // namespace media 76 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698