Update V8 to version 4.7.42.
[chromium-blink-merge.git] / media / blink / new_session_cdm_result_promise.cc
blob0a07614dc0a789e758e46d3c6ec6a179461460f9
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"
11 namespace media {
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) {
22 NewSessionCdmResultPromise::~NewSessionCdmResultPromise() {
25 void NewSessionCdmResultPromise::resolve(const std::string& session_id) {
26 MarkPromiseSettled();
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,
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));
44 } // namespace media