summaryrefslogtreecommitdiffstats
path: root/ppapi/proxy/serialized_var.h
diff options
context:
space:
mode:
Diffstat (limited to 'ppapi/proxy/serialized_var.h')
-rw-r--r--ppapi/proxy/serialized_var.h47
1 files changed, 47 insertions, 0 deletions
diff --git a/ppapi/proxy/serialized_var.h b/ppapi/proxy/serialized_var.h
index 3b74a3e..f283590 100644
--- a/ppapi/proxy/serialized_var.h
+++ b/ppapi/proxy/serialized_var.h
@@ -11,8 +11,12 @@
#include "base/basictypes.h"
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
+#include "base/shared_memory.h"
+#include "ppapi/c/pp_instance.h"
#include "ppapi/c/pp_var.h"
#include "ppapi/proxy/ppapi_proxy_export.h"
+#include "ppapi/proxy/serialized_handle.h"
+#include "ppapi/proxy/serialized_structs.h"
#include "ppapi/proxy/var_serialization_rules.h"
class PickleIterator;
@@ -79,11 +83,20 @@ class PPAPI_PROXY_EXPORT SerializedVar {
return inner_->ReadFromMessage(m, iter);
}
+ // Used by chrome/nacl/nacl_ipc_adapter.cc
+ SerializedHandle* GetPluginShmemHandle() const {
+ return inner_->GetPluginShmemHandle();
+ }
+ void WriteRawVarHeader(IPC::Message* m) const {
+ inner_->WriteRawVarHeader(m);
+ }
+
protected:
friend class SerializedVarReceiveInput;
friend class SerializedVarReturnValue;
friend class SerializedVarOutParam;
friend class SerializedVarSendInput;
+ friend class SerializedVarSendInputShmem;
friend class SerializedVarTestConstructor;
friend class SerializedVarVectorReceiveInput;
@@ -103,6 +116,7 @@ class PPAPI_PROXY_EXPORT SerializedVar {
// See outer class's declarations above.
PP_Var GetVar();
void SetVar(PP_Var var);
+ void SetInstance(PP_Instance instance);
// For the SerializedVarTestConstructor, this writes the Var value as if
// it was just received off the wire, without any serialization rules.
@@ -115,6 +129,12 @@ class PPAPI_PROXY_EXPORT SerializedVar {
void SetCleanupModeToEndSendPassRef();
void SetCleanupModeToEndReceiveCallerOwned();
+ // Returns a handle in the underlying data, if it exists.
+ SerializedHandle* GetPluginShmemHandle() const;
+
+ // Writes raw var data, excluding handles.
+ void WriteRawVarHeader(IPC::Message* m) const;
+
private:
enum CleanupMode {
// The serialized var won't do anything special in the destructor
@@ -128,6 +148,13 @@ class PPAPI_PROXY_EXPORT SerializedVar {
END_RECEIVE_CALLER_OWNED
};
+ // Enum for array buffer message types.
+ enum ShmemType {
+ ARRAY_BUFFER_NO_SHMEM,
+ ARRAY_BUFFER_SHMEM_HOST,
+ ARRAY_BUFFER_SHMEM_PLUGIN,
+ };
+
// ReadFromMessage() may be called on the I/O thread, e.g., when reading the
// reply to a sync message. We cannot use the var tracker on the I/O thread,
// which means we cannot create PP_Var for PP_VARTYPE_STRING and
@@ -136,7 +163,11 @@ class PPAPI_PROXY_EXPORT SerializedVar {
// the main thread.
struct RawVarData {
PP_VarType type;
+ ShmemType shmem_type;
std::string data;
+ uint32 shmem_size;
+ int host_handle_id;
+ SerializedHandle plugin_handle;
};
// Converts |raw_var_data_| to |var_|. It is a no-op if |raw_var_data_| is
@@ -158,6 +189,8 @@ class PPAPI_PROXY_EXPORT SerializedVar {
// a string ID. Before this, the as_id will be 0 for VARTYPE_STRING.
PP_Var var_;
+ PP_Instance instance_;
+
CleanupMode cleanup_mode_;
#ifndef NDEBUG
@@ -208,6 +241,19 @@ class PPAPI_PROXY_EXPORT SerializedVarSendInput : public SerializedVar {
SerializedVarSendInput();
};
+// Specialization for optionally sending over shared memory.
+class PPAPI_PROXY_EXPORT SerializedVarSendInputShmem : public SerializedVar {
+ public:
+ SerializedVarSendInputShmem(Dispatcher* dispatcher, const PP_Var& var,
+ const PP_Instance& instance);
+
+ private:
+ // Disallow the empty constructor, but keep the default copy constructor
+ // which is required to send the object to the IPC system.
+ SerializedVarSendInputShmem();
+};
+
+
// For the calling side of a function returning a var. The sending side uses
// SerializedVarReturnValue.
//
@@ -324,6 +370,7 @@ class PPAPI_PROXY_EXPORT SerializedVarReceiveInput {
~SerializedVarReceiveInput();
PP_Var Get(Dispatcher* dispatcher);
+ PP_Var GetForInstance(Dispatcher* dispatcher, PP_Instance instance);
private:
const SerializedVar& serialized_;