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

Unified Diff: ppapi/cpp/dev/var_array_buffer_dev.h

Issue 8502030: Draft of a PPAPI interface for ArrayBuffer and typed arrays. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Cut back down to just the API for review. Created 9 years 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 side-by-side diff with in-line comments
Download patch
Index: ppapi/cpp/dev/var_array_buffer_dev.h
diff --git a/ppapi/cpp/dev/var_array_buffer_dev.h b/ppapi/cpp/dev/var_array_buffer_dev.h
new file mode 100644
index 0000000000000000000000000000000000000000..c0e981a8d66152bd7e0d7016444596480a9d865c
--- /dev/null
+++ b/ppapi/cpp/dev/var_array_buffer_dev.h
@@ -0,0 +1,60 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef PPAPI_CPP_DEV_VAR_ARRAY_BUFFER_DEV_H_
+#define PPAPI_CPP_DEV_VAR_ARRAY_BUFFER_DEV_H_
+
+#include "ppapi/cpp/var.h"
+
+/// @file
+/// This file defines the API for interacting with an ArrayBuffer.
+
+namespace pp {
+
+class Instance;
+
+/// VarArrayBuffer_Dev provides a way to interact with JavaScript ArrayBuffers,
+/// which represent a contiguous sequence of bytes. Note that
+/// VarArrayBuffer_Devs are not part of the embedding page's DOM, and can only
+/// be shared with JavaScript via pp::Instance's PostMessage and HandleMessage
+/// functions.
+class VarArrayBuffer_Dev : public Var {
+ public:
+ /// Contruct a VarArrayBuffer_Dev given a var for which is_array_buffer() is
+ /// true. This will refer to the same buffer as var, but allows you to access
+ /// methods specific to VarArrayBuffer_Dev.
+ ///
+ /// @param[in] var An array buffer Var.
+ explicit VarArrayBuffer_Dev(const Var& var);
dmichael (off chromium) 2011/12/02 18:53:52 This is basically down-casting the 'var handle'. T
+
+ VarArrayBuffer_Dev(const VarArrayBuffer_Dev& buffer) : Var(buffer) {}
+
+ /// Construct a new VarArrayBuffer_Dev which is size_in_bytes bytes long and
+ /// initialized to zero.
+ ///
+ /// @param[in] instance The Instance which is creating the VarArrayBuffer_Dev.
+ /// @param[in] size_in_bytes The size of the constructed array in bytes.
+ VarArrayBuffer_Dev(const Instance& instance, uint32_t size_in_bytes);
+
+ /// Return the length of the VarArrayBuffer_Dev in bytes.
+ ///
+ /// @return The length of the VarArrayBuffer_Dev in bytes.
+ uint32_t ByteLength() const;
+
+ /// Return a pointer to the buffer associated with this VarArrayBuffer_Dev.
+ ///
+ /// @return A pointer to the buffer associated with this VarArrayBuffer_Dev.
+ void* Map();
+ const void* Map() const;
+
+ virtual ~VarArrayBuffer_Dev() {}
+
+ private:
+ // We cache the buffer so that repeated calls to Map() are quick.
+ void* buffer_;
+};
+
+} // namespace pp
+
+#endif // PPAPI_CPP_DEV_VAR_ARRAY_BUFFER_DEV_H_

Powered by Google App Engine
This is Rietveld 408576698