OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "media/blink/new_session_cdm_result_promise.h" |
| 6 |
| 7 #include "base/logging.h" |
| 8 #include "media/blink/cdm_result_promise_helper.h" |
| 9 #include "third_party/WebKit/public/platform/WebString.h" |
| 10 |
| 11 namespace media { |
| 12 |
| 13 NewSessionCdmResultPromise::NewSessionCdmResultPromise( |
| 14 const blink::WebContentDecryptionModuleResult& result, |
| 15 const std::string& uma_name, |
| 16 const SessionInitializedCB& new_session_created_cb) |
| 17 : web_cdm_result_(result), |
| 18 uma_name_(uma_name), |
| 19 new_session_created_cb_(new_session_created_cb) { |
| 20 } |
| 21 |
| 22 NewSessionCdmResultPromise::~NewSessionCdmResultPromise() { |
| 23 } |
| 24 |
| 25 void NewSessionCdmResultPromise::resolve(const std::string& web_session_id) { |
| 26 MarkPromiseSettled(); |
| 27 ReportCdmResultUMA(uma_name_, SUCCESS); |
| 28 blink::WebContentDecryptionModuleResult::SessionStatus status = |
| 29 new_session_created_cb_.Run(web_session_id); |
| 30 web_cdm_result_.completeWithSession(status); |
| 31 } |
| 32 |
| 33 void NewSessionCdmResultPromise::reject(MediaKeys::Exception exception_code, |
| 34 uint32 system_code, |
| 35 const std::string& error_message) { |
| 36 MarkPromiseSettled(); |
| 37 ReportCdmResultUMA(uma_name_, |
| 38 ConvertCdmExceptionToResultForUMA(exception_code)); |
| 39 web_cdm_result_.completeWithError(ConvertCdmException(exception_code), |
| 40 system_code, |
| 41 blink::WebString::fromUTF8(error_message)); |
| 42 } |
| 43 |
| 44 } // namespace media |
OLD | NEW |