Extract SIGPIPE ignoring code to a common place.
[chromium-blink-merge.git] / ppapi / thunk / ppb_content_decryptor_private_thunk.cc
blob905d48230dec40866f86ac14aea964a7c92fb291
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.
5 #include "ppapi/c/private/ppb_content_decryptor_private.h"
6 #include "ppapi/thunk/enter.h"
7 #include "ppapi/thunk/ppb_instance_api.h"
8 #include "ppapi/thunk/thunk.h"
10 namespace ppapi {
11 namespace thunk {
13 namespace {
15 void NeedKey(PP_Instance instance,
16 PP_Var key_system,
17 PP_Var session_id,
18 PP_Var init_data) {
19 EnterInstance enter(instance);
20 if (enter.succeeded())
21 enter.functions()->NeedKey(instance, key_system, session_id, init_data);
24 void KeyAdded(PP_Instance instance,
25 PP_Var key_system,
26 PP_Var session_id) {
27 EnterInstance enter(instance);
28 if (enter.succeeded())
29 enter.functions()->KeyAdded(instance, key_system, session_id);
32 void KeyMessage(PP_Instance instance,
33 PP_Var key_system,
34 PP_Var session_id,
35 PP_Resource message,
36 PP_Var default_url) {
37 EnterInstance enter(instance);
38 if (enter.succeeded()) {
39 enter.functions()->KeyMessage(instance, key_system, session_id, message,
40 default_url);
44 void KeyError(PP_Instance instance,
45 PP_Var key_system,
46 PP_Var session_id,
47 int32_t media_error,
48 int32_t system_code) {
49 EnterInstance enter(instance);
50 if (enter.succeeded()) {
51 enter.functions()->KeyError(instance, key_system, session_id, media_error,
52 system_code);
56 void DeliverBlock(PP_Instance instance,
57 PP_Resource decrypted_block,
58 const PP_DecryptedBlockInfo* block_info) {
59 EnterInstance enter(instance);
60 if (enter.succeeded())
61 enter.functions()->DeliverBlock(instance, decrypted_block, block_info);
64 void DecoderInitializeDone(PP_Instance instance,
65 PP_DecryptorStreamType decoder_type,
66 uint32_t request_id,
67 PP_Bool success) {
68 EnterInstance enter(instance);
69 if (enter.succeeded()) {
70 enter.functions()->DecoderInitializeDone(instance,
71 decoder_type,
72 request_id,
73 success);
77 void DecoderDeinitializeDone(PP_Instance instance,
78 PP_DecryptorStreamType decoder_type,
79 uint32_t request_id) {
80 EnterInstance enter(instance);
81 if (enter.succeeded()) {
82 enter.functions()->DecoderDeinitializeDone(instance,
83 decoder_type,
84 request_id);
88 void DecoderResetDone(PP_Instance instance,
89 PP_DecryptorStreamType decoder_type,
90 uint32_t request_id) {
91 EnterInstance enter(instance);
92 if (enter.succeeded())
93 enter.functions()->DecoderResetDone(instance, decoder_type, request_id);
96 void DeliverFrame(PP_Instance instance,
97 PP_Resource decrypted_frame,
98 const PP_DecryptedFrameInfo* frame_info) {
99 EnterInstance enter(instance);
100 if (enter.succeeded())
101 enter.functions()->DeliverFrame(instance, decrypted_frame, frame_info);
104 void DeliverSamples(PP_Instance instance,
105 PP_Resource audio_frames,
106 const PP_DecryptedBlockInfo* block_info) {
107 EnterInstance enter(instance);
108 if (enter.succeeded())
109 enter.functions()->DeliverSamples(instance, audio_frames, block_info);
112 const PPB_ContentDecryptor_Private g_ppb_decryption_thunk = {
113 &NeedKey,
114 &KeyAdded,
115 &KeyMessage,
116 &KeyError,
117 &DeliverBlock,
118 &DecoderInitializeDone,
119 &DecoderDeinitializeDone,
120 &DecoderResetDone,
121 &DeliverFrame,
122 &DeliverSamples
125 } // namespace
127 const PPB_ContentDecryptor_Private*
128 GetPPB_ContentDecryptor_Private_0_6_Thunk() {
129 return &g_ppb_decryption_thunk;
132 } // namespace thunk
133 } // namespace ppapi