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