Add histogram for content verification failures of policy based installs
[chromium-blink-merge.git] / ppapi / thunk / ppb_audio_buffer_thunk.cc
blobcafa5c03cd60027c6cb9d0093670259e298101aa
1 // Copyright 2014 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 // From ppb_audio_buffer.idl modified Mon Apr 7 08:56:43 2014.
7 #include "ppapi/c/pp_errors.h"
8 #include "ppapi/c/ppb_audio_buffer.h"
9 #include "ppapi/shared_impl/tracked_callback.h"
10 #include "ppapi/thunk/enter.h"
11 #include "ppapi/thunk/ppapi_thunk_export.h"
12 #include "ppapi/thunk/ppb_audio_buffer_api.h"
14 namespace ppapi {
15 namespace thunk {
17 namespace {
19 PP_Bool IsAudioBuffer(PP_Resource resource) {
20 VLOG(4) << "PPB_AudioBuffer::IsAudioBuffer()";
21 EnterResource<PPB_AudioBuffer_API> enter(resource, false);
22 return PP_FromBool(enter.succeeded());
25 PP_TimeDelta GetTimestamp(PP_Resource buffer) {
26 VLOG(4) << "PPB_AudioBuffer::GetTimestamp()";
27 EnterResource<PPB_AudioBuffer_API> enter(buffer, true);
28 if (enter.failed())
29 return 0.0;
30 return enter.object()->GetTimestamp();
33 void SetTimestamp(PP_Resource buffer, PP_TimeDelta timestamp) {
34 VLOG(4) << "PPB_AudioBuffer::SetTimestamp()";
35 EnterResource<PPB_AudioBuffer_API> enter(buffer, true);
36 if (enter.failed())
37 return;
38 enter.object()->SetTimestamp(timestamp);
41 PP_AudioBuffer_SampleRate GetSampleRate(PP_Resource buffer) {
42 VLOG(4) << "PPB_AudioBuffer::GetSampleRate()";
43 EnterResource<PPB_AudioBuffer_API> enter(buffer, true);
44 if (enter.failed())
45 return PP_AUDIOBUFFER_SAMPLERATE_UNKNOWN;
46 return enter.object()->GetSampleRate();
49 PP_AudioBuffer_SampleSize GetSampleSize(PP_Resource buffer) {
50 VLOG(4) << "PPB_AudioBuffer::GetSampleSize()";
51 EnterResource<PPB_AudioBuffer_API> enter(buffer, true);
52 if (enter.failed())
53 return PP_AUDIOBUFFER_SAMPLESIZE_UNKNOWN;
54 return enter.object()->GetSampleSize();
57 uint32_t GetNumberOfChannels(PP_Resource buffer) {
58 VLOG(4) << "PPB_AudioBuffer::GetNumberOfChannels()";
59 EnterResource<PPB_AudioBuffer_API> enter(buffer, true);
60 if (enter.failed())
61 return 0;
62 return enter.object()->GetNumberOfChannels();
65 uint32_t GetNumberOfSamples(PP_Resource buffer) {
66 VLOG(4) << "PPB_AudioBuffer::GetNumberOfSamples()";
67 EnterResource<PPB_AudioBuffer_API> enter(buffer, true);
68 if (enter.failed())
69 return 0;
70 return enter.object()->GetNumberOfSamples();
73 void* GetDataBuffer(PP_Resource buffer) {
74 VLOG(4) << "PPB_AudioBuffer::GetDataBuffer()";
75 EnterResource<PPB_AudioBuffer_API> enter(buffer, true);
76 if (enter.failed())
77 return NULL;
78 return enter.object()->GetDataBuffer();
81 uint32_t GetDataBufferSize(PP_Resource buffer) {
82 VLOG(4) << "PPB_AudioBuffer::GetDataBufferSize()";
83 EnterResource<PPB_AudioBuffer_API> enter(buffer, true);
84 if (enter.failed())
85 return 0;
86 return enter.object()->GetDataBufferSize();
89 const PPB_AudioBuffer_0_1 g_ppb_audiobuffer_thunk_0_1 = {&IsAudioBuffer,
90 &GetTimestamp,
91 &SetTimestamp,
92 &GetSampleRate,
93 &GetSampleSize,
94 &GetNumberOfChannels,
95 &GetNumberOfSamples,
96 &GetDataBuffer,
97 &GetDataBufferSize};
99 } // namespace
101 PPAPI_THUNK_EXPORT const PPB_AudioBuffer_0_1* GetPPB_AudioBuffer_0_1_Thunk() {
102 return &g_ppb_audiobuffer_thunk_0_1;
105 } // namespace thunk
106 } // namespace ppapi