OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "ppapi/cpp/dev/content_decryptor_dev.h" | |
6 | |
7 #include "ppapi/c/dev/ppp_content_decryptor_dev.h" | |
8 #include "ppapi/cpp/instance.h" | |
9 #include "ppapi/cpp/instance_handle.h" | |
10 #include "ppapi/cpp/module.h" | |
11 #include "ppapi/cpp/module_impl.h" | |
12 | |
13 namespace pp { | |
14 | |
15 namespace { | |
16 | |
17 static const char kPPPContentDecryptorInterface[] = | |
18 PPP_CONTENTDECRYPTOR_DEV_INTERFACE; | |
19 | |
20 PP_Bool GenerateKeyRequest(PP_Instance instance, | |
21 PP_Var key_system, | |
22 PP_Resource init_data) { | |
23 void* object = | |
24 Instance::GetPerInstanceObject(instance, kPPPContentDecryptorInterface); | |
25 if (!object) | |
26 return PP_FALSE; | |
27 return PP_FromBool( | |
28 static_cast<ContentDecryptor_Dev*>(object)->GenerateKeyRequest( | |
29 key_system, | |
30 init_data)); | |
31 } | |
32 | |
33 PP_Bool AddKey(PP_Instance instance, | |
34 PP_Var session_id, | |
35 PP_Resource key) { | |
36 void* object = | |
37 Instance::GetPerInstanceObject(instance, | |
38 kPPPContentDecryptorInterface); | |
fgalligan1
2012/07/24 04:33:41
nit: put param on line 37 like functions.
Tom Finegan
2012/07/25 02:00:07
Done.
| |
39 if (!object) | |
40 return PP_FALSE; | |
41 return PP_FromBool( | |
42 static_cast<ContentDecryptor_Dev*>(object)->AddKey(session_id, | |
43 key)); | |
fgalligan1
2012/07/24 04:33:41
nit: line up key with session_id
Tom Finegan
2012/07/25 02:00:07
Done.
| |
44 } | |
45 | |
46 PP_Bool CancelKeyRequest(PP_Instance instance, | |
47 PP_Var session_id) { | |
48 void* object = | |
49 Instance::GetPerInstanceObject(instance, kPPPContentDecryptorInterface); | |
50 if (!object) | |
51 return PP_FALSE; | |
52 return PP_FromBool( | |
53 static_cast<ContentDecryptor_Dev*>(object)->CancelKeyRequest( | |
54 session_id)); | |
55 } | |
56 | |
57 | |
58 PP_Bool Decrypt(PP_Instance instance, | |
59 PP_Resource encrypted_block, | |
60 PP_CompletionCallback callback) { | |
61 void* object = | |
62 Instance::GetPerInstanceObject(instance, kPPPContentDecryptorInterface); | |
63 if (!object) | |
64 return PP_FALSE; | |
65 return PP_FromBool( | |
66 static_cast<ContentDecryptor_Dev*>(object)->Decrypt( | |
67 encrypted_block, | |
68 callback)); | |
69 } | |
70 | |
71 PP_Bool DecryptAndDecode(PP_Instance instance, | |
72 PP_Resource encrypted_block, | |
73 PP_CompletionCallback callback) { | |
74 void* object = | |
75 Instance::GetPerInstanceObject(instance, kPPPContentDecryptorInterface); | |
76 if (!object) | |
77 return PP_FALSE; | |
78 return PP_FromBool( | |
79 static_cast<ContentDecryptor_Dev*>(object)->DecryptAndDecode( | |
80 encrypted_block, | |
81 callback)); | |
82 } | |
83 | |
84 const PPP_ContentDecryptor_Dev ppp_content_decryptor = { | |
85 &GenerateKeyRequest, | |
86 &AddKey, | |
87 &CancelKeyRequest, | |
88 &Decrypt, | |
89 &DecryptAndDecode | |
90 }; | |
91 | |
92 } // namespace | |
93 | |
94 ContentDecryptor_Dev::ContentDecryptor_Dev(Instance* instance) | |
95 : associated_instance_(instance) { | |
96 Module::Get()->AddPluginInterface(kPPPContentDecryptorInterface, | |
97 &ppp_content_decryptor); | |
98 instance->AddPerInstanceObject(kPPPContentDecryptorInterface, this); | |
99 } | |
100 | |
101 ContentDecryptor_Dev::~ContentDecryptor_Dev() { | |
102 Instance::RemovePerInstanceObject(associated_instance_, | |
103 kPPPContentDecryptorInterface, | |
104 this); | |
105 } | |
106 | |
107 } // namespace pp | |
OLD | NEW |