| 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/callback_helpers.h" | 7 #include "base/callback_helpers.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
| 10 #include "third_party/WebKit/public/platform/WebURL.h" | 10 #include "third_party/WebKit/public/platform/WebURL.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 } | 24 } |
| 25 | 25 |
| 26 WebContentDecryptionModuleSessionImpl:: | 26 WebContentDecryptionModuleSessionImpl:: |
| 27 ~WebContentDecryptionModuleSessionImpl() { | 27 ~WebContentDecryptionModuleSessionImpl() { |
| 28 } | 28 } |
| 29 | 29 |
| 30 blink::WebString WebContentDecryptionModuleSessionImpl::sessionId() const { | 30 blink::WebString WebContentDecryptionModuleSessionImpl::sessionId() const { |
| 31 return web_session_id_; | 31 return web_session_id_; |
| 32 } | 32 } |
| 33 | 33 |
| 34 void WebContentDecryptionModuleSessionImpl::generateKeyRequest( | 34 void WebContentDecryptionModuleSessionImpl::initialize( |
| 35 const blink::WebString& mime_type, | 35 const blink::WebString& mime_type, |
| 36 const uint8* init_data, size_t init_data_length) { | 36 const uint8* init_data, size_t init_data_length) { |
| 37 // TODO(ddorwin): Guard against this in supported types check and remove this. | 37 // TODO(ddorwin): Guard against this in supported types check and remove this. |
| 38 // Chromium only supports ASCII MIME types. | 38 // Chromium only supports ASCII MIME types. |
| 39 if (!IsStringASCII(mime_type)) { | 39 if (!IsStringASCII(mime_type)) { |
| 40 NOTREACHED(); | 40 NOTREACHED(); |
| 41 OnSessionError(media::MediaKeys::kUnknownError, 0); | 41 OnSessionError(media::MediaKeys::kUnknownError, 0); |
| 42 return; | 42 return; |
| 43 } | 43 } |
| 44 | 44 |
| 45 media_keys_->CreateSession( | 45 media_keys_->CreateSession( |
| 46 session_id_, UTF16ToASCII(mime_type), init_data, init_data_length); | 46 session_id_, UTF16ToASCII(mime_type), init_data, init_data_length); |
| 47 } | 47 } |
| 48 | 48 |
| 49 void WebContentDecryptionModuleSessionImpl::generateKeyRequest( |
| 50 const blink::WebString& mime_type, |
| 51 const uint8* init_data, size_t init_data_length) { |
| 52 initialize(mime_type, init_data, init_data_length); |
| 53 } |
| 54 |
| 49 void WebContentDecryptionModuleSessionImpl::update(const uint8* response, | 55 void WebContentDecryptionModuleSessionImpl::update(const uint8* response, |
| 50 size_t response_length) { | 56 size_t response_length) { |
| 51 DCHECK(response); | 57 DCHECK(response); |
| 52 media_keys_->UpdateSession(session_id_, response, response_length); | 58 media_keys_->UpdateSession(session_id_, response, response_length); |
| 53 } | 59 } |
| 54 | 60 |
| 61 void WebContentDecryptionModuleSessionImpl::release() { |
| 62 media_keys_->ReleaseSession(session_id_); |
| 63 } |
| 64 |
| 55 void WebContentDecryptionModuleSessionImpl::close() { | 65 void WebContentDecryptionModuleSessionImpl::close() { |
| 56 media_keys_->ReleaseSession(session_id_); | 66 release(); |
| 57 } | 67 } |
| 58 | 68 |
| 59 void WebContentDecryptionModuleSessionImpl::OnSessionCreated( | 69 void WebContentDecryptionModuleSessionImpl::OnSessionCreated( |
| 60 const std::string& web_session_id) { | 70 const std::string& web_session_id) { |
| 61 // Due to heartbeat messages, OnSessionCreated() can get called multiple | 71 // Due to heartbeat messages, OnSessionCreated() can get called multiple |
| 62 // times. | 72 // times. |
| 63 // TODO(jrummell): Once all CDMs are updated to support reference ids, | 73 // TODO(jrummell): Once all CDMs are updated to support reference ids, |
| 64 // OnSessionCreated() should only be called once, and the second check can be | 74 // OnSessionCreated() should only be called once, and the second check can be |
| 65 // removed. | 75 // removed. |
| 66 blink::WebString id = blink::WebString::fromUTF8(web_session_id); | 76 blink::WebString id = blink::WebString::fromUTF8(web_session_id); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 89 } | 99 } |
| 90 | 100 |
| 91 void WebContentDecryptionModuleSessionImpl::OnSessionError( | 101 void WebContentDecryptionModuleSessionImpl::OnSessionError( |
| 92 media::MediaKeys::KeyError error_code, | 102 media::MediaKeys::KeyError error_code, |
| 93 int system_code) { | 103 int system_code) { |
| 94 client_->keyError(static_cast<Client::MediaKeyErrorCode>(error_code), | 104 client_->keyError(static_cast<Client::MediaKeyErrorCode>(error_code), |
| 95 system_code); | 105 system_code); |
| 96 } | 106 } |
| 97 | 107 |
| 98 } // namespace content | 108 } // namespace content |
| OLD | NEW |