OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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" | 9 #include "ppapi/c/dev/ppb_var_array_buffer_dev.h" |
10 #include "ppapi/c/ppb_var.h" | 10 #include "ppapi/c/ppb_var.h" |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 }; | 68 }; |
69 | 69 |
70 | 70 |
71 // PPB_VarArrayBuffer_Dev methods ---------------------------------------------- | 71 // PPB_VarArrayBuffer_Dev 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 uint32_t ByteLength(struct PP_Var array) { | 78 uint32_t ByteLength(PP_Var array) { |
79 ArrayBufferVar* buffer = ArrayBufferVar::FromPPVar(array); | 79 ArrayBufferVar* buffer = ArrayBufferVar::FromPPVar(array); |
80 if (!buffer) | 80 if (!buffer) |
81 return 0; | 81 return 0; |
82 return buffer->ByteLength(); | 82 return buffer->ByteLength(); |
83 } | 83 } |
84 | 84 |
85 void* Map(struct PP_Var array) { | 85 void* Map(PP_Var array) { |
86 ArrayBufferVar* buffer = ArrayBufferVar::FromPPVar(array); | 86 ArrayBufferVar* buffer = ArrayBufferVar::FromPPVar(array); |
87 if (!buffer) | 87 if (!buffer) |
88 return NULL; | 88 return NULL; |
89 return buffer->Map(); | 89 return buffer->Map(); |
90 } | 90 } |
91 | 91 |
92 const PPB_VarArrayBuffer_Dev var_arraybuffer_interface = { | 92 const PPB_VarArrayBuffer_Dev var_arraybuffer_interface = { |
93 &CreateArrayBufferVar, | 93 &CreateArrayBufferVar, |
94 &ByteLength, | 94 &ByteLength, |
95 &Map | 95 &Map |
96 }; | 96 }; |
97 | 97 |
98 } // namespace | 98 } // namespace |
99 | 99 |
100 // static | 100 // static |
101 const PPB_Var* PPB_Var_Shared::GetVarInterface() { | 101 const PPB_Var_1_1* PPB_Var_Shared::GetVarInterface1_1() { |
102 return &var_interface; | 102 return &var_interface; |
103 } | 103 } |
104 | 104 |
105 // static | 105 // static |
106 const PPB_Var_1_0* PPB_Var_Shared::GetVarInterface1_0() { | 106 const PPB_Var_1_0* PPB_Var_Shared::GetVarInterface1_0() { |
107 return &var_interface1_0; | 107 return &var_interface1_0; |
108 } | 108 } |
109 | 109 |
110 // static | 110 // static |
111 const PPB_VarArrayBuffer_Dev* PPB_Var_Shared::GetVarArrayBufferInterface() { | 111 const PPB_VarArrayBuffer_Dev* PPB_Var_Shared::GetVarArrayBufferInterface() { |
112 return &var_arraybuffer_interface; | 112 return &var_arraybuffer_interface; |
113 } | 113 } |
114 | 114 |
115 } // namespace ppapi | 115 } // namespace ppapi |
116 | |
OLD | NEW |