| 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 #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 Loading... |
| 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 (IsPromiseSettled()) |
| 40 return; |
| 41 |
| 42 DCHECK(!web_cdm_result_.isCompleted()); |
| 43 RejectPromiseOnDestruction(); |
| 39 } | 44 } |
| 40 | 45 |
| 41 void NewSessionCdmResultPromise::resolve(const std::string& session_id) { | 46 void NewSessionCdmResultPromise::resolve(const std::string& session_id) { |
| 42 // |new_session_created_cb_| uses a WeakPtr<> and may not do anything | 47 // |new_session_created_cb_| uses a WeakPtr<> and may not do anything |
| 43 // if the session object has been destroyed. | 48 // if the session object has been destroyed. |
| 44 SessionInitStatus status = SessionInitStatus::UNKNOWN_STATUS; | 49 SessionInitStatus status = SessionInitStatus::UNKNOWN_STATUS; |
| 45 new_session_created_cb_.Run(session_id, &status); | 50 new_session_created_cb_.Run(session_id, &status); |
| 46 | 51 |
| 47 if (status == SessionInitStatus::UNKNOWN_STATUS) { | 52 if (status == SessionInitStatus::UNKNOWN_STATUS) { |
| 48 reject(MediaKeys::INVALID_STATE_ERROR, 0, | 53 reject(MediaKeys::INVALID_STATE_ERROR, 0, |
| (...skipping 11 matching lines...) Expand all Loading... |
| 60 const std::string& error_message) { | 65 const std::string& error_message) { |
| 61 MarkPromiseSettled(); | 66 MarkPromiseSettled(); |
| 62 ReportCdmResultUMA(uma_name_, | 67 ReportCdmResultUMA(uma_name_, |
| 63 ConvertCdmExceptionToResultForUMA(exception_code)); | 68 ConvertCdmExceptionToResultForUMA(exception_code)); |
| 64 web_cdm_result_.completeWithError(ConvertCdmException(exception_code), | 69 web_cdm_result_.completeWithError(ConvertCdmException(exception_code), |
| 65 system_code, | 70 system_code, |
| 66 blink::WebString::fromUTF8(error_message)); | 71 blink::WebString::fromUTF8(error_message)); |
| 67 } | 72 } |
| 68 | 73 |
| 69 } // namespace media | 74 } // namespace media |
| OLD | NEW |