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

Side by Side Diff: ppapi/cpp/dev/content_decryption_module_dev.cc

Issue 10545036: Add PPAPI decryptor interfaces. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Implement enough thunk stuff to call into PluginInstance CDM stubs Created 8 years, 5 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
(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_decryption_module_dev.h"
6
7 #include "ppapi/c/dev/ppp_content_decryption_module_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 kPPPContentDecryptionModuleInterface[] =
18 PPP_CONTENTDECRYPTIONMODULE_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,
25 kPPPContentDecryptionModuleInterface);
26 if (!object)
27 return PP_FALSE;
28 return PP_FromBool(
29 static_cast<ContentDecryptionModule_Dev*>(object)->GenerateKeyRequest(
30 key_system,
31 init_data));
32 }
33
34 PP_Bool AddKey(PP_Instance instance,
35 PP_Var session_id,
36 PP_Resource key) {
37 void* object =
38 Instance::GetPerInstanceObject(instance,
39 kPPPContentDecryptionModuleInterface);
40 if (!object)
41 return PP_FALSE;
42 return PP_FromBool(
43 static_cast<ContentDecryptionModule_Dev*>(object)->AddKey(session_id,
44 key));
45 }
46
47 PP_Bool CancelKeyRequest(PP_Instance instance,
48 PP_Var session_id) {
49 void* object =
50 Instance::GetPerInstanceObject(instance,
51 kPPPContentDecryptionModuleInterface);
52 if (!object)
53 return PP_FALSE;
54 return PP_FromBool(
55 static_cast<ContentDecryptionModule_Dev*>(object)->CancelKeyRequest(
56 session_id));
57 }
58
59
60 PP_Bool Decrypt(PP_Instance instance,
61 PP_Resource encrypted_block,
62 PP_CompletionCallback callback) {
63 void* object =
64 Instance::GetPerInstanceObject(instance,
65 kPPPContentDecryptionModuleInterface);
66 if (!object)
67 return PP_FALSE;
68 return PP_FromBool(
69 static_cast<ContentDecryptionModule_Dev*>(object)->Decrypt(
70 encrypted_block,
71 callback));
72 }
73
74 PP_Bool DecryptAndDecode(PP_Instance instance,
75 PP_Resource encrypted_block,
76 PP_CompletionCallback callback) {
77 void* object =
78 Instance::GetPerInstanceObject(instance,
79 kPPPContentDecryptionModuleInterface);
80 if (!object)
81 return PP_FALSE;
82 return PP_FromBool(
83 static_cast<ContentDecryptionModule_Dev*>(object)->DecryptAndDecode(
84 encrypted_block,
85 callback));
86 }
87
88 const PPP_ContentDecryptionModule_Dev ppp_content_decryption_module = {
89 &GenerateKeyRequest,
90 &AddKey,
91 &CancelKeyRequest,
92 &Decrypt,
93 &DecryptAndDecode
94 };
95
96 } // namespace
97
98 ContentDecryptionModule_Dev::ContentDecryptionModule_Dev(Instance* instance)
99 : associated_instance_(instance) {
100 Module::Get()->AddPluginInterface(kPPPContentDecryptionModuleInterface,
101 &ppp_content_decryption_module);
102 instance->AddPerInstanceObject(kPPPContentDecryptionModuleInterface, this);
103 }
104
105 ContentDecryptionModule_Dev::~ContentDecryptionModule_Dev() {
106 Instance::RemovePerInstanceObject(associated_instance_,
107 kPPPContentDecryptionModuleInterface,
108 this);
109 }
110
111 } // namespace pp
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698