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

Side by Side Diff: ppapi/cpp/private/content_decryptor_private.cc

Issue 10928098: Return void from all PPP CDM API interface methods (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased Created 8 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 | Annotate | Revision Log
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/cpp/private/content_decryptor_private.h" 5 #include "ppapi/cpp/private/content_decryptor_private.h"
6 6
7 #include <cstring> // memcpy 7 #include <cstring> // memcpy
8 8
9 #include "ppapi/c/ppb_var.h" 9 #include "ppapi/c/ppb_var.h"
10 #include "ppapi/c/private/ppb_content_decryptor_private.h" 10 #include "ppapi/c/private/ppb_content_decryptor_private.h"
11 #include "ppapi/c/private/ppp_content_decryptor_private.h" 11 #include "ppapi/c/private/ppp_content_decryptor_private.h"
12 #include "ppapi/cpp/instance.h" 12 #include "ppapi/cpp/instance.h"
13 #include "ppapi/cpp/instance_handle.h" 13 #include "ppapi/cpp/instance_handle.h"
14 #include "ppapi/cpp/logging.h" 14 #include "ppapi/cpp/logging.h"
15 #include "ppapi/cpp/module.h" 15 #include "ppapi/cpp/module.h"
16 #include "ppapi/cpp/module_impl.h" 16 #include "ppapi/cpp/module_impl.h"
17 #include "ppapi/cpp/var.h" 17 #include "ppapi/cpp/var.h"
18 18
19 namespace pp { 19 namespace pp {
20 20
21 namespace { 21 namespace {
22 22
23 static const char kPPPContentDecryptorInterface[] = 23 static const char kPPPContentDecryptorInterface[] =
24 PPP_CONTENTDECRYPTOR_PRIVATE_INTERFACE; 24 PPP_CONTENTDECRYPTOR_PRIVATE_INTERFACE;
25 25
26 PP_Bool GenerateKeyRequest(PP_Instance instance, 26 void GenerateKeyRequest(PP_Instance instance,
27 PP_Var key_system_arg, 27 PP_Var key_system_arg,
28 PP_Var init_data_arg) { 28 PP_Var init_data_arg) {
29 void* object = 29 void* object =
30 Instance::GetPerInstanceObject(instance, kPPPContentDecryptorInterface); 30 Instance::GetPerInstanceObject(instance, kPPPContentDecryptorInterface);
31 if (!object) 31 if (!object)
32 return PP_FALSE; 32 return;
xhwang 2012/09/13 12:24:59 For here and below, if this happens, is it a codin
Tom Finegan 2012/09/14 00:08:37 Yeah... I was being a little bit over conservative
33 33
34 pp::Var key_system_var(pp::PASS_REF, key_system_arg); 34 pp::Var key_system_var(pp::PASS_REF, key_system_arg);
35 if (key_system_var.is_string() == false) 35 if (key_system_var.is_string() == false)
36 return PP_FALSE; 36 return;
37 37
38 pp::Var init_data_var(pp::PASS_REF, init_data_arg); 38 pp::Var init_data_var(pp::PASS_REF, init_data_arg);
39 if (init_data_var.is_array_buffer() == false) 39 if (init_data_var.is_array_buffer() == false)
40 return PP_FALSE; 40 return;
41 pp::VarArrayBuffer init_data_array_buffer(init_data_var); 41 pp::VarArrayBuffer init_data_array_buffer(init_data_var);
42 42
43 return PP_FromBool( 43 static_cast<ContentDecryptor_Private*>(object)->GenerateKeyRequest(
44 static_cast<ContentDecryptor_Private*>(object)->GenerateKeyRequest( 44 key_system_var.AsString(),
45 key_system_var.AsString(), 45 init_data_array_buffer);
46 init_data_array_buffer));
47 } 46 }
48 47
49 PP_Bool AddKey(PP_Instance instance, 48 void AddKey(PP_Instance instance,
50 PP_Var session_id_arg, 49 PP_Var session_id_arg,
51 PP_Var key_arg, 50 PP_Var key_arg,
52 PP_Var init_data_arg) { 51 PP_Var init_data_arg) {
53 void* object = 52 void* object =
54 Instance::GetPerInstanceObject(instance, kPPPContentDecryptorInterface); 53 Instance::GetPerInstanceObject(instance, kPPPContentDecryptorInterface);
55 if (!object) 54 if (!object)
56 return PP_FALSE; 55 return;
57 56
58 pp::Var session_id_var(pp::PASS_REF, session_id_arg); 57 pp::Var session_id_var(pp::PASS_REF, session_id_arg);
59 if (session_id_var.is_string() == false) 58 if (session_id_var.is_string() == false)
60 return PP_FALSE; 59 return;
61 60
62 pp::Var key_var(pp::PASS_REF, key_arg); 61 pp::Var key_var(pp::PASS_REF, key_arg);
63 if (key_var.is_array_buffer() == false) 62 if (key_var.is_array_buffer() == false)
64 return PP_FALSE; 63 return;
65 pp::VarArrayBuffer key(key_var); 64 pp::VarArrayBuffer key(key_var);
66 65
67 pp::Var init_data_var(pp::PASS_REF, init_data_arg); 66 pp::Var init_data_var(pp::PASS_REF, init_data_arg);
68 if (init_data_var.is_array_buffer() == false) 67 if (init_data_var.is_array_buffer() == false)
69 return PP_FALSE; 68 return;
70 pp::VarArrayBuffer init_data(init_data_var); 69 pp::VarArrayBuffer init_data(init_data_var);
71 70
72 return PP_FromBool( 71
73 static_cast<ContentDecryptor_Private*>(object)->AddKey( 72 static_cast<ContentDecryptor_Private*>(object)->AddKey(
74 session_id_var.AsString(), 73 session_id_var.AsString(),
75 key, 74 key,
76 init_data)); 75 init_data);
77 } 76 }
78 77
79 PP_Bool CancelKeyRequest(PP_Instance instance, 78 void CancelKeyRequest(PP_Instance instance, PP_Var session_id_arg) {
80 PP_Var session_id_arg) {
81 void* object = 79 void* object =
82 Instance::GetPerInstanceObject(instance, kPPPContentDecryptorInterface); 80 Instance::GetPerInstanceObject(instance, kPPPContentDecryptorInterface);
83 if (!object) 81 if (!object)
84 return PP_FALSE; 82 return;
85 83
86 pp::Var session_id_var(pp::PASS_REF, session_id_arg); 84 pp::Var session_id_var(pp::PASS_REF, session_id_arg);
87 if (session_id_var.is_string() == false) 85 if (session_id_var.is_string() == false)
88 return PP_FALSE; 86 return;
89 87
90 return PP_FromBool( 88 static_cast<ContentDecryptor_Private*>(object)->CancelKeyRequest(
91 static_cast<ContentDecryptor_Private*>(object)-> 89 session_id_var.AsString());
92 CancelKeyRequest(session_id_var.AsString()));
93 } 90 }
94 91
95 92
96 PP_Bool Decrypt(PP_Instance instance, 93 void Decrypt(PP_Instance instance,
97 PP_Resource encrypted_resource, 94 PP_Resource encrypted_resource,
98 const PP_EncryptedBlockInfo* encrypted_block_info) { 95 const PP_EncryptedBlockInfo* encrypted_block_info) {
99 void* object = 96 void* object =
100 Instance::GetPerInstanceObject(instance, kPPPContentDecryptorInterface); 97 Instance::GetPerInstanceObject(instance, kPPPContentDecryptorInterface);
101 if (!object) 98 if (!object)
102 return PP_FALSE; 99 return;
103 100
104 pp::Buffer_Dev encrypted_block(pp::PassRef(), encrypted_resource); 101 pp::Buffer_Dev encrypted_block(pp::PassRef(), encrypted_resource);
105 102
106 return PP_FromBool( 103 static_cast<ContentDecryptor_Private*>(object)->Decrypt(
107 static_cast<ContentDecryptor_Private*>(object)->Decrypt( 104 encrypted_block,
108 encrypted_block, 105 *encrypted_block_info);
109 *encrypted_block_info));
110 } 106 }
111 107
112 PP_Bool DecryptAndDecode(PP_Instance instance, 108 void DecryptAndDecode(PP_Instance instance,
113 PP_Resource encrypted_resource, 109 PP_Resource encrypted_resource,
114 const PP_EncryptedBlockInfo* encrypted_block_info) { 110 const PP_EncryptedBlockInfo* encrypted_block_info) {
115 void* object = 111 void* object =
116 Instance::GetPerInstanceObject(instance, kPPPContentDecryptorInterface); 112 Instance::GetPerInstanceObject(instance, kPPPContentDecryptorInterface);
117 if (!object) 113 if (!object)
118 return PP_FALSE; 114 return;
119 115
120 pp::Buffer_Dev encrypted_block(pp::PassRef(), encrypted_resource); 116 pp::Buffer_Dev encrypted_block(pp::PassRef(), encrypted_resource);
121 117
122 return PP_FromBool( 118 static_cast<ContentDecryptor_Private*>(object)->DecryptAndDecode(
123 static_cast<ContentDecryptor_Private*>(object)->DecryptAndDecode( 119 encrypted_block,
124 encrypted_block, 120 *encrypted_block_info);
125 *encrypted_block_info));
126 } 121 }
127 122
128 const PPP_ContentDecryptor_Private ppp_content_decryptor = { 123 const PPP_ContentDecryptor_Private ppp_content_decryptor = {
129 &GenerateKeyRequest, 124 &GenerateKeyRequest,
130 &AddKey, 125 &AddKey,
131 &CancelKeyRequest, 126 &CancelKeyRequest,
132 &Decrypt, 127 &Decrypt,
133 &DecryptAndDecode 128 &DecryptAndDecode
134 }; 129 };
135 130
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 const PP_DecryptedBlockInfo& decrypted_block_info) { 235 const PP_DecryptedBlockInfo& decrypted_block_info) {
241 if (has_interface<PPB_ContentDecryptor_Private>()) { 236 if (has_interface<PPB_ContentDecryptor_Private>()) {
242 get_interface<PPB_ContentDecryptor_Private>()->DeliverSamples( 237 get_interface<PPB_ContentDecryptor_Private>()->DeliverSamples(
243 associated_instance_.pp_instance(), 238 associated_instance_.pp_instance(),
244 decrypted_samples.pp_resource(), 239 decrypted_samples.pp_resource(),
245 &decrypted_block_info); 240 &decrypted_block_info);
246 } 241 }
247 } 242 }
248 243
249 } // namespace pp 244 } // namespace pp
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698