| 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 * PP_ArrayOutput_GetDataBuffer is a callback function to allocate plugin | 7 * PP_ArrayOutput_GetDataBuffer is a callback function to allocate plugin |
| 8 * memory for an array. It returns the allocated memory or null on failure. | 8 * memory for an array. It returns the allocated memory or null on failure. |
| 9 * | 9 * |
| 10 * This function will be called reentrantly. This means that if you call a | 10 * This function will be called reentrantly. This means that if you call a |
| 11 * function PPB_Foo.GetData(&array_output), GetData will call your | 11 * function PPB_Foo.GetData(&array_output), GetData will call your |
| 12 * GetDataBuffer function before it returns. | 12 * GetDataBuffer function before it returns. |
| 13 * | 13 * |
| 14 * This function will be called even when returning 0-length arrays, so be sure | 14 * This function will be called even when returning 0-length arrays, so be sure |
| 15 * your implementation can support that. You can return NULL for 0 length | 15 * your implementation can support that. You can return NULL for 0 length |
| 16 * arrays and it will not be treated as a failure. | 16 * arrays and it will not be treated as a failure. |
| 17 | 17 |
| 18 * You should not perform any processing in this callback, including calling | 18 * You should not perform any processing in this callback, including calling |
| 19 * other PPAPI functions, outside of allocating memory. You should not throw | 19 * other PPAPI functions, outside of allocating memory. You should not throw |
| 20 * any exceptions. In C++, this means using "new (nothrow)" or being sure to | 20 * any exceptions. In C++, this means using "new (nothrow)" or being sure to |
| 21 * catch any exceptions before returning. | 21 * catch any exceptions before returning. |
| 22 * | 22 * |
| 23 * The C++ wrapper provides a convenient templatized implementation around | 23 * The C++ wrapper provides a convenient templatized implementation around |
| 24 * std::vector which you should generally use instead of coding this | 24 * std::vector which you should generally use instead of coding this |
| 25 * specifically. | 25 * specifically. |
| 26 * | 26 * |
| 27 * @param user_data The pointer provided in the PP_ArrayOutput structure. This | 27 * @param user_data The pointer provided in the PP_ArrayOutput structure. This |
| 28 * has no meaning to the browser, it is intended to be used by the | 28 * has no meaning to the browser, it is intended to be used by the |
| 29 * implementation to figure out where to put the data. | 29 * implementation to figure out where to put the data. |
| 30 * | 30 * |
| 31 * @param element_count The number of elements in the array. This will be 0 | 31 * @param element_count The number of elements in the array. This will be 0 |
| 32 * if there is no data to return. | 32 * if there is no data to return. |
| 33 * | 33 * |
| 34 * @param element_size The size of each element in bytes. | 34 * @param element_size The size of each element in bytes. |
| 35 * | 35 * |
| 36 * @return Returns a pointer to the allocated memory. On failure, returns null. | 36 * @return Returns a pointer to the allocated memory. On failure, returns null. |
| 37 * You can also return null if the element_count is 0. | 37 * You can also return null if the element_count is 0. When a non-null value is |
| 38 * returned, the buffer must remain valid until after the callback runs. If used |
| 39 * with a blocking callback, the buffer must remain valid until after the |
| 40 * function returns. The plugin can then free any memory that it allocated. |
| 38 */ | 41 */ |
| 39 typedef mem_t PP_ArrayOutput_GetDataBuffer([inout] mem_t user_data, | 42 typedef mem_t PP_ArrayOutput_GetDataBuffer([inout] mem_t user_data, |
| 40 [in] uint32_t element_count, | 43 [in] uint32_t element_count, |
| 41 [in] uint32_t element_size); | 44 [in] uint32_t element_size); |
| 42 | 45 |
| 43 /** | 46 /** |
| 44 * A structure that defines a way for the browser to return arrays of data | 47 * A structure that defines a way for the browser to return arrays of data |
| 45 * to the plugin. The browser can not allocate memory on behalf of the plugin | 48 * to the plugin. The browser can not allocate memory on behalf of the plugin |
| 46 * because the plugin and browser may have different allocators. | 49 * because the plugin and browser may have different allocators. |
| 47 * | 50 * |
| (...skipping 23 matching lines...) Expand all Loading... |
| 71 * void MyFunction() { | 74 * void MyFunction() { |
| 72 * MyArrayOutput array = { NULL, 0 }; | 75 * MyArrayOutput array = { NULL, 0 }; |
| 73 * PP_ArrayOutput output = { &MyGetDataBuffer, &array }; | 76 * PP_ArrayOutput output = { &MyGetDataBuffer, &array }; |
| 74 * ppb_foo->GetData(&output); | 77 * ppb_foo->GetData(&output); |
| 75 * } | 78 * } |
| 76 * @endcode | 79 * @endcode |
| 77 */ | 80 */ |
| 78 [passByValue] | 81 [passByValue] |
| 79 struct PP_ArrayOutput { | 82 struct PP_ArrayOutput { |
| 80 /** | 83 /** |
| 81 * A pointer to the allocation function that the browser implements. | 84 * A pointer to the allocation function that the browser will call. |
| 82 */ | 85 */ |
| 83 PP_ArrayOutput_GetDataBuffer GetDataBuffer; | 86 PP_ArrayOutput_GetDataBuffer GetDataBuffer; |
| 84 | 87 |
| 85 /** | 88 /** |
| 86 * Data that is passed to the allocation function. Typically, this is used | 89 * Data that is passed to the allocation function. Typically, this is used |
| 87 * to communicate how the data should be stored. | 90 * to communicate how the data should be stored. |
| 88 */ | 91 */ |
| 89 mem_t user_data; | 92 mem_t user_data; |
| 90 }; | 93 }; |
| OLD | NEW |