Chromium Code Reviews| Index: ppapi/proxy/ppb_instance_proxy.cc |
| diff --git a/ppapi/proxy/ppb_instance_proxy.cc b/ppapi/proxy/ppb_instance_proxy.cc |
| index 1dfb897ca681e99acd45a7aea198da903fda2d19..b82639c01026eee32ad40db457da9294e1c582dc 100644 |
| --- a/ppapi/proxy/ppb_instance_proxy.cc |
| +++ b/ppapi/proxy/ppb_instance_proxy.cc |
| @@ -182,8 +182,6 @@ bool PPB_Instance_Proxy::OnMessageReceived(const IPC::Message& msg) { |
| OnHostMsgPromiseResolved) |
| IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_PromiseResolvedWithSession, |
| OnHostMsgPromiseResolvedWithSession) |
| - IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_PromiseResolvedWithKeyIds, |
| - OnHostMsgPromiseResolvedWithKeyIds) |
| IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_PromiseRejected, |
| OnHostMsgPromiseRejected) |
| IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_SessionMessage, |
| @@ -192,8 +190,6 @@ bool PPB_Instance_Proxy::OnMessageReceived(const IPC::Message& msg) { |
| OnHostMsgSessionKeysChange) |
| IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_SessionExpirationChange, |
| OnHostMsgSessionExpirationChange) |
| - IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_SessionReady, |
| - OnHostMsgSessionReady) |
| IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_SessionClosed, |
| OnHostMsgSessionClosed) |
| IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_SessionError, |
| @@ -586,35 +582,6 @@ void PPB_Instance_Proxy::PromiseResolvedWithSession(PP_Instance instance, |
| SerializedVarSendInput(dispatcher(), web_session_id_var))); |
| } |
| -void PPB_Instance_Proxy::PromiseResolvedWithKeyIds(PP_Instance instance, |
| - uint32 promise_id, |
| - PP_Var key_ids_var) { |
| - ArrayVar* key_ids_array = ArrayVar::FromPPVar(key_ids_var); |
| - if (!key_ids_array || |
| - key_ids_array->GetLength() > media::limits::kMaxKeyIds) { |
| - NOTREACHED(); |
| - return; |
| - } |
| - |
| - std::vector<std::vector<uint8_t> > key_ids; |
| - for (size_t i = 0; i < key_ids_array->GetLength(); ++i) { |
| - ArrayBufferVar* key_id = ArrayBufferVar::FromPPVar(key_ids_array->Get(i)); |
| - if (!key_id || key_id->ByteLength() < media::limits::kMinKeyIdLength || |
| - key_id->ByteLength() > media::limits::kMaxKeyIdLength) { |
| - NOTREACHED(); |
| - continue; |
| - } |
| - |
| - const uint8_t* key_id_ptr = static_cast<const uint8_t*>(key_id->Map()); |
| - const uint32_t key_id_size = key_id->ByteLength(); |
| - std::vector<uint8_t> key_id_vector(key_id_ptr, key_id_ptr + key_id_size); |
| - key_ids.push_back(key_id_vector); |
| - } |
| - |
| - dispatcher()->Send(new PpapiHostMsg_PPBInstance_PromiseResolvedWithKeyIds( |
| - API_ID_PPB_INSTANCE, instance, promise_id, key_ids)); |
| -} |
| - |
| void PPB_Instance_Proxy::PromiseRejected(PP_Instance instance, |
| uint32 promise_id, |
| PP_CdmExceptionCode exception_code, |
| @@ -631,19 +598,18 @@ void PPB_Instance_Proxy::PromiseRejected(PP_Instance instance, |
| void PPB_Instance_Proxy::SessionMessage(PP_Instance instance, |
| PP_Var web_session_id_var, |
| - PP_Var message_var, |
| - PP_Var destination_url_var) { |
| + PP_MessageType message_type, |
| + PP_Var message_var) { |
| dispatcher()->Send(new PpapiHostMsg_PPBInstance_SessionMessage( |
| - API_ID_PPB_INSTANCE, |
| - instance, |
| - SerializedVarSendInput(dispatcher(), web_session_id_var), |
| - SerializedVarSendInput(dispatcher(), message_var), |
| - SerializedVarSendInput(dispatcher(), destination_url_var))); |
| + API_ID_PPB_INSTANCE, instance, |
| + SerializedVarSendInput(dispatcher(), web_session_id_var), message_type, |
| + SerializedVarSendInput(dispatcher(), message_var))); |
| } |
| void PPB_Instance_Proxy::SessionKeysChange(PP_Instance instance, |
| PP_Var web_session_id_var, |
| - PP_Bool has_additional_usable_key) { |
| + PP_Bool has_additional_usable_key, |
| + PP_Var key_information_var) { |
| StringVar* session_id = StringVar::FromPPVar(web_session_id_var); |
| if (!session_id || |
| session_id->value().length() > media::limits::kMaxWebSessionIdLength) { |
| @@ -651,11 +617,42 @@ void PPB_Instance_Proxy::SessionKeysChange(PP_Instance instance, |
| return; |
| } |
| + ArrayVar* key_information_array = ArrayVar::FromPPVar(key_information_var); |
| + if (!key_information_array || |
| + key_information_array->GetLength() > media::limits::kMaxKeyIds) { |
| + NOTREACHED(); |
| + return; |
| + } |
| + |
| + std::vector<std::string> serialized_key_info; |
| + for (size_t i = 0; i < key_information_array->GetLength(); ++i) { |
| + ArrayBufferVar* key_info = |
| + ArrayBufferVar::FromPPVar(key_information_array->Get(i)); |
| + if (!key_info || key_info->ByteLength() != sizeof(PP_KeyInformation)) { |
| + NOTREACHED(); |
| + continue; |
| + } |
| + |
| + PP_KeyInformation new_key; |
| + memcpy(&new_key, key_info->Map(), sizeof(PP_KeyInformation)); |
| + if (new_key.key_id_size < media::limits::kMinKeyIdLength || |
| + new_key.key_id_size > media::limits::kMaxKeyIdLength) { |
| + NOTREACHED(); |
| + continue; |
| + } |
| + |
| + std::string serialized_info; |
| + if (!SerializeBlockInfo(new_key, &serialized_info)) { |
| + NOTREACHED(); |
| + return; |
| + } |
| + |
| + serialized_key_info.push_back(serialized_info); |
| + } |
| + |
| dispatcher()->Send(new PpapiHostMsg_PPBInstance_SessionKeysChange( |
| - API_ID_PPB_INSTANCE, |
| - instance, |
| - session_id->value(), |
| - has_additional_usable_key)); |
| + API_ID_PPB_INSTANCE, instance, session_id->value(), |
| + has_additional_usable_key, serialized_key_info)); |
| } |
| void PPB_Instance_Proxy::SessionExpirationChange(PP_Instance instance, |
| @@ -672,14 +669,6 @@ void PPB_Instance_Proxy::SessionExpirationChange(PP_Instance instance, |
| API_ID_PPB_INSTANCE, instance, session_id->value(), new_expiry_time)); |
| } |
| -void PPB_Instance_Proxy::SessionReady(PP_Instance instance, |
| - PP_Var web_session_id_var) { |
| - dispatcher()->Send(new PpapiHostMsg_PPBInstance_SessionReady( |
| - API_ID_PPB_INSTANCE, |
| - instance, |
| - SerializedVarSendInput(dispatcher(), web_session_id_var))); |
| -} |
| - |
| void PPB_Instance_Proxy::SessionClosed(PP_Instance instance, |
| PP_Var web_session_id_var) { |
| dispatcher()->Send(new PpapiHostMsg_PPBInstance_SessionClosed( |
| @@ -1286,40 +1275,6 @@ void PPB_Instance_Proxy::OnHostMsgPromiseResolvedWithSession( |
| } |
| } |
| -void PPB_Instance_Proxy::OnHostMsgPromiseResolvedWithKeyIds( |
| - PP_Instance instance, |
| - uint32_t promise_id, |
| - const std::vector<std::vector<uint8_t> >& key_ids) { |
| - if (!dispatcher()->permissions().HasPermission(PERMISSION_PRIVATE)) |
| - return; |
| - if (key_ids.size() > media::limits::kMaxKeyIds) { |
| - NOTREACHED(); |
| - return; |
| - } |
| - |
| - scoped_refptr<ArrayVar> key_ids_array = new ArrayVar(); |
| - key_ids_array->SetLength(key_ids.size()); |
| - for (size_t i = 0; i < key_ids.size(); ++i) { |
| - const std::vector<uint8_t>& entry = key_ids[i]; |
| - if (entry.size() < media::limits::kMinKeyIdLength || |
| - entry.size() > media::limits::kMaxKeyIdLength) { |
| - NOTREACHED(); |
| - continue; |
| - } |
| - key_ids_array->Set( |
| - i, |
| - PpapiGlobals::Get()->GetVarTracker()->MakeArrayBufferPPVar(entry.size(), |
| - &entry[0])); |
| - } |
| - |
| - EnterInstanceNoLock enter(instance); |
| - if (enter.succeeded()) { |
| - ScopedPPVar key_ids_var(ScopedPPVar::PassRef(), key_ids_array->GetPPVar()); |
| - enter.functions()->PromiseResolvedWithKeyIds( |
| - instance, promise_id, key_ids_var.get()); |
| - } |
| -} |
| - |
| void PPB_Instance_Proxy::OnHostMsgPromiseRejected( |
| PP_Instance instance, |
| uint32_t promise_id, |
| @@ -1341,31 +1296,54 @@ void PPB_Instance_Proxy::OnHostMsgPromiseRejected( |
| void PPB_Instance_Proxy::OnHostMsgSessionMessage( |
| PP_Instance instance, |
| SerializedVarReceiveInput web_session_id, |
| - SerializedVarReceiveInput message, |
| - SerializedVarReceiveInput destination_url) { |
| + PP_MessageType message_type, |
| + SerializedVarReceiveInput message) { |
| if (!dispatcher()->permissions().HasPermission(PERMISSION_PRIVATE)) |
| return; |
| EnterInstanceNoLock enter(instance); |
| if (enter.succeeded()) { |
| enter.functions()->SessionMessage(instance, |
| web_session_id.Get(dispatcher()), |
| - message.Get(dispatcher()), |
| - destination_url.Get(dispatcher())); |
| + message_type, message.Get(dispatcher())); |
| } |
| } |
| void PPB_Instance_Proxy::OnHostMsgSessionKeysChange( |
| PP_Instance instance, |
| const std::string& web_session_id, |
| - PP_Bool has_additional_usable_key) { |
| + PP_Bool has_additional_usable_key, |
| + const std::vector<std::string>& serialized_key_ids) { |
| if (!dispatcher()->permissions().HasPermission(PERMISSION_PRIVATE)) |
| return; |
| + |
| + if (serialized_key_ids.size() > media::limits::kMaxKeyIds) { |
| + NOTREACHED(); |
| + return; |
| + } |
| + |
| + scoped_refptr<ArrayVar> key_ids_array = new ArrayVar(); |
| + key_ids_array->SetLength(serialized_key_ids.size()); |
| + for (size_t i = 0; i < serialized_key_ids.size(); ++i) { |
| + PP_KeyInformation info; |
| + |
| + if (!DeserializeBlockInfo(serialized_key_ids[i], &info)) { |
| + NOTREACHED(); |
| + continue; |
| + } |
| + |
| + key_ids_array->Set( |
| + i, PpapiGlobals::Get()->GetVarTracker()->MakeArrayBufferPPVar( |
| + sizeof(PP_KeyInformation), &info)); |
|
dcheng
2014/12/18 22:35:03
Ditto: sizeof(info) instead of sizeof(PP_KeyInform
jrummell
2014/12/18 23:47:59
Done.
|
| + } |
| + |
| EnterInstanceNoLock enter(instance); |
| if (enter.succeeded()) { |
| ScopedPPVar web_session_id_var(ScopedPPVar::PassRef(), |
| StringVar::StringToPPVar(web_session_id)); |
| - enter.functions()->SessionKeysChange( |
| - instance, web_session_id_var.get(), has_additional_usable_key); |
| + ScopedPPVar key_ids_var(ScopedPPVar::PassRef(), key_ids_array->GetPPVar()); |
| + enter.functions()->SessionKeysChange(instance, web_session_id_var.get(), |
| + has_additional_usable_key, |
| + key_ids_var.get()); |
| } |
| } |
| @@ -1384,17 +1362,6 @@ void PPB_Instance_Proxy::OnHostMsgSessionExpirationChange( |
| } |
| } |
| -void PPB_Instance_Proxy::OnHostMsgSessionReady( |
| - PP_Instance instance, |
| - SerializedVarReceiveInput web_session_id) { |
| - if (!dispatcher()->permissions().HasPermission(PERMISSION_PRIVATE)) |
| - return; |
| - EnterInstanceNoLock enter(instance); |
| - if (enter.succeeded()) { |
| - enter.functions()->SessionReady(instance, web_session_id.Get(dispatcher())); |
| - } |
| -} |
| - |
| void PPB_Instance_Proxy::OnHostMsgSessionClosed( |
| PP_Instance instance, |
| SerializedVarReceiveInput web_session_id) { |