Allow script to request durable storage permission (chrome side)
[chromium-blink-merge.git] / ppapi / thunk / ppb_audio_thunk.cc
blob646ae6b4c4444a75b63abba3beb9291562974cc2
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/pp_errors.h"
6 #include "ppapi/c/ppb_audio.h"
7 #include "ppapi/shared_impl/tracked_callback.h"
8 #include "ppapi/thunk/enter.h"
9 #include "ppapi/thunk/ppb_audio_api.h"
10 #include "ppapi/thunk/ppb_instance_api.h"
11 #include "ppapi/thunk/resource_creation_api.h"
12 #include "ppapi/thunk/thunk.h"
14 namespace ppapi {
15 namespace thunk {
17 namespace {
19 PP_Resource Create_1_0(PP_Instance instance,
20 PP_Resource config,
21 PPB_Audio_Callback_1_0 audio_callback,
22 void* user_data) {
23 VLOG(4) << "PPB_Audio::Create()";
24 EnterResourceCreation enter(instance);
25 if (enter.failed())
26 return 0;
27 return enter.functions()->CreateAudio1_0(instance,
28 config,
29 audio_callback,
30 user_data);
33 PP_Resource Create(PP_Instance instance,
34 PP_Resource config,
35 PPB_Audio_Callback audio_callback,
36 void* user_data) {
37 VLOG(4) << "PPB_Audio::Create()";
38 EnterResourceCreation enter(instance);
39 if (enter.failed())
40 return 0;
41 return enter.functions()->CreateAudio(instance,
42 config,
43 audio_callback,
44 user_data);
47 PP_Bool IsAudio(PP_Resource resource) {
48 VLOG(4) << "PPB_Audio::IsAudio()";
49 EnterResource<PPB_Audio_API> enter(resource, false);
50 return PP_FromBool(enter.succeeded());
53 PP_Resource GetCurrentConfig(PP_Resource audio) {
54 VLOG(4) << "PPB_Audio::GetCurrentConfig()";
55 EnterResource<PPB_Audio_API> enter(audio, true);
56 if (enter.failed())
57 return 0;
58 return enter.object()->GetCurrentConfig();
61 PP_Bool StartPlayback(PP_Resource audio) {
62 VLOG(4) << "PPB_Audio::StartPlayback()";
63 EnterResource<PPB_Audio_API> enter(audio, true);
64 if (enter.failed())
65 return PP_FALSE;
66 return enter.object()->StartPlayback();
69 PP_Bool StopPlayback(PP_Resource audio) {
70 VLOG(4) << "PPB_Audio::StopPlayback()";
71 EnterResource<PPB_Audio_API> enter(audio, true);
72 if (enter.failed())
73 return PP_FALSE;
74 return enter.object()->StopPlayback();
77 const PPB_Audio_1_0 g_ppb_audio_thunk_1_0 = {
78 &Create_1_0,
79 &IsAudio,
80 &GetCurrentConfig,
81 &StartPlayback,
82 &StopPlayback
85 const PPB_Audio_1_1 g_ppb_audio_thunk_1_1 = {
86 &Create,
87 &IsAudio,
88 &GetCurrentConfig,
89 &StartPlayback,
90 &StopPlayback
93 } // namespace
95 const PPB_Audio_1_0* GetPPB_Audio_1_0_Thunk() {
96 return &g_ppb_audio_thunk_1_0;
99 const PPB_Audio_1_1* GetPPB_Audio_1_1_Thunk() {
100 return &g_ppb_audio_thunk_1_1;
103 } // namespace thunk
104 } // namespace ppapi