| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ppapi/shared_impl/ppb_var_shared.h" | 5 #include "ppapi/shared_impl/ppb_var_shared.h" |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 | 8 |
| 9 #include "ppapi/c/dev/ppb_var_array_buffer_dev.h" | |
| 10 #include "ppapi/c/ppb_var.h" | 9 #include "ppapi/c/ppb_var.h" |
| 10 #include "ppapi/c/ppb_var_array_buffer.h" |
| 11 #include "ppapi/c/pp_var.h" | 11 #include "ppapi/c/pp_var.h" |
| 12 #include "ppapi/shared_impl/ppapi_globals.h" | 12 #include "ppapi/shared_impl/ppapi_globals.h" |
| 13 #include "ppapi/shared_impl/proxy_lock.h" | 13 #include "ppapi/shared_impl/proxy_lock.h" |
| 14 #include "ppapi/shared_impl/var.h" | 14 #include "ppapi/shared_impl/var.h" |
| 15 #include "ppapi/shared_impl/var_tracker.h" | 15 #include "ppapi/shared_impl/var_tracker.h" |
| 16 | 16 |
| 17 using ppapi::PpapiGlobals; | 17 using ppapi::PpapiGlobals; |
| 18 using ppapi::StringVar; | 18 using ppapi::StringVar; |
| 19 | 19 |
| 20 namespace ppapi { | 20 namespace ppapi { |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 }; | 61 }; |
| 62 | 62 |
| 63 const PPB_Var_1_0 var_interface1_0 = { | 63 const PPB_Var_1_0 var_interface1_0 = { |
| 64 &AddRefVar, | 64 &AddRefVar, |
| 65 &ReleaseVar, | 65 &ReleaseVar, |
| 66 &VarFromUtf8_1_0, | 66 &VarFromUtf8_1_0, |
| 67 &VarToUtf8 | 67 &VarToUtf8 |
| 68 }; | 68 }; |
| 69 | 69 |
| 70 | 70 |
| 71 // PPB_VarArrayBuffer_Dev methods ---------------------------------------------- | 71 // PPB_VarArrayBuffer methods -------------------------------------------------- |
| 72 | 72 |
| 73 PP_Var CreateArrayBufferVar(uint32_t size_in_bytes) { | 73 PP_Var CreateArrayBufferVar(uint32_t size_in_bytes) { |
| 74 return PpapiGlobals::Get()->GetVarTracker()->MakeArrayBufferPPVar( | 74 return PpapiGlobals::Get()->GetVarTracker()->MakeArrayBufferPPVar( |
| 75 size_in_bytes); | 75 size_in_bytes); |
| 76 } | 76 } |
| 77 | 77 |
| 78 PP_Bool ByteLength(PP_Var array, uint32_t* byte_length) { | 78 PP_Bool ByteLength(PP_Var array, uint32_t* byte_length) { |
| 79 ArrayBufferVar* buffer = ArrayBufferVar::FromPPVar(array); | 79 ArrayBufferVar* buffer = ArrayBufferVar::FromPPVar(array); |
| 80 if (!buffer) | 80 if (!buffer) |
| 81 return PP_FALSE; | 81 return PP_FALSE; |
| 82 *byte_length = buffer->ByteLength(); | 82 *byte_length = buffer->ByteLength(); |
| 83 return PP_TRUE; | 83 return PP_TRUE; |
| 84 } | 84 } |
| 85 | 85 |
| 86 void* Map(PP_Var array) { | 86 void* Map(PP_Var array) { |
| 87 ArrayBufferVar* buffer = ArrayBufferVar::FromPPVar(array); | 87 ArrayBufferVar* buffer = ArrayBufferVar::FromPPVar(array); |
| 88 if (!buffer) | 88 if (!buffer) |
| 89 return NULL; | 89 return NULL; |
| 90 return buffer->Map(); | 90 return buffer->Map(); |
| 91 } | 91 } |
| 92 | 92 |
| 93 void Unmap(PP_Var array) { | 93 void Unmap(PP_Var array) { |
| 94 ArrayBufferVar* buffer = ArrayBufferVar::FromPPVar(array); | 94 ArrayBufferVar* buffer = ArrayBufferVar::FromPPVar(array); |
| 95 if (buffer) | 95 if (buffer) |
| 96 buffer->Unmap(); | 96 buffer->Unmap(); |
| 97 } | 97 } |
| 98 | 98 |
| 99 const PPB_VarArrayBuffer_Dev var_arraybuffer_interface = { | 99 const PPB_VarArrayBuffer_1_0 var_arraybuffer_interface = { |
| 100 &CreateArrayBufferVar, | 100 &CreateArrayBufferVar, |
| 101 &ByteLength, | 101 &ByteLength, |
| 102 &Map, | 102 &Map, |
| 103 &Unmap | 103 &Unmap |
| 104 }; | 104 }; |
| 105 | 105 |
| 106 } // namespace | 106 } // namespace |
| 107 | 107 |
| 108 // static | 108 // static |
| 109 const PPB_Var_1_1* PPB_Var_Shared::GetVarInterface1_1() { | 109 const PPB_Var_1_1* PPB_Var_Shared::GetVarInterface1_1() { |
| 110 return &var_interface; | 110 return &var_interface; |
| 111 } | 111 } |
| 112 | 112 |
| 113 // static | 113 // static |
| 114 const PPB_Var_1_0* PPB_Var_Shared::GetVarInterface1_0() { | 114 const PPB_Var_1_0* PPB_Var_Shared::GetVarInterface1_0() { |
| 115 return &var_interface1_0; | 115 return &var_interface1_0; |
| 116 } | 116 } |
| 117 | 117 |
| 118 // static | 118 // static |
| 119 const PPB_VarArrayBuffer_Dev* PPB_Var_Shared::GetVarArrayBufferInterface() { | 119 const PPB_VarArrayBuffer_1_0* PPB_Var_Shared::GetVarArrayBufferInterface1_0() { |
| 120 return &var_arraybuffer_interface; | 120 return &var_arraybuffer_interface; |
| 121 } | 121 } |
| 122 | 122 |
| 123 } // namespace ppapi | 123 } // namespace ppapi |
| OLD | NEW |