Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/crypto/proxy_media_keys.h" | 5 #include "content/renderer/media/crypto/proxy_media_keys.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 41 // Reject any outstanding promises. | 41 // Reject any outstanding promises. |
| 42 for (PromiseMap::iterator it = session_id_to_promise_map_.begin(); | 42 for (PromiseMap::iterator it = session_id_to_promise_map_.begin(); |
| 43 it != session_id_to_promise_map_.end(); | 43 it != session_id_to_promise_map_.end(); |
| 44 ++it) { | 44 ++it) { |
| 45 it->second->reject( | 45 it->second->reject( |
| 46 media::MediaKeys::NOT_SUPPORTED_ERROR, 0, "The operation was aborted."); | 46 media::MediaKeys::NOT_SUPPORTED_ERROR, 0, "The operation was aborted."); |
| 47 } | 47 } |
| 48 session_id_to_promise_map_.clear(); | 48 session_id_to_promise_map_.clear(); |
| 49 } | 49 } |
| 50 | 50 |
| 51 void ProxyMediaKeys::SetServerCertificate( | |
| 52 const uint8* certificate_data, | |
| 53 int certificate_data_length, | |
| 54 scoped_ptr<media::SimpleCdmPromise> promise) { | |
| 55 promise->reject( | |
| 56 INVALID_ACCESS_ERROR, 0, "SetServerCertificate() is not supported."); | |
|
ddorwin
2014/09/10 22:58:38
There is a NOT_SUPPORTED_ERROR.
Note: Eventually,
jrummell
2014/09/11 21:21:54
Done.
| |
| 57 } | |
| 58 | |
| 51 void ProxyMediaKeys::CreateSession( | 59 void ProxyMediaKeys::CreateSession( |
| 52 const std::string& init_data_type, | 60 const std::string& init_data_type, |
| 53 const uint8* init_data, | 61 const uint8* init_data, |
| 54 int init_data_length, | 62 int init_data_length, |
| 55 SessionType session_type, | 63 SessionType session_type, |
| 56 scoped_ptr<media::NewSessionCdmPromise> promise) { | 64 scoped_ptr<media::NewSessionCdmPromise> promise) { |
| 57 // TODO(xhwang): Move these checks up to blink and DCHECK here. | 65 // TODO(xhwang): Move these checks up to blink and DCHECK here. |
| 58 // See http://crbug.com/342510 | 66 // See http://crbug.com/342510 |
| 59 CdmHostMsg_CreateSession_ContentType create_session_content_type; | 67 CdmHostMsg_CreateSession_ContentType create_session_content_type; |
| 60 if (init_data_type == "cenc") { | 68 if (init_data_type == "cenc") { |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 100 return; | 108 return; |
| 101 } | 109 } |
| 102 | 110 |
| 103 SavePromise(session_id, promise.PassAs<media::CdmPromise>()); | 111 SavePromise(session_id, promise.PassAs<media::CdmPromise>()); |
| 104 manager_->UpdateSession( | 112 manager_->UpdateSession( |
| 105 cdm_id_, | 113 cdm_id_, |
| 106 session_id, | 114 session_id, |
| 107 std::vector<uint8>(response, response + response_length)); | 115 std::vector<uint8>(response, response + response_length)); |
| 108 } | 116 } |
| 109 | 117 |
| 110 void ProxyMediaKeys::ReleaseSession( | 118 void ProxyMediaKeys::CloseSession(const std::string& web_session_id, |
| 119 scoped_ptr<media::SimpleCdmPromise> promise) { | |
| 120 promise->reject(INVALID_ACCESS_ERROR, 0, "CloseSession() is not supported."); | |
|
ddorwin
2014/09/10 22:58:38
ditto on NOT_SUPPORTED_ERROR. The comment should b
jrummell
2014/09/11 21:21:54
See comment below.
| |
| 121 } | |
| 122 | |
| 123 void ProxyMediaKeys::RemoveSession( | |
| 111 const std::string& web_session_id, | 124 const std::string& web_session_id, |
| 112 scoped_ptr<media::SimpleCdmPromise> promise) { | 125 scoped_ptr<media::SimpleCdmPromise> promise) { |
| 113 uint32 session_id = LookupSessionId(web_session_id); | 126 uint32 session_id = LookupSessionId(web_session_id); |
| 114 if (!session_id) { | 127 if (!session_id) { |
| 115 promise->reject(INVALID_ACCESS_ERROR, 0, "Session does not exist."); | 128 promise->reject(INVALID_ACCESS_ERROR, 0, "Session does not exist."); |
| 116 return; | 129 return; |
| 117 } | 130 } |
| 118 | 131 |
| 119 SavePromise(session_id, promise.PassAs<media::CdmPromise>()); | 132 SavePromise(session_id, promise.PassAs<media::CdmPromise>()); |
| 120 manager_->ReleaseSession(cdm_id_, session_id); | 133 manager_->ReleaseSession(cdm_id_, session_id); |
|
ddorwin
2014/09/10 22:58:38
Which function should actually be calling this? On
jrummell
2014/09/11 21:21:54
Since v0.1b CKR calls turn into RemoveSession() cu
ddorwin
2014/09/11 23:31:11
See comment in new PS.
| |
| 121 } | 134 } |
| 122 | 135 |
| 136 void ProxyMediaKeys::GetUsableKeyIds(const std::string& web_session_id, | |
| 137 scoped_ptr<media::KeyIdsPromise> promise) { | |
| 138 promise->reject( | |
| 139 INVALID_ACCESS_ERROR, 0, "GetUsableKeyIds() is not supported."); | |
|
ddorwin
2014/09/10 22:58:38
ditto
jrummell
2014/09/11 21:21:54
Done.
| |
| 140 } | |
| 141 | |
| 123 void ProxyMediaKeys::OnSessionCreated(uint32 session_id, | 142 void ProxyMediaKeys::OnSessionCreated(uint32 session_id, |
| 124 const std::string& web_session_id) { | 143 const std::string& web_session_id) { |
| 125 AssignWebSessionId(session_id, web_session_id); | 144 AssignWebSessionId(session_id, web_session_id); |
| 126 scoped_ptr<media::CdmPromise> promise = TakePromise(session_id); | 145 scoped_ptr<media::CdmPromise> promise = TakePromise(session_id); |
| 127 if (promise) { | 146 if (promise) { |
| 128 media::NewSessionCdmPromise* session_promise( | 147 media::NewSessionCdmPromise* session_promise( |
| 129 static_cast<media::NewSessionCdmPromise*>(promise.get())); | 148 static_cast<media::NewSessionCdmPromise*>(promise.get())); |
| 130 session_promise->resolve(web_session_id); | 149 session_promise->resolve(web_session_id); |
| 131 } | 150 } |
| 132 } | 151 } |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 264 | 283 |
| 265 scoped_ptr<media::CdmPromise> ProxyMediaKeys::TakePromise(uint32_t session_id) { | 284 scoped_ptr<media::CdmPromise> ProxyMediaKeys::TakePromise(uint32_t session_id) { |
| 266 PromiseMap::iterator it = session_id_to_promise_map_.find(session_id); | 285 PromiseMap::iterator it = session_id_to_promise_map_.find(session_id); |
| 267 // May not be a promise associated with this session for asynchronous events. | 286 // May not be a promise associated with this session for asynchronous events. |
| 268 if (it == session_id_to_promise_map_.end()) | 287 if (it == session_id_to_promise_map_.end()) |
| 269 return scoped_ptr<media::CdmPromise>(); | 288 return scoped_ptr<media::CdmPromise>(); |
| 270 return session_id_to_promise_map_.take_and_erase(it); | 289 return session_id_to_promise_map_.take_and_erase(it); |
| 271 } | 290 } |
| 272 | 291 |
| 273 } // namespace content | 292 } // namespace content |
| OLD | NEW |