| 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 "content/renderer/media/webcontentdecryptionmodulesession_impl.h" | 5 #include "content/renderer/media/webcontentdecryptionmodulesession_impl.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/callback_helpers.h" | 8 #include "base/callback_helpers.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 | 23 |
| 24 class NewSessionCdmResultPromise : public CdmResultPromise<std::string> { | 24 class NewSessionCdmResultPromise : public CdmResultPromise<std::string> { |
| 25 public: | 25 public: |
| 26 NewSessionCdmResultPromise(blink::WebContentDecryptionModuleResult result, | 26 NewSessionCdmResultPromise(blink::WebContentDecryptionModuleResult result, |
| 27 std::string uma_name, | 27 std::string uma_name, |
| 28 const SessionInitializedCB& new_session_created_cb) | 28 const SessionInitializedCB& new_session_created_cb) |
| 29 : CdmResultPromise<std::string>(result, uma_name), | 29 : CdmResultPromise<std::string>(result, uma_name), |
| 30 new_session_created_cb_(new_session_created_cb) {} | 30 new_session_created_cb_(new_session_created_cb) {} |
| 31 | 31 |
| 32 protected: | 32 protected: |
| 33 virtual void OnResolve(const std::string& web_session_id) OVERRIDE { | 33 virtual void resolve(const std::string& web_session_id) OVERRIDE { |
| 34 ReportResultToUMA(SUCCESS); |
| 34 blink::WebContentDecryptionModuleResult::SessionStatus status = | 35 blink::WebContentDecryptionModuleResult::SessionStatus status = |
| 35 new_session_created_cb_.Run(web_session_id); | 36 new_session_created_cb_.Run(web_session_id); |
| 36 web_cdm_result_.completeWithSession(status); | 37 web_cdm_result_.completeWithSession(status); |
| 37 } | 38 } |
| 38 | 39 |
| 39 private: | 40 private: |
| 40 SessionInitializedCB new_session_created_cb_; | 41 SessionInitializedCB new_session_created_cb_; |
| 41 }; | 42 }; |
| 42 | 43 |
| 43 WebContentDecryptionModuleSessionImpl::WebContentDecryptionModuleSessionImpl( | 44 WebContentDecryptionModuleSessionImpl::WebContentDecryptionModuleSessionImpl( |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 void WebContentDecryptionModuleSessionImpl::update( | 123 void WebContentDecryptionModuleSessionImpl::update( |
| 123 const uint8* response, | 124 const uint8* response, |
| 124 size_t response_length, | 125 size_t response_length, |
| 125 blink::WebContentDecryptionModuleResult result) { | 126 blink::WebContentDecryptionModuleResult result) { |
| 126 DCHECK(response); | 127 DCHECK(response); |
| 127 DCHECK(!web_session_id_.empty()); | 128 DCHECK(!web_session_id_.empty()); |
| 128 adapter_->UpdateSession( | 129 adapter_->UpdateSession( |
| 129 web_session_id_, | 130 web_session_id_, |
| 130 response, | 131 response, |
| 131 response_length, | 132 response_length, |
| 132 scoped_ptr<media::SimpleCdmPromise>(new SimpleCdmResultPromise(result))); | 133 scoped_ptr<media::SimpleCdmPromise>( |
| 134 new SimpleCdmResultPromise(result, std::string()))); |
| 133 } | 135 } |
| 134 | 136 |
| 135 void WebContentDecryptionModuleSessionImpl::close( | 137 void WebContentDecryptionModuleSessionImpl::close( |
| 136 blink::WebContentDecryptionModuleResult result) { | 138 blink::WebContentDecryptionModuleResult result) { |
| 137 DCHECK(!web_session_id_.empty()); | 139 DCHECK(!web_session_id_.empty()); |
| 138 adapter_->CloseSession( | 140 adapter_->CloseSession( |
| 139 web_session_id_, | 141 web_session_id_, |
| 140 scoped_ptr<media::SimpleCdmPromise>(new SimpleCdmResultPromise(result))); | 142 scoped_ptr<media::SimpleCdmPromise>( |
| 143 new SimpleCdmResultPromise(result, std::string()))); |
| 141 } | 144 } |
| 142 | 145 |
| 143 void WebContentDecryptionModuleSessionImpl::remove( | 146 void WebContentDecryptionModuleSessionImpl::remove( |
| 144 blink::WebContentDecryptionModuleResult result) { | 147 blink::WebContentDecryptionModuleResult result) { |
| 145 DCHECK(!web_session_id_.empty()); | 148 DCHECK(!web_session_id_.empty()); |
| 146 adapter_->RemoveSession( | 149 adapter_->RemoveSession( |
| 147 web_session_id_, | 150 web_session_id_, |
| 148 scoped_ptr<media::SimpleCdmPromise>(new SimpleCdmResultPromise(result))); | 151 scoped_ptr<media::SimpleCdmPromise>( |
| 152 new SimpleCdmResultPromise(result, std::string()))); |
| 149 } | 153 } |
| 150 | 154 |
| 151 void WebContentDecryptionModuleSessionImpl::getUsableKeyIds( | 155 void WebContentDecryptionModuleSessionImpl::getUsableKeyIds( |
| 152 blink::WebContentDecryptionModuleResult result) { | 156 blink::WebContentDecryptionModuleResult result) { |
| 153 DCHECK(!web_session_id_.empty()); | 157 DCHECK(!web_session_id_.empty()); |
| 154 adapter_->GetUsableKeyIds( | 158 adapter_->GetUsableKeyIds( |
| 155 web_session_id_, | 159 web_session_id_, |
| 156 scoped_ptr<media::KeyIdsPromise>( | 160 scoped_ptr<media::KeyIdsPromise>( |
| 157 new CdmResultPromise<media::KeyIdsVector>(result))); | 161 new CdmResultPromise<media::KeyIdsVector>(result, std::string()))); |
| 158 } | 162 } |
| 159 | 163 |
| 160 void WebContentDecryptionModuleSessionImpl::release( | 164 void WebContentDecryptionModuleSessionImpl::release( |
| 161 blink::WebContentDecryptionModuleResult result) { | 165 blink::WebContentDecryptionModuleResult result) { |
| 162 close(result); | 166 close(result); |
| 163 } | 167 } |
| 164 | 168 |
| 165 void WebContentDecryptionModuleSessionImpl::OnSessionMessage( | 169 void WebContentDecryptionModuleSessionImpl::OnSessionMessage( |
| 166 const std::vector<uint8>& message, | 170 const std::vector<uint8>& message, |
| 167 const GURL& destination_url) { | 171 const GURL& destination_url) { |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 | 225 |
| 222 DCHECK(web_session_id_.empty()) << "Session ID may not be changed once set."; | 226 DCHECK(web_session_id_.empty()) << "Session ID may not be changed once set."; |
| 223 web_session_id_ = web_session_id; | 227 web_session_id_ = web_session_id; |
| 224 return adapter_->RegisterSession(web_session_id_, | 228 return adapter_->RegisterSession(web_session_id_, |
| 225 weak_ptr_factory_.GetWeakPtr()) | 229 weak_ptr_factory_.GetWeakPtr()) |
| 226 ? blink::WebContentDecryptionModuleResult::NewSession | 230 ? blink::WebContentDecryptionModuleResult::NewSession |
| 227 : blink::WebContentDecryptionModuleResult::SessionAlreadyExists; | 231 : blink::WebContentDecryptionModuleResult::SessionAlreadyExists; |
| 228 } | 232 } |
| 229 | 233 |
| 230 } // namespace content | 234 } // namespace content |
| OLD | NEW |