OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "media/blink/webcontentdecryptionmoduleaccess_impl.h" | 5 #include "media/blink/webcontentdecryptionmoduleaccess_impl.h" |
6 | 6 |
| 7 #include <utility> |
| 8 |
7 #include "base/bind.h" | 9 #include "base/bind.h" |
8 #include "base/location.h" | 10 #include "base/location.h" |
9 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
10 #include "base/single_thread_task_runner.h" | 12 #include "base/single_thread_task_runner.h" |
11 #include "base/thread_task_runner_handle.h" | 13 #include "base/thread_task_runner_handle.h" |
12 #include "media/blink/webencryptedmediaclient_impl.h" | 14 #include "media/blink/webencryptedmediaclient_impl.h" |
13 | 15 |
14 namespace media { | 16 namespace media { |
15 | 17 |
16 // The caller owns the created cdm (passed back using |result|). | 18 // The caller owns the created cdm (passed back using |result|). |
17 static void CreateCdm( | 19 static void CreateCdm( |
18 const base::WeakPtr<WebEncryptedMediaClientImpl>& client, | 20 const base::WeakPtr<WebEncryptedMediaClientImpl>& client, |
19 const blink::WebString& key_system, | 21 const blink::WebString& key_system, |
20 const blink::WebSecurityOrigin& security_origin, | 22 const blink::WebSecurityOrigin& security_origin, |
21 const CdmConfig& cdm_config, | 23 const CdmConfig& cdm_config, |
22 scoped_ptr<blink::WebContentDecryptionModuleResult> result) { | 24 scoped_ptr<blink::WebContentDecryptionModuleResult> result) { |
23 // If |client| is gone (due to the frame getting destroyed), it is | 25 // If |client| is gone (due to the frame getting destroyed), it is |
24 // impossible to create the CDM, so fail. | 26 // impossible to create the CDM, so fail. |
25 if (!client) { | 27 if (!client) { |
26 result->completeWithError( | 28 result->completeWithError( |
27 blink::WebContentDecryptionModuleExceptionInvalidStateError, 0, | 29 blink::WebContentDecryptionModuleExceptionInvalidStateError, 0, |
28 "Failed to create CDM."); | 30 "Failed to create CDM."); |
29 return; | 31 return; |
30 } | 32 } |
31 | 33 |
32 client->CreateCdm(key_system, security_origin, cdm_config, result.Pass()); | 34 client->CreateCdm(key_system, security_origin, cdm_config, std::move(result)); |
33 } | 35 } |
34 | 36 |
35 WebContentDecryptionModuleAccessImpl* | 37 WebContentDecryptionModuleAccessImpl* |
36 WebContentDecryptionModuleAccessImpl::Create( | 38 WebContentDecryptionModuleAccessImpl::Create( |
37 const blink::WebString& key_system, | 39 const blink::WebString& key_system, |
38 const blink::WebSecurityOrigin& security_origin, | 40 const blink::WebSecurityOrigin& security_origin, |
39 const blink::WebMediaKeySystemConfiguration& configuration, | 41 const blink::WebMediaKeySystemConfiguration& configuration, |
40 const CdmConfig& cdm_config, | 42 const CdmConfig& cdm_config, |
41 const base::WeakPtr<WebEncryptedMediaClientImpl>& client) { | 43 const base::WeakPtr<WebEncryptedMediaClientImpl>& client) { |
42 return new WebContentDecryptionModuleAccessImpl( | 44 return new WebContentDecryptionModuleAccessImpl( |
(...skipping 28 matching lines...) Expand all Loading... |
71 // blink side, copy all values needed by CreateCdm() in case the blink object | 73 // blink side, copy all values needed by CreateCdm() in case the blink object |
72 // gets garbage-collected. | 74 // gets garbage-collected. |
73 scoped_ptr<blink::WebContentDecryptionModuleResult> result_copy( | 75 scoped_ptr<blink::WebContentDecryptionModuleResult> result_copy( |
74 new blink::WebContentDecryptionModuleResult(result)); | 76 new blink::WebContentDecryptionModuleResult(result)); |
75 base::ThreadTaskRunnerHandle::Get()->PostTask( | 77 base::ThreadTaskRunnerHandle::Get()->PostTask( |
76 FROM_HERE, base::Bind(&CreateCdm, client_, key_system_, security_origin_, | 78 FROM_HERE, base::Bind(&CreateCdm, client_, key_system_, security_origin_, |
77 cdm_config_, base::Passed(&result_copy))); | 79 cdm_config_, base::Passed(&result_copy))); |
78 } | 80 } |
79 | 81 |
80 } // namespace media | 82 } // namespace media |
OLD | NEW |