| 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 | 5 |
| 6 /** | 6 /** |
| 7 * This file defines the <code>PPB_VarArrayBuffer</code> struct. | 7 * This file defines the <code>PPB_VarArrayBuffer</code> struct providing |
| 8 * a way to interact with JavaScript ArrayBuffers. |
| 8 */ | 9 */ |
| 9 | 10 |
| 10 label Chrome { | 11 label Chrome { |
| 11 M18 = 1.0 | 12 M18 = 1.0 |
| 12 }; | 13 }; |
| 13 | 14 |
| 14 /** | 15 /** |
| 15 * PPB_VarArrayBuffer API. This provides a way to interact with JavaScript | 16 * The <code>PPB_VarArrayBuffer</code> interface provides a way to interact |
| 16 * ArrayBuffers, which represent a contiguous sequence of bytes. To manage the | 17 * with JavaScript ArrayBuffers, which represent a contiguous sequence of |
| 17 * reference count for a VarArrayBuffer, please see PPB_Var. Note that | 18 * bytes. Use <code>PPB_Var</code> to manage the reference count for a |
| 18 * these Vars are not part of the embedding page's DOM, and can only be shared | 19 * <code>VarArrayBuffer</code>. Note that these Vars are not part of the |
| 19 * with JavaScript via pp::Instance's PostMessage and HandleMessage functions. | 20 * embedding page's DOM, and can only be shared with JavaScript using the |
| 21 * <code>PostMessage</code> and <code>HandleMessage</code> functions of |
| 22 * <code>pp::Instance</code>. |
| 20 */ | 23 */ |
| 21 [macro="PPB_VAR_ARRAY_BUFFER_INTERFACE"] | 24 [macro="PPB_VAR_ARRAY_BUFFER_INTERFACE"] |
| 22 interface PPB_VarArrayBuffer { | 25 interface PPB_VarArrayBuffer { |
| 23 /** | 26 /** |
| 24 * Create a zero-initialized VarArrayBuffer. | 27 * Create() creates a zero-initialized <code>VarArrayBuffer</code>. |
| 25 * | 28 * |
| 26 * @param[in] size_in_bytes The size of the ArrayBuffer that will be created. | 29 * @param[in] size_in_bytes The size of the <code>ArrayBuffer</code> to |
| 30 * be created. |
| 27 * | 31 * |
| 28 * @return A PP_Var which represents a VarArrayBuffer of the requested size | 32 * @return A <code>PP_Var</code> representing a <code>VarArrayBuffer</code> |
| 29 * with a reference count of 1. | 33 * of the requested size and with a reference count of 1. |
| 30 */ | 34 */ |
| 31 PP_Var Create([in] uint32_t size_in_bytes); | 35 PP_Var Create([in] uint32_t size_in_bytes); |
| 32 | 36 |
| 33 /** | 37 /** |
| 34 * Retrieves the length of the VarArrayBuffer in bytes. On success, | 38 * ByteLength() retrieves the length of the <code>VarArrayBuffer</code> in |
| 35 * byte_length is set to the length of the given ArrayBuffer var. On failure, | 39 * bytes. On success, <code>byte_length</code> is set to the length of the |
| 36 * byte_length is unchanged (this could happen, for instance, if the given | 40 * given <code>ArrayBuffer</code> var. On failure, <code>byte_length</code> |
| 37 * PP_Var is not of type PP_VARTYPE_ARRAY_BUFFER). Note that ByteLength() will | 41 * is unchanged (this could happen, for instance, if the given |
| 38 * successfully retrieve the the size of an ArrayBuffer even if the | 42 * <code>PP_Var</code> is not of type <code>PP_VARTYPE_ARRAY_BUFFER</code>). |
| 39 * ArrayBuffer is not currently mapped. | 43 * Note that ByteLength() will successfully retrieve the size of an |
| 44 * <code>ArrayBuffer</code> even if the <code>ArrayBuffer</code> is not |
| 45 * currently mapped. |
| 40 * | 46 * |
| 41 * @param[in] array The ArrayBuffer whose length should be returned. | 47 * @param[in] array The <code>ArrayBuffer</code> whose length should be |
| 48 * returned. |
| 42 * | 49 * |
| 43 * @param[out] byte_length A variable which is set to the length of the given | 50 * @param[out] byte_length A variable which is set to the length of the given |
| 44 * ArrayBuffer on success. | 51 * <code>ArrayBuffer</code> on success. |
| 45 * | 52 * |
| 46 * @return PP_TRUE on success, PP_FALSE on failure. | 53 * @return <code>PP_TRUE</code> on success, <code>PP_FALSE</code> on failure. |
| 47 */ | 54 */ |
| 48 PP_Bool ByteLength([in] PP_Var array, [out] uint32_t byte_length); | 55 PP_Bool ByteLength([in] PP_Var array, [out] uint32_t byte_length); |
| 49 | 56 |
| 50 /** | 57 /** |
| 51 * Maps the ArrayBuffer in to the module's address space and returns a pointer | 58 * Map() maps the <code>ArrayBuffer</code> in to the module's address space |
| 52 * to the beginning of the buffer for the given ArrayBuffer PP_Var. Note that | 59 * and returns a pointer to the beginning of the buffer for the given |
| 53 * calling Map() can be a relatively expensive operation. Use care when | 60 * <code>ArrayBuffer PP_Var</code>. Note that calling Map() can be a |
| 54 * calling it in performance-critical code. For example, you should call it | 61 * relatively expensive operation. Use care when calling it in |
| 55 * only once when looping over an ArrayBuffer: | 62 * performance-critical code. For example, you should call it only once when |
| 63 * looping over an <code>ArrayBuffer</code>. |
| 56 * | 64 * |
| 57 * <code> | 65 * <strong>Example:</strong> |
| 58 * char* data = (char*)(array_buffer_if.Map(array_buffer_var)); | |
| 59 * uint32_t byte_length = 0; | |
| 60 * PP_Bool ok = array_buffer_if.ByteLength(array_buffer_var, &byte_length); | |
| 61 * if (!ok) | |
| 62 * return DoSomethingBecauseMyVarIsNotAnArrayBuffer(); | |
| 63 * for (uint32_t i = 0; i < byte_length; ++i) | |
| 64 * data[i] = 'A'; | |
| 65 * </code> | |
| 66 * | 66 * |
| 67 * @param[in] array The ArrayBuffer whose internal buffer should be returned. | 67 * @code |
| 68 * char* data = (char*)(array_buffer_if.Map(array_buffer_var)); |
| 69 * uint32_t byte_length = 0; |
| 70 * PP_Bool ok = array_buffer_if.ByteLength(array_buffer_var, &byte_length); |
| 71 * if (!ok) |
| 72 * return DoSomethingBecauseMyVarIsNotAnArrayBuffer(); |
| 73 * for (uint32_t i = 0; i < byte_length; ++i) |
| 74 * data[i] = 'A'; |
| 75 * @endcode |
| 68 * | 76 * |
| 69 * @return A pointer to the internal buffer for this ArrayBuffer. Returns NULL | 77 * @param[in] array The <code>ArrayBuffer</code> whose internal buffer should |
| 70 * if the given PP_Var is not of type PP_VARTYPE_ARRAY_BUFFER. | 78 * be returned. |
| 79 * |
| 80 * @return A pointer to the internal buffer for this |
| 81 * <code>ArrayBuffer</code>. Returns <code>NULL</code> |
| 82 * if the given <code>PP_Var</code> is not of type |
| 83 * <code>PP_VARTYPE_ARRAY_BUFFER</code>. |
| 71 */ | 84 */ |
| 72 mem_t Map([in] PP_Var array); | 85 mem_t Map([in] PP_Var array); |
| 73 | 86 |
| 74 /** | 87 /** |
| 75 * Unmaps the given ArrayBuffer var from the module address space. Use this if | 88 * Unmap() unmaps the given <code>ArrayBuffer</code> var from the module |
| 76 * you want to save memory but might want to Map the buffer again later. The | 89 * address space. Use this if you want to save memory but might want to call |
| 77 * PP_Var remains valid and should still be released using PPB_Var when you | 90 * Map() to map the buffer again later. The <code>PP_Var</code> remains valid |
| 78 * are done with the ArrayBuffer. | 91 * and should still be released using <code>PPB_Var</code> when you are done |
| 92 * with the <code>ArrayBuffer</code>. |
| 79 * | 93 * |
| 80 * @param[in] array The ArrayBuffer which should be released. | 94 * @param[in] array The <code>ArrayBuffer</code> to be released. |
| 81 */ | 95 */ |
| 82 void Unmap([in] PP_Var array); | 96 void Unmap([in] PP_Var array); |
| 83 }; | 97 }; |
| 84 | 98 |
| OLD | NEW |