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.
5 #include "media/blink/new_session_cdm_result_promise.h"
7 #include "base/logging.h"
8 #include "media/blink/cdm_result_promise_helper.h"
9 #include "third_party/WebKit/public/platform/WebString.h"
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
),
19 new_session_created_cb_(new_session_created_cb
) {
22 NewSessionCdmResultPromise::~NewSessionCdmResultPromise() {
25 void NewSessionCdmResultPromise::resolve(const std::string
& session_id
) {
27 ReportCdmResultUMA(uma_name_
, SUCCESS
);
28 blink::WebContentDecryptionModuleResult::SessionStatus status
=
29 new_session_created_cb_
.Run(session_id
);
30 web_cdm_result_
.completeWithSession(status
);
33 void NewSessionCdmResultPromise::reject(MediaKeys::Exception exception_code
,
35 const std::string
& error_message
) {
37 ReportCdmResultUMA(uma_name_
,
38 ConvertCdmExceptionToResultForUMA(exception_code
));
39 web_cdm_result_
.completeWithError(ConvertCdmException(exception_code
),
41 blink::WebString::fromUTF8(error_message
));