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 "webcontentdecryptionmodule_impl.h" | 5 #include "webcontentdecryptionmodule_impl.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/numerics/safe_conversions.h" | 10 #include "base/numerics/safe_conversions.h" |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 | 55 |
56 // If unique security origin, don't try to create the CDM. | 56 // If unique security origin, don't try to create the CDM. |
57 if (security_origin.isUnique() || security_origin.toString() == "null") { | 57 if (security_origin.isUnique() || security_origin.toString() == "null") { |
58 result.completeWithError( | 58 result.completeWithError( |
59 blink::WebContentDecryptionModuleExceptionNotSupportedError, 0, | 59 blink::WebContentDecryptionModuleExceptionNotSupportedError, 0, |
60 "CDM use not allowed for unique security origin."); | 60 "CDM use not allowed for unique security origin."); |
61 return; | 61 return; |
62 } | 62 } |
63 | 63 |
64 GURL security_origin_as_gurl(security_origin.toString()); | 64 GURL security_origin_as_gurl(security_origin.toString()); |
| 65 |
| 66 // CdmSessionAdapter::CreateCdm() will keep a reference to |adapter|. Then |
| 67 // if WebContentDecryptionModuleImpl is successfully created (returned in |
| 68 // |result|), it will keep a reference to |adapter|. Otherwise, |adapter| will |
| 69 // be destructed. |
65 scoped_refptr<CdmSessionAdapter> adapter(new CdmSessionAdapter()); | 70 scoped_refptr<CdmSessionAdapter> adapter(new CdmSessionAdapter()); |
66 | 71 adapter->CreateCdm(cdm_factory, key_system_ascii, |
67 // TODO(jrummell): Pass WebContentDecryptionModuleResult (or similar) to | 72 allow_distinctive_identifier, allow_persistent_state, |
68 // Initialize() so that more specific errors can be reported. | 73 security_origin_as_gurl, result); |
69 if (!adapter->Initialize(cdm_factory, key_system_ascii, | |
70 allow_distinctive_identifier, | |
71 allow_persistent_state, security_origin_as_gurl)) { | |
72 result.completeWithError( | |
73 blink::WebContentDecryptionModuleExceptionNotSupportedError, 0, | |
74 "Failed to initialize CDM."); | |
75 return; | |
76 } | |
77 | |
78 result.completeWithContentDecryptionModule( | |
79 new WebContentDecryptionModuleImpl(adapter)); | |
80 } | 74 } |
81 | 75 |
82 WebContentDecryptionModuleImpl::WebContentDecryptionModuleImpl( | 76 WebContentDecryptionModuleImpl::WebContentDecryptionModuleImpl( |
83 scoped_refptr<CdmSessionAdapter> adapter) | 77 scoped_refptr<CdmSessionAdapter> adapter) |
84 : adapter_(adapter) { | 78 : adapter_(adapter) { |
85 } | 79 } |
86 | 80 |
87 WebContentDecryptionModuleImpl::~WebContentDecryptionModuleImpl() { | 81 WebContentDecryptionModuleImpl::~WebContentDecryptionModuleImpl() { |
88 } | 82 } |
89 | 83 |
(...skipping 13 matching lines...) Expand all Loading... |
103 base::saturated_cast<int>(server_certificate_length), | 97 base::saturated_cast<int>(server_certificate_length), |
104 scoped_ptr<SimpleCdmPromise>( | 98 scoped_ptr<SimpleCdmPromise>( |
105 new CdmResultPromise<>(result, std::string()))); | 99 new CdmResultPromise<>(result, std::string()))); |
106 } | 100 } |
107 | 101 |
108 CdmContext* WebContentDecryptionModuleImpl::GetCdmContext() { | 102 CdmContext* WebContentDecryptionModuleImpl::GetCdmContext() { |
109 return adapter_->GetCdmContext(); | 103 return adapter_->GetCdmContext(); |
110 } | 104 } |
111 | 105 |
112 } // namespace media | 106 } // namespace media |
OLD | NEW |