Chromium Code Reviews| Index: ppapi/cpp/private/content_decryptor_private.cc |
| diff --git a/ppapi/cpp/private/content_decryptor_private.cc b/ppapi/cpp/private/content_decryptor_private.cc |
| index 3142511f7fbe6238ebdd580c865051afac098d23..667ab25ddac3ad9dea9016d2ed8491c960fc75bf 100644 |
| --- a/ppapi/cpp/private/content_decryptor_private.cc |
| +++ b/ppapi/cpp/private/content_decryptor_private.cc |
| @@ -15,6 +15,7 @@ |
| #include "ppapi/cpp/module.h" |
| #include "ppapi/cpp/module_impl.h" |
| #include "ppapi/cpp/var.h" |
| +#include "ppapi/cpp/var_array.h" |
| namespace pp { |
| @@ -38,6 +39,23 @@ void Initialize(PP_Instance instance, |
| key_system_var.AsString()); |
| } |
| +void SetServerCertificate(PP_Instance instance, |
| + uint32_t promise_id, |
| + PP_Var server_certificate_arg) { |
| + void* object = |
| + Instance::GetPerInstanceObject(instance, kPPPContentDecryptorInterface); |
| + if (!object) |
| + return; |
| + |
| + pp::Var server_certificate_var(server_certificate_arg); |
| + if (!server_certificate_var.is_array_buffer()) |
| + return; |
| + pp::VarArrayBuffer server_certificate(server_certificate_var); |
| + |
| + static_cast<ContentDecryptor_Private*>(object) |
| + ->SetServerCertificate(promise_id, server_certificate); |
| +} |
| + |
| void CreateSession(PP_Instance instance, |
| uint32_t promise_id, |
| PP_Var init_data_type_arg, |
| @@ -102,9 +120,41 @@ void UpdateSession(PP_Instance instance, |
| ->UpdateSession(promise_id, web_session_id_var.AsString(), response); |
| } |
| -void ReleaseSession(PP_Instance instance, |
| - uint32_t promise_id, |
| - PP_Var web_session_id_arg) { |
| +void GetUsableKeyIds(PP_Instance instance, |
| + uint32_t promise_id, |
| + PP_Var web_session_id_arg) { |
| + void* object = |
| + Instance::GetPerInstanceObject(instance, kPPPContentDecryptorInterface); |
| + if (!object) |
| + return; |
| + |
| + pp::Var web_session_id_var(web_session_id_arg); |
| + if (!web_session_id_var.is_string()) |
| + return; |
| + |
| + static_cast<ContentDecryptor_Private*>(object) |
| + ->GetUsableKeyIds(promise_id, web_session_id_var.AsString()); |
| +} |
| + |
| +void CloseSession(PP_Instance instance, |
| + uint32_t promise_id, |
| + PP_Var web_session_id_arg) { |
| + void* object = |
| + Instance::GetPerInstanceObject(instance, kPPPContentDecryptorInterface); |
| + if (!object) |
| + return; |
| + |
| + pp::Var web_session_id_var(web_session_id_arg); |
| + if (!web_session_id_var.is_string()) |
| + return; |
| + |
| + static_cast<ContentDecryptor_Private*>(object) |
| + ->CloseSession(promise_id, web_session_id_var.AsString()); |
| +} |
| + |
| +void RemoveSession(PP_Instance instance, |
| + uint32_t promise_id, |
| + PP_Var web_session_id_arg) { |
| void* object = |
| Instance::GetPerInstanceObject(instance, kPPPContentDecryptorInterface); |
| if (!object) |
| @@ -115,7 +165,7 @@ void ReleaseSession(PP_Instance instance, |
| return; |
| static_cast<ContentDecryptor_Private*>(object) |
| - ->ReleaseSession(promise_id, web_session_id_var.AsString()); |
| + ->RemoveSession(promise_id, web_session_id_var.AsString()); |
| } |
| void Decrypt(PP_Instance instance, |
| @@ -206,18 +256,20 @@ void DecryptAndDecode(PP_Instance instance, |
| } |
| const PPP_ContentDecryptor_Private ppp_content_decryptor = { |
| - &Initialize, |
| - &CreateSession, |
| - &LoadSession, |
| - &UpdateSession, |
| - &ReleaseSession, |
| - &Decrypt, |
| - &InitializeAudioDecoder, |
| - &InitializeVideoDecoder, |
| - &DeinitializeDecoder, |
| - &ResetDecoder, |
| - &DecryptAndDecode |
| -}; |
| + &Initialize, |
| + &SetServerCertificate, |
| + &CreateSession, |
| + &LoadSession, |
| + &UpdateSession, |
| + &GetUsableKeyIds, |
|
ddorwin
2014/08/22 20:49:21
ditto
jrummell
2014/08/25 21:54:37
Done.
|
| + &CloseSession, |
| + &RemoveSession, |
| + &Decrypt, |
| + &InitializeAudioDecoder, |
| + &InitializeVideoDecoder, |
| + &DeinitializeDecoder, |
| + &ResetDecoder, |
| + &DecryptAndDecode}; |
| template <> const char* interface_name<PPB_ContentDecryptor_Private>() { |
| return PPB_CONTENTDECRYPTOR_PRIVATE_INTERFACE; |
| @@ -257,6 +309,22 @@ void ContentDecryptor_Private::PromiseResolvedWithSession( |
| } |
| } |
| +void ContentDecryptor_Private::PromiseResolvedWithKeyIds( |
| + uint32_t promise_id, |
| + const std::vector<std::vector<uint8_t> >& key_ids) { |
| + if (has_interface<PPB_ContentDecryptor_Private>()) { |
| + pp::VarArray key_ids_array = pp::VarArray(); |
| + for (size_t i = 0; i < key_ids.size(); ++i) { |
| + std::vector<uint8_t> entry = key_ids[i]; |
|
ddorwin
2014/08/22 20:49:21
const ref?
jrummell
2014/08/25 21:54:37
Done.
|
| + pp::VarArrayBuffer array_buffer(entry.size()); |
| + memcpy(array_buffer.Map(), &entry[0], entry.size()); |
| + key_ids_array.Set(i, pp::Var(array_buffer)); |
|
ddorwin
2014/08/22 20:49:21
Is there an Add() or Push()? It seems odd that you
jrummell
2014/08/25 21:54:37
Nope. Added a call to SetLength() above to make it
|
| + } |
| + get_interface<PPB_ContentDecryptor_Private>()->PromiseResolvedWithKeyIds( |
| + associated_instance_.pp_instance(), promise_id, key_ids_array.pp_var()); |
| + } |
| +} |
| + |
| void ContentDecryptor_Private::PromiseRejected( |
| uint32_t promise_id, |
| PP_CdmExceptionCode exception_code, |
| @@ -288,6 +356,30 @@ void ContentDecryptor_Private::SessionMessage( |
| } |
| } |
| +void ContentDecryptor_Private::SessionKeysChange( |
| + const std::string& web_session_id, |
| + bool has_additional_usable_key) { |
| + if (has_interface<PPB_ContentDecryptor_Private>()) { |
| + pp::Var web_session_id_var(web_session_id); |
| + get_interface<PPB_ContentDecryptor_Private>()->SessionKeysChange( |
| + associated_instance_.pp_instance(), |
| + web_session_id_var.pp_var(), |
| + PP_FromBool(has_additional_usable_key)); |
| + } |
| +} |
| + |
| +void ContentDecryptor_Private::SessionExpirationChange( |
| + const std::string& web_session_id, |
| + PP_Time new_expiry_time) { |
| + if (has_interface<PPB_ContentDecryptor_Private>()) { |
| + pp::Var web_session_id_var(web_session_id); |
| + get_interface<PPB_ContentDecryptor_Private>()->SessionExpirationChange( |
| + associated_instance_.pp_instance(), |
| + web_session_id_var.pp_var(), |
| + new_expiry_time); |
| + } |
| +} |
| + |
| void ContentDecryptor_Private::SessionReady(const std::string& web_session_id) { |
| if (has_interface<PPB_ContentDecryptor_Private>()) { |
| pp::Var web_session_id_var(web_session_id); |