Update V8 to version 4.7.47.
[chromium-blink-merge.git] / ppapi / thunk / ppb_buffer_thunk.cc
blob9c6698d27da72995bdfd093aedd910b6aca8e609
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/dev/ppb_buffer_dev.h"
6 #include "ppapi/thunk/thunk.h"
7 #include "ppapi/thunk/enter.h"
8 #include "ppapi/thunk/ppb_buffer_api.h"
9 #include "ppapi/thunk/resource_creation_api.h"
11 namespace ppapi {
12 namespace thunk {
14 namespace {
16 PP_Resource Create(PP_Instance instance, uint32_t size) {
17 EnterResourceCreation enter(instance);
18 if (enter.failed())
19 return 0;
20 return enter.functions()->CreateBuffer(instance, size);
23 PP_Bool IsBuffer(PP_Resource resource) {
24 EnterResource<PPB_Buffer_API> enter(resource, false);
25 return PP_FromBool(enter.succeeded());
28 PP_Bool Describe(PP_Resource resource, uint32_t* size_in_bytes) {
29 EnterResource<PPB_Buffer_API> enter(resource, true);
30 if (enter.failed()) {
31 *size_in_bytes = 0;
32 return PP_FALSE;
34 return enter.object()->Describe(size_in_bytes);
37 void* Map(PP_Resource resource) {
38 EnterResource<PPB_Buffer_API> enter(resource, true);
39 if (enter.failed())
40 return NULL;
41 return enter.object()->Map();
44 void Unmap(PP_Resource resource) {
45 EnterResource<PPB_Buffer_API> enter(resource, true);
46 if (enter.succeeded())
47 enter.object()->Unmap();
50 const PPB_Buffer_Dev g_ppb_buffer_thunk = {
51 &Create,
52 &IsBuffer,
53 &Describe,
54 &Map,
55 &Unmap,
58 } // namespace
60 const PPB_Buffer_Dev_0_4* GetPPB_Buffer_Dev_0_4_Thunk() {
61 return &g_ppb_buffer_thunk;
64 } // namespace thunk
65 } // namespace ppapi