1 // Copyright 2013 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 "webcontentdecryptionmoduleaccess_impl.h"
7 #include "base/basictypes.h"
9 #include "base/location.h"
10 #include "base/message_loop/message_loop_proxy.h"
11 #include "third_party/WebKit/public/platform/WebContentDecryptionModuleResult.h"
12 #include "webcontentdecryptionmodule_impl.h"
16 // The caller owns the created cdm (passed back using |result|).
17 static void CreateCdm(CdmFactory
* cdm_factory
,
18 blink::WebSecurityOrigin security_origin
,
19 blink::WebString key_system
,
20 blink::WebContentDecryptionModuleResult result
) {
21 WebContentDecryptionModuleImpl::Create(cdm_factory
, security_origin
,
25 WebContentDecryptionModuleAccessImpl
*
26 WebContentDecryptionModuleAccessImpl::Create(
27 const blink::WebString
& key_system
,
28 const blink::WebSecurityOrigin
& security_origin
,
29 CdmFactory
* cdm_factory
) {
30 return new WebContentDecryptionModuleAccessImpl(key_system
, security_origin
,
34 WebContentDecryptionModuleAccessImpl::WebContentDecryptionModuleAccessImpl(
35 const blink::WebString
& key_system
,
36 const blink::WebSecurityOrigin
& security_origin
,
37 CdmFactory
* cdm_factory
)
38 : key_system_(key_system
),
39 security_origin_(security_origin
),
40 cdm_factory_(cdm_factory
) {
43 WebContentDecryptionModuleAccessImpl::~WebContentDecryptionModuleAccessImpl() {
46 void WebContentDecryptionModuleAccessImpl::createContentDecryptionModule(
47 blink::WebContentDecryptionModuleResult result
) {
48 // This method needs to run asynchronously, as it may need to load the CDM.
49 // As this object's lifetime is controlled by MediaKeySystemAccess on the
50 // blink side, copy all values needed by CreateCdm() in case the blink object
51 // gets garbage-collected.
52 base::MessageLoopProxy::current()->PostTask(
53 FROM_HERE
, base::Bind(&CreateCdm
, cdm_factory_
, security_origin_
,
54 key_system_
, result
));