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

Unified Diff: ppapi/shared_impl/var.h

Issue 8930010: Implement in-process PPB_VarArrayBuffer_Dev. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Some pre-review cleanup. 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/shared_impl/var.h
diff --git a/ppapi/shared_impl/var.h b/ppapi/shared_impl/var.h
index 988898a0b4c17476a5256479ac2da9da6c22b8e2..71410c7a740207f1e3f91b2adf658bfbe6fd1ce5 100644
--- a/ppapi/shared_impl/var.h
+++ b/ppapi/shared_impl/var.h
@@ -14,6 +14,7 @@
namespace ppapi {
+class ArrayBufferVar;
class NPObjectVar;
class ProxyObjectVar;
class StringVar;
@@ -29,12 +30,13 @@ class PPAPI_SHARED_EXPORT Var : public base::RefCounted<Var> {
static std::string PPVarToLogString(PP_Var var);
virtual StringVar* AsStringVar();
+ virtual ArrayBufferVar* AsArrayBufferVar();
virtual NPObjectVar* AsNPObjectVar();
virtual ProxyObjectVar* AsProxyObjectVar();
// Creates a PP_Var corresponding to this object. The return value will have
// one reference addrefed on behalf of the caller.
- virtual PP_Var GetPPVar() = 0;
+ PP_Var GetPPVar();
// Returns the type of this var.
virtual PP_VarType GetType() const = 0;
@@ -91,7 +93,6 @@ class PPAPI_SHARED_EXPORT StringVar : public Var {
// Var override.
virtual StringVar* AsStringVar() OVERRIDE;
- virtual PP_Var GetPPVar() OVERRIDE;
virtual PP_VarType GetType() const OVERRIDE;
// Helper function to create a PP_Var of type string that contains a copy of
@@ -113,6 +114,40 @@ class PPAPI_SHARED_EXPORT StringVar : public Var {
DISALLOW_COPY_AND_ASSIGN(StringVar);
};
+// ArrayBufferVar --------------------------------------------------------------
+
+// Represents an array buffer Var.
+//
+// Note this is an abstract class. To create an appropriate concrete one, you
+// need to use the VarTracker:
+// VarArrayBuffer* buf =
+// PpapiGlobals::Get()->GetVarTracker()->CreateArrayBuffer(size);
+//
+// Converting a PP_Var to an ArrayBufferVar:
+// ArrayBufferVar* array = ArrayBufferVar::FromPPVar(var);
+// if (!array)
+// return false; // Not an ArrayBuffer or an invalid var.
+// DoSomethingWithTheBuffer(array);
+class PPAPI_SHARED_EXPORT ArrayBufferVar : public Var {
+ public:
+ ArrayBufferVar();
+ virtual ~ArrayBufferVar();
+
+ virtual void* Map() = 0;
+ virtual uint32 ByteLength() = 0;
+
+ // Var override.
+ virtual ArrayBufferVar* AsArrayBufferVar() OVERRIDE;
+ virtual PP_VarType GetType() const OVERRIDE;
+
+ // Helper function that converts a PP_Var to an ArrayBufferVar. This will
+ // return NULL if the PP_Var is not of ArrayBuffer type.
+ static ArrayBufferVar* FromPPVar(PP_Var var);
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(ArrayBufferVar);
+};
+
} // namespace ppapi
#endif // PPAPI_SHARED_IMPL_VAR_H_

Powered by Google App Engine
This is Rietveld 408576698