Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1177)

Side by Side Diff: ppapi/c/dev/ppb_var_array_buffer_dev.h

Issue 9169052: Tweaks to PPB_VarArrayBuffer in preperation for taking out of Dev. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: update the documentation Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 /* From dev/ppb_var_array_buffer_dev.idl modified Wed Dec 14 18:08:00 2011. */ 6 /* From dev/ppb_var_array_buffer_dev.idl modified Wed Jan 25 14:51:15 2012. */
7 7
8 #ifndef PPAPI_C_DEV_PPB_VAR_ARRAY_BUFFER_DEV_H_ 8 #ifndef PPAPI_C_DEV_PPB_VAR_ARRAY_BUFFER_DEV_H_
9 #define PPAPI_C_DEV_PPB_VAR_ARRAY_BUFFER_DEV_H_ 9 #define PPAPI_C_DEV_PPB_VAR_ARRAY_BUFFER_DEV_H_
10 10
11 #include "ppapi/c/pp_bool.h" 11 #include "ppapi/c/pp_bool.h"
12 #include "ppapi/c/pp_macros.h" 12 #include "ppapi/c/pp_macros.h"
13 #include "ppapi/c/pp_stdint.h" 13 #include "ppapi/c/pp_stdint.h"
14 #include "ppapi/c/pp_var.h" 14 #include "ppapi/c/pp_var.h"
15 15
16 #define PPB_VAR_ARRAY_BUFFER_DEV_INTERFACE_0_1 "PPB_VarArrayBuffer(Dev);0.1" 16 #define PPB_VAR_ARRAY_BUFFER_DEV_INTERFACE_0_2 "PPB_VarArrayBuffer(Dev);0.2"
17 #define PPB_VAR_ARRAY_BUFFER_DEV_INTERFACE \ 17 #define PPB_VAR_ARRAY_BUFFER_DEV_INTERFACE \
18 PPB_VAR_ARRAY_BUFFER_DEV_INTERFACE_0_1 18 PPB_VAR_ARRAY_BUFFER_DEV_INTERFACE_0_2
19 19
20 /** 20 /**
21 * @file 21 * @file
22 * This file defines the <code>PPB_VarArrayBuffer_Dev</code> struct. 22 * This file defines the <code>PPB_VarArrayBuffer_Dev</code> struct.
23 */ 23 */
24 24
25 25
26 /** 26 /**
27 * @addtogroup Interfaces 27 * @addtogroup Interfaces
28 * @{ 28 * @{
29 */ 29 */
30 /** 30 /**
31 * PPB_VarArrayBuffer_Dev API. This provides a way to interact with JavaScript 31 * PPB_VarArrayBuffer_Dev API. This provides a way to interact with JavaScript
32 * ArrayBuffers, which represent a contiguous sequence of bytes. To manage the 32 * ArrayBuffers, which represent a contiguous sequence of bytes. To manage the
33 * reference count for a VarArrayBuffer, please see PPB_Var. Note that 33 * reference count for a VarArrayBuffer, please see PPB_Var. Note that
34 * these Vars are not part of the embedding page's DOM, and can only be shared 34 * these Vars are not part of the embedding page's DOM, and can only be shared
35 * with JavaScript via pp::Instance's PostMessage and HandleMessage functions. 35 * with JavaScript via pp::Instance's PostMessage and HandleMessage functions.
36 */ 36 */
37 struct PPB_VarArrayBuffer_Dev_0_1 { 37 struct PPB_VarArrayBuffer_Dev_0_2 {
38 /** 38 /**
39 * Create a zero-initialized VarArrayBuffer. 39 * Create a zero-initialized VarArrayBuffer.
40 * 40 *
41 * @param[in] size_in_bytes The size of the array buffer that will be created. 41 * @param[in] size_in_bytes The size of the array buffer that will be created.
42 * 42 *
43 * @return A PP_Var which represents an VarArrayBuffer of the requested size 43 * @return A PP_Var which represents an VarArrayBuffer of the requested size
44 * with a reference count of 1. 44 * with a reference count of 1.
45 */ 45 */
46 struct PP_Var (*Create)(uint32_t size_in_bytes); 46 struct PP_Var (*Create)(uint32_t size_in_bytes);
47 /** 47 /**
48 * Returns the length of the VarArrayBuffer in bytes. 48 * Retrieves the length of the VarArrayBuffer in bytes.
49 * 49 *
50 * @return The length of the VarArrayBuffer in bytes. 50 * @param[in] array The array whose length should be returned.
51 *
52 * @param[out] byte_length The length of the given array.
53 *
54 * @return PP_TRUE on success, PP_FALSE on failure.
51 */ 55 */
52 uint32_t (*ByteLength)(struct PP_Var array); 56 PP_Bool (*ByteLength)(struct PP_Var array, uint32_t* byte_length);
53 /** 57 /**
54 * Returns a pointer to the beginning of the buffer for the given array. 58 * Maps the ArrayBuffer in to the module's address space and returns a pointer
59 * to the beginning of the buffer for the given ArrayBuffer PP_Var. Note that
60 * calling Map() can be a relatively expensive operation. Use care when
61 * calling it in performance-critical code. For example, you should call it
62 * only once when looping over an ArrayBuffer:
63 *
64 * <code>
65 * char* data = (char*)(array_buffer_if.Map(array_buffer_var));
66 * uint32_t byte_length = 0;
67 * PP_Bool ok = array_buffer_if.ByteLength(array_buffer_var, &byte_length);
68 * if (!ok)
69 * return DoSomethingBecauseMyVarIsNotAnArrayBuffer();
70 * for (uint32_t i = 0; i < byte_length; ++i)
71 * data[i] = 'A';
72 * </code>
55 * 73 *
56 * @param[in] array The array whose buffer should be returned. 74 * @param[in] array The array whose buffer should be returned.
57 * 75 *
58 * @return A pointer to the buffer for this array. 76 * @return A pointer to the buffer for this array. Returns NULL if the given
77 * PP_Var is not of type PP_VARTYPE_ARRAY_BUFFER.
59 */ 78 */
60 void* (*Map)(struct PP_Var array); 79 void* (*Map)(struct PP_Var array);
80 /**
81 * Unmaps the given ArrayBuffer var from the module address space. Use this if
82 * you want to save memory but might want to Map the buffer again later. The
83 * PP_Var remains valid and should still be released using PPB_Var when you
84 * are done with the ArrayBuffer.
85 *
86 * @param[in] array The ArrayBuffer which should be released.
87 */
88 void (*Unmap)(struct PP_Var array);
61 }; 89 };
62 90
63 typedef struct PPB_VarArrayBuffer_Dev_0_1 PPB_VarArrayBuffer_Dev; 91 typedef struct PPB_VarArrayBuffer_Dev_0_2 PPB_VarArrayBuffer_Dev;
64 /** 92 /**
65 * @} 93 * @}
66 */ 94 */
67 95
68 #endif /* PPAPI_C_DEV_PPB_VAR_ARRAY_BUFFER_DEV_H_ */ 96 #endif /* PPAPI_C_DEV_PPB_VAR_ARRAY_BUFFER_DEV_H_ */
69 97
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698