Resurrect battery_status_dispatcher_unittest.
[chromium-blink-merge.git] / media / blink / webcontentdecryptionmoduleaccess_impl.cc
blob9971829a3968cc6e4575ba9beb12fd0d8375d897
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"
8 #include "base/bind.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"
14 namespace media {
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,
22 key_system, result);
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,
31 cdm_factory);
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));
57 } // namespace media