| 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 #ifndef PPAPI_CPP_DEV_VAR_ARRAY_BUFFER_DEV_H_ | 5 #ifndef PPAPI_CPP_VAR_ARRAY_BUFFER_H_ |
| 6 #define PPAPI_CPP_DEV_VAR_ARRAY_BUFFER_DEV_H_ | 6 #define PPAPI_CPP_VAR_ARRAY_BUFFER_H_ |
| 7 | 7 |
| 8 #include "ppapi/cpp/var.h" | 8 #include "ppapi/cpp/var.h" |
| 9 | 9 |
| 10 /// @file | 10 /// @file |
| 11 /// This file defines the API for interacting with an ArrayBuffer. | 11 /// This file defines the API for interacting with an ArrayBuffer. |
| 12 | 12 |
| 13 namespace pp { | 13 namespace pp { |
| 14 | 14 |
| 15 /// VarArrayBuffer_Dev provides a way to interact with JavaScript ArrayBuffers, | 15 /// VarArrayBuffer provides a way to interact with JavaScript ArrayBuffers, |
| 16 /// which represent a contiguous sequence of bytes. Note that | 16 /// which represent a contiguous sequence of bytes. Note that |
| 17 /// VarArrayBuffer_Devs are not part of the embedding page's DOM, and can only | 17 /// VarArrayBuffers are not part of the embedding page's DOM, and can only |
| 18 /// be shared with JavaScript via pp::Instance's PostMessage and HandleMessage | 18 /// be shared with JavaScript via pp::Instance's PostMessage and HandleMessage |
| 19 /// functions. | 19 /// functions. |
| 20 class VarArrayBuffer_Dev : public Var { | 20 class VarArrayBuffer : public Var { |
| 21 public: | 21 public: |
| 22 /// Contruct a VarArrayBuffer_Dev given a var for which is_array_buffer() is | 22 /// Contruct a VarArrayBuffer given a var for which is_array_buffer() is |
| 23 /// true. This will refer to the same buffer as var, but allows you to access | 23 /// true. This will refer to the same buffer as var, but allows you to access |
| 24 /// methods specific to VarArrayBuffer_Dev. | 24 /// methods specific to VarArrayBuffer. |
| 25 /// | 25 /// |
| 26 /// @param[in] var An array buffer Var. | 26 /// @param[in] var An array buffer Var. |
| 27 explicit VarArrayBuffer_Dev(const Var& var); | 27 explicit VarArrayBuffer(const Var& var); |
| 28 | 28 |
| 29 VarArrayBuffer_Dev(const VarArrayBuffer_Dev& buffer) : Var(buffer) {} | 29 VarArrayBuffer(const VarArrayBuffer& buffer) : Var(buffer) {} |
| 30 | 30 |
| 31 /// Construct a new VarArrayBuffer_Dev which is size_in_bytes bytes long and | 31 /// Construct a new VarArrayBuffer which is size_in_bytes bytes long and |
| 32 /// initialized to zero. | 32 /// initialized to zero. |
| 33 /// | 33 /// |
| 34 /// @param[in] size_in_bytes The size of the constructed array in bytes. | 34 /// @param[in] size_in_bytes The size of the constructed array in bytes. |
| 35 VarArrayBuffer_Dev(uint32_t size_in_bytes); | 35 VarArrayBuffer(uint32_t size_in_bytes); |
| 36 | 36 |
| 37 /// Return the length of the VarArrayBuffer_Dev in bytes. | 37 /// Return the length of the VarArrayBuffer in bytes. |
| 38 /// | 38 /// |
| 39 /// @return The length of the VarArrayBuffer_Dev in bytes. | 39 /// @return The length of the VarArrayBuffer in bytes. |
| 40 uint32_t ByteLength() const; | 40 uint32_t ByteLength() const; |
| 41 | 41 |
| 42 /// Return a pointer to the buffer associated with this VarArrayBuffer_Dev. | 42 /// Return a pointer to the buffer associated with this VarArrayBuffer. |
| 43 /// | 43 /// |
| 44 /// @return A pointer to the buffer associated with this VarArrayBuffer_Dev. | 44 /// @return A pointer to the buffer associated with this VarArrayBuffer. |
| 45 void* Map(); | 45 void* Map(); |
| 46 const void* Map() const; | 46 const void* Map() const; |
| 47 | 47 |
| 48 virtual ~VarArrayBuffer_Dev() {} | 48 virtual ~VarArrayBuffer() {} |
| 49 | 49 |
| 50 private: | 50 private: |
| 51 // We cache the buffer so that repeated calls to Map() are quick. | 51 // We cache the buffer so that repeated calls to Map() are quick. |
| 52 void* buffer_; | 52 void* buffer_; |
| 53 }; | 53 }; |
| 54 | 54 |
| 55 } // namespace pp | 55 } // namespace pp |
| 56 | 56 |
| 57 #endif // PPAPI_CPP_DEV_VAR_ARRAY_BUFFER_DEV_H_ | 57 #endif // PPAPI_CPP_VAR_ARRAY_BUFFER_H_ |
| OLD | NEW |