Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(590)

Side by Side Diff: ppapi/proxy/ppp_content_decryptor_private_proxy.cc

Issue 24192004: Changes to the EME Pepper API (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "ppapi/proxy/ppp_content_decryptor_private_proxy.h" 5 #include "ppapi/proxy/ppp_content_decryptor_private_proxy.h"
6 6
7 #include "base/platform_file.h" 7 #include "base/platform_file.h"
8 #include "ppapi/c/pp_bool.h" 8 #include "ppapi/c/pp_bool.h"
9 #include "ppapi/c/ppb_core.h" 9 #include "ppapi/c/ppb_core.h"
10 #include "ppapi/proxy/content_decryptor_private_serializer.h" 10 #include "ppapi/proxy/content_decryptor_private_serializer.h"
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 resource, 102 resource,
103 &handle) == PP_FALSE) 103 &handle) == PP_FALSE)
104 return false; 104 return false;
105 105
106 buffer->resource = host_resource; 106 buffer->resource = host_resource;
107 buffer->handle = handle; 107 buffer->handle = handle;
108 buffer->size = size; 108 buffer->size = size;
109 return true; 109 return true;
110 } 110 }
111 111
112 void Initialize(PP_Instance instance,
113 PP_Var key_system,
114 const PP_KeySystemFlags* key_system_flags) {
115 HostDispatcher* dispatcher = HostDispatcher::GetForInstance(instance);
116 if (!dispatcher) {
117 NOTREACHED();
118 return;
119 }
120
121 std::string serialized_flags;
122 if (!SerializeBlockInfo(*key_system_flags, &serialized_flags)) {
123 NOTREACHED();
124 return;
125 }
126
127 dispatcher->Send(
128 new PpapiMsg_PPPContentDecryptor_Initialize(
129 API_ID_PPP_CONTENT_DECRYPTOR_PRIVATE,
130 instance,
131 SerializedVarSendInput(dispatcher, key_system),
132 serialized_flags));
133 }
134
112 void GenerateKeyRequest(PP_Instance instance, 135 void GenerateKeyRequest(PP_Instance instance,
113 PP_Var key_system,
114 PP_Var type, 136 PP_Var type,
115 PP_Var init_data) { 137 PP_Var init_data) {
116 HostDispatcher* dispatcher = HostDispatcher::GetForInstance(instance); 138 HostDispatcher* dispatcher = HostDispatcher::GetForInstance(instance);
117 if (!dispatcher) { 139 if (!dispatcher) {
118 NOTREACHED(); 140 NOTREACHED();
119 return; 141 return;
120 } 142 }
121 143
122 dispatcher->Send( 144 dispatcher->Send(
123 new PpapiMsg_PPPContentDecryptor_GenerateKeyRequest( 145 new PpapiMsg_PPPContentDecryptor_GenerateKeyRequest(
124 API_ID_PPP_CONTENT_DECRYPTOR_PRIVATE, 146 API_ID_PPP_CONTENT_DECRYPTOR_PRIVATE,
125 instance, 147 instance,
126 SerializedVarSendInput(dispatcher, key_system),
127 SerializedVarSendInput(dispatcher, type), 148 SerializedVarSendInput(dispatcher, type),
128 SerializedVarSendInput(dispatcher, init_data))); 149 SerializedVarSendInput(dispatcher, init_data)));
129 } 150 }
130 151
131 void AddKey(PP_Instance instance, 152 void AddKey(PP_Instance instance,
132 PP_Var session_id, 153 PP_Var session_id,
133 PP_Var key, 154 PP_Var key,
134 PP_Var init_data) { 155 PP_Var init_data) {
135 HostDispatcher* dispatcher = HostDispatcher::GetForInstance(instance); 156 HostDispatcher* dispatcher = HostDispatcher::GetForInstance(instance);
136 if (!dispatcher) { 157 if (!dispatcher) {
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 dispatcher->Send( 363 dispatcher->Send(
343 new PpapiMsg_PPPContentDecryptor_DecryptAndDecode( 364 new PpapiMsg_PPPContentDecryptor_DecryptAndDecode(
344 API_ID_PPP_CONTENT_DECRYPTOR_PRIVATE, 365 API_ID_PPP_CONTENT_DECRYPTOR_PRIVATE,
345 instance, 366 instance,
346 decoder_type, 367 decoder_type,
347 buffer, 368 buffer,
348 serialized_block_info)); 369 serialized_block_info));
349 } 370 }
350 371
351 static const PPP_ContentDecryptor_Private content_decryptor_interface = { 372 static const PPP_ContentDecryptor_Private content_decryptor_interface = {
373 &Initialize,
352 &GenerateKeyRequest, 374 &GenerateKeyRequest,
353 &AddKey, 375 &AddKey,
354 &CancelKeyRequest, 376 &CancelKeyRequest,
355 &Decrypt, 377 &Decrypt,
356 &InitializeAudioDecoder, 378 &InitializeAudioDecoder,
357 &InitializeVideoDecoder, 379 &InitializeVideoDecoder,
358 &DeinitializeDecoder, 380 &DeinitializeDecoder,
359 &ResetDecoder, 381 &ResetDecoder,
360 &DecryptAndDecode 382 &DecryptAndDecode
361 }; 383 };
(...skipping 21 matching lines...) Expand all
383 } 405 }
384 406
385 bool PPP_ContentDecryptor_Private_Proxy::OnMessageReceived( 407 bool PPP_ContentDecryptor_Private_Proxy::OnMessageReceived(
386 const IPC::Message& msg) { 408 const IPC::Message& msg) {
387 if (!dispatcher()->IsPlugin()) 409 if (!dispatcher()->IsPlugin())
388 return false; // These are only valid from host->plugin. 410 return false; // These are only valid from host->plugin.
389 // Don't allow the plugin to send these to the host. 411 // Don't allow the plugin to send these to the host.
390 412
391 bool handled = true; 413 bool handled = true;
392 IPC_BEGIN_MESSAGE_MAP(PPP_ContentDecryptor_Private_Proxy, msg) 414 IPC_BEGIN_MESSAGE_MAP(PPP_ContentDecryptor_Private_Proxy, msg)
415 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_Initialize,
416 OnMsgInitialize)
393 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_GenerateKeyRequest, 417 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_GenerateKeyRequest,
394 OnMsgGenerateKeyRequest) 418 OnMsgGenerateKeyRequest)
395 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_AddKey, 419 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_AddKey,
396 OnMsgAddKey) 420 OnMsgAddKey)
397 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_CancelKeyRequest, 421 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_CancelKeyRequest,
398 OnMsgCancelKeyRequest) 422 OnMsgCancelKeyRequest)
399 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_Decrypt, 423 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_Decrypt,
400 OnMsgDecrypt) 424 OnMsgDecrypt)
401 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_InitializeAudioDecoder, 425 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_InitializeAudioDecoder,
402 OnMsgInitializeAudioDecoder) 426 OnMsgInitializeAudioDecoder)
403 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_InitializeVideoDecoder, 427 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_InitializeVideoDecoder,
404 OnMsgInitializeVideoDecoder) 428 OnMsgInitializeVideoDecoder)
405 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_DeinitializeDecoder, 429 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_DeinitializeDecoder,
406 OnMsgDeinitializeDecoder) 430 OnMsgDeinitializeDecoder)
407 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_ResetDecoder, 431 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_ResetDecoder,
408 OnMsgResetDecoder) 432 OnMsgResetDecoder)
409 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_DecryptAndDecode, 433 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_DecryptAndDecode,
410 OnMsgDecryptAndDecode) 434 OnMsgDecryptAndDecode)
411 IPC_MESSAGE_UNHANDLED(handled = false) 435 IPC_MESSAGE_UNHANDLED(handled = false)
412 IPC_END_MESSAGE_MAP() 436 IPC_END_MESSAGE_MAP()
413 DCHECK(handled); 437 DCHECK(handled);
414 return handled; 438 return handled;
415 } 439 }
416 440
441 void PPP_ContentDecryptor_Private_Proxy::OnMsgInitialize(
442 PP_Instance instance,
443 SerializedVarReceiveInput key_system,
444 const std::string& serialized_key_systems_flags) {
445 if (ppp_decryptor_impl_) {
446 PP_KeySystemFlags key_system_flags;
447 if (!DeserializeBlockInfo(serialized_key_systems_flags, &key_system_flags))
dmichael (off chromium) 2013/09/18 22:52:32 hmm, I probably never should have lgtmed Deseriali
jrummell 2013/09/19 00:37:28 Switched to pass a bool, and avoid the serializati
448 return;
449 CallWhileUnlocked(ppp_decryptor_impl_->Initialize,
450 instance,
451 ExtractReceivedVarAndAddRef(dispatcher(), &key_system),
452 const_cast<const PP_KeySystemFlags*>(&key_system_flags));
ddorwin 2013/09/18 22:22:24 There's no way to pass structs by value or const r
dmichael (off chromium) 2013/09/18 22:52:32 No const-ref in C. You could technically use by-va
453 }
454 }
455
417 void PPP_ContentDecryptor_Private_Proxy::OnMsgGenerateKeyRequest( 456 void PPP_ContentDecryptor_Private_Proxy::OnMsgGenerateKeyRequest(
418 PP_Instance instance, 457 PP_Instance instance,
419 SerializedVarReceiveInput key_system,
420 SerializedVarReceiveInput type, 458 SerializedVarReceiveInput type,
421 SerializedVarReceiveInput init_data) { 459 SerializedVarReceiveInput init_data) {
422 if (ppp_decryptor_impl_) { 460 if (ppp_decryptor_impl_) {
423 CallWhileUnlocked(ppp_decryptor_impl_->GenerateKeyRequest, 461 CallWhileUnlocked(ppp_decryptor_impl_->GenerateKeyRequest,
424 instance, 462 instance,
425 ExtractReceivedVarAndAddRef(dispatcher(), &key_system),
426 ExtractReceivedVarAndAddRef(dispatcher(), &type), 463 ExtractReceivedVarAndAddRef(dispatcher(), &type),
427 ExtractReceivedVarAndAddRef(dispatcher(), &init_data)); 464 ExtractReceivedVarAndAddRef(dispatcher(), &init_data));
428 } 465 }
429 } 466 }
430 467
431 void PPP_ContentDecryptor_Private_Proxy::OnMsgAddKey( 468 void PPP_ContentDecryptor_Private_Proxy::OnMsgAddKey(
432 PP_Instance instance, 469 PP_Instance instance,
433 SerializedVarReceiveInput session_id, 470 SerializedVarReceiveInput session_id,
434 SerializedVarReceiveInput key, 471 SerializedVarReceiveInput key,
435 SerializedVarReceiveInput init_data) { 472 SerializedVarReceiveInput init_data) {
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
572 ppp_decryptor_impl_->DecryptAndDecode, 609 ppp_decryptor_impl_->DecryptAndDecode,
573 instance, 610 instance,
574 decoder_type, 611 decoder_type,
575 plugin_resource.get(), 612 plugin_resource.get(),
576 const_cast<const PP_EncryptedBlockInfo*>(&block_info)); 613 const_cast<const PP_EncryptedBlockInfo*>(&block_info));
577 } 614 }
578 } 615 }
579 616
580 } // namespace proxy 617 } // namespace proxy
581 } // namespace ppapi 618 } // namespace ppapi
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698