Chromium Code Reviews| Index: ppapi/proxy/ppp_content_decryptor_private_proxy.cc |
| diff --git a/ppapi/proxy/ppp_content_decryptor_private_proxy.cc b/ppapi/proxy/ppp_content_decryptor_private_proxy.cc |
| index eee3871b5098d01643d8c19999aeb6d6db9ee52f..c586c07a3405885e42077b1a5c973c4180a8e1ba 100644 |
| --- a/ppapi/proxy/ppp_content_decryptor_private_proxy.cc |
| +++ b/ppapi/proxy/ppp_content_decryptor_private_proxy.cc |
| @@ -5,6 +5,7 @@ |
| #include "ppapi/proxy/ppp_content_decryptor_private_proxy.h" |
| #include "base/files/file.h" |
| +#include "media/base/limits.h" |
| #include "ppapi/c/pp_bool.h" |
| #include "ppapi/c/ppb_core.h" |
| #include "ppapi/proxy/content_decryptor_private_serializer.h" |
| @@ -124,6 +125,40 @@ void Initialize(PP_Instance instance, |
| SerializedVarSendInput(dispatcher, key_system))); |
| } |
| +void SetServerCertificate(PP_Instance instance, |
| + uint32_t promise_id, |
| + PP_Var server_certificate) { |
| + HostDispatcher* dispatcher = HostDispatcher::GetForInstance(instance); |
| + if (!dispatcher) { |
| + NOTREACHED(); |
| + return; |
| + } |
| + |
| + ArrayBufferVar* server_certificate_buffer = |
| + ArrayBufferVar::FromPPVar(server_certificate); |
| + if (!server_certificate_buffer || |
| + server_certificate_buffer->ByteLength() < |
| + media::limits::kMinCertificateLength || |
| + server_certificate_buffer->ByteLength() > |
| + media::limits::kMaxCertificateLength) { |
| + NOTREACHED(); |
| + return; |
| + } |
| + |
| + const uint8_t* server_certificate_ptr = |
| + static_cast<const uint8_t*>(server_certificate_buffer->Map()); |
| + const uint32_t server_certificate_size = |
| + server_certificate_buffer->ByteLength(); |
| + std::vector<uint8_t> server_certificate_vector( |
| + server_certificate_ptr, server_certificate_ptr + server_certificate_size); |
| + |
| + dispatcher->Send(new PpapiMsg_PPPContentDecryptor_SetServerCertificate( |
| + API_ID_PPP_CONTENT_DECRYPTOR_PRIVATE, |
| + instance, |
| + promise_id, |
| + server_certificate_vector)); |
| +} |
| + |
| void CreateSession(PP_Instance instance, |
| uint32_t promise_id, |
| PP_Var init_data_type, |
| @@ -178,20 +213,73 @@ void UpdateSession(PP_Instance instance, |
| SerializedVarSendInput(dispatcher, response))); |
| } |
| -void ReleaseSession(PP_Instance instance, |
| - uint32_t promise_id, |
| - PP_Var web_session_id) { |
| +void CloseSession(PP_Instance instance, |
| + uint32_t promise_id, |
| + PP_Var web_session_id) { |
| HostDispatcher* dispatcher = HostDispatcher::GetForInstance(instance); |
| if (!dispatcher) { |
| NOTREACHED(); |
| return; |
| } |
| - dispatcher->Send(new PpapiMsg_PPPContentDecryptor_ReleaseSession( |
| + StringVar* session_id = StringVar::FromPPVar(web_session_id); |
| + if (!session_id || |
| + session_id->value().length() > media::limits::kMaxWebSessionIdLength) { |
| + NOTREACHED(); |
| + return; |
| + } |
| + |
| + dispatcher->Send(new PpapiMsg_PPPContentDecryptor_CloseSession( |
| API_ID_PPP_CONTENT_DECRYPTOR_PRIVATE, |
| instance, |
| promise_id, |
| - SerializedVarSendInput(dispatcher, web_session_id))); |
| + session_id->value())); |
| +} |
| + |
| +void RemoveSession(PP_Instance instance, |
| + uint32_t promise_id, |
| + PP_Var web_session_id) { |
| + HostDispatcher* dispatcher = HostDispatcher::GetForInstance(instance); |
| + if (!dispatcher) { |
| + NOTREACHED(); |
| + return; |
| + } |
| + |
| + StringVar* session_id = StringVar::FromPPVar(web_session_id); |
| + if (!session_id || |
| + session_id->value().length() > media::limits::kMaxWebSessionIdLength) { |
| + NOTREACHED(); |
| + return; |
| + } |
| + |
| + dispatcher->Send(new PpapiMsg_PPPContentDecryptor_RemoveSession( |
| + API_ID_PPP_CONTENT_DECRYPTOR_PRIVATE, |
| + instance, |
| + promise_id, |
| + session_id->value())); |
| +} |
| + |
| +void GetUsableKeyIds(PP_Instance instance, |
| + uint32_t promise_id, |
| + PP_Var web_session_id) { |
| + HostDispatcher* dispatcher = HostDispatcher::GetForInstance(instance); |
| + if (!dispatcher) { |
| + NOTREACHED(); |
| + return; |
| + } |
| + |
| + StringVar* session_id = StringVar::FromPPVar(web_session_id); |
| + if (!session_id || |
| + session_id->value().length() > media::limits::kMaxWebSessionIdLength) { |
| + NOTREACHED(); |
| + return; |
| + } |
| + |
| + dispatcher->Send(new PpapiMsg_PPPContentDecryptor_GetUsableKeyIds( |
| + API_ID_PPP_CONTENT_DECRYPTOR_PRIVATE, |
| + instance, |
| + promise_id, |
| + session_id->value())); |
| } |
| void Decrypt(PP_Instance instance, |
| @@ -382,18 +470,20 @@ void DecryptAndDecode(PP_Instance instance, |
| } |
| static const PPP_ContentDecryptor_Private content_decryptor_interface = { |
| - &Initialize, |
| - &CreateSession, |
| - &LoadSession, |
| - &UpdateSession, |
| - &ReleaseSession, |
| - &Decrypt, |
| - &InitializeAudioDecoder, |
| - &InitializeVideoDecoder, |
| - &DeinitializeDecoder, |
| - &ResetDecoder, |
| - &DecryptAndDecode |
| -}; |
| + &Initialize, |
| + &SetServerCertificate, |
| + &CreateSession, |
| + &LoadSession, |
| + &UpdateSession, |
| + &CloseSession, |
| + &RemoveSession, |
| + &GetUsableKeyIds, |
| + &Decrypt, |
| + &InitializeAudioDecoder, |
| + &InitializeVideoDecoder, |
| + &DeinitializeDecoder, |
| + &ResetDecoder, |
| + &DecryptAndDecode}; |
| } // namespace |
| @@ -427,14 +517,20 @@ bool PPP_ContentDecryptor_Private_Proxy::OnMessageReceived( |
| IPC_BEGIN_MESSAGE_MAP(PPP_ContentDecryptor_Private_Proxy, msg) |
| IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_Initialize, |
| OnMsgInitialize) |
| + IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_SetServerCertificate, |
| + OnMsgSetServerCertificate) |
| IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_CreateSession, |
| OnMsgCreateSession) |
| IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_LoadSession, |
| OnMsgLoadSession) |
| IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_UpdateSession, |
| OnMsgUpdateSession) |
| - IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_ReleaseSession, |
| - OnMsgReleaseSession) |
| + IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_CloseSession, |
| + OnMsgCloseSession) |
| + IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_RemoveSession, |
| + OnMsgRemoveSession) |
| + IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_GetUsableKeyIds, |
| + OnMsgGetUsableKeyIds) |
| IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_Decrypt, |
| OnMsgDecrypt) |
| IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_InitializeAudioDecoder, |
| @@ -464,6 +560,27 @@ void PPP_ContentDecryptor_Private_Proxy::OnMsgInitialize( |
| } |
| } |
| +void PPP_ContentDecryptor_Private_Proxy::OnMsgSetServerCertificate( |
| + PP_Instance instance, |
| + uint32_t promise_id, |
| + std::vector<uint8_t> server_certificate) { |
| + if (server_certificate.size() < media::limits::kMinCertificateLength || |
| + server_certificate.size() > media::limits::kMaxCertificateLength) { |
| + NOTREACHED(); |
| + return; |
| + } |
| + |
| + if (ppp_decryptor_impl_) { |
| + PP_Var server_certificate_buffer = |
| + PpapiGlobals::Get()->GetVarTracker()->MakeArrayBufferPPVar( |
| + server_certificate.size(), server_certificate.data()); |
|
dmichael (off chromium)
2014/09/04 21:17:11
Same problem as the PPB_Instance proxy; you never
jrummell
2014/09/04 23:05:03
Done.
|
| + CallWhileUnlocked(ppp_decryptor_impl_->SetServerCertificate, |
| + instance, |
| + promise_id, |
| + server_certificate_buffer); |
| + } |
| +} |
| + |
| void PPP_ContentDecryptor_Private_Proxy::OnMsgCreateSession( |
| PP_Instance instance, |
| uint32_t promise_id, |
| @@ -509,16 +626,39 @@ void PPP_ContentDecryptor_Private_Proxy::OnMsgUpdateSession( |
| } |
| } |
| -void PPP_ContentDecryptor_Private_Proxy::OnMsgReleaseSession( |
| +void PPP_ContentDecryptor_Private_Proxy::OnMsgCloseSession( |
| PP_Instance instance, |
| uint32_t promise_id, |
| - SerializedVarReceiveInput web_session_id) { |
| + const std::string& web_session_id) { |
| if (ppp_decryptor_impl_) { |
| - CallWhileUnlocked( |
| - ppp_decryptor_impl_->ReleaseSession, |
| - instance, |
| - promise_id, |
| - ExtractReceivedVarAndAddRef(dispatcher(), &web_session_id)); |
| + CallWhileUnlocked(ppp_decryptor_impl_->CloseSession, |
| + instance, |
| + promise_id, |
| + StringVar::StringToPPVar(web_session_id)); |
|
dmichael (off chromium)
2014/09/04 21:17:11
ditto
jrummell
2014/09/04 23:05:03
Done.
|
| + } |
| +} |
| + |
| +void PPP_ContentDecryptor_Private_Proxy::OnMsgRemoveSession( |
| + PP_Instance instance, |
| + uint32_t promise_id, |
| + const std::string& web_session_id) { |
| + if (ppp_decryptor_impl_) { |
| + CallWhileUnlocked(ppp_decryptor_impl_->RemoveSession, |
| + instance, |
| + promise_id, |
| + StringVar::StringToPPVar(web_session_id)); |
|
dmichael (off chromium)
2014/09/04 21:17:11
ditto
jrummell
2014/09/04 23:05:03
Done.
|
| + } |
| +} |
| + |
| +void PPP_ContentDecryptor_Private_Proxy::OnMsgGetUsableKeyIds( |
| + PP_Instance instance, |
| + uint32_t promise_id, |
| + const std::string& web_session_id) { |
| + if (ppp_decryptor_impl_) { |
| + CallWhileUnlocked(ppp_decryptor_impl_->GetUsableKeyIds, |
| + instance, |
| + promise_id, |
| + StringVar::StringToPPVar(web_session_id)); |
|
dmichael (off chromium)
2014/09/04 21:17:11
ditto
jrummell
2014/09/04 23:05:03
Done.
|
| } |
| } |