summaryrefslogtreecommitdiffstats
path: root/ppapi/proxy/serialized_var.cc
diff options
context:
space:
mode:
authordmichael@chromium.org <dmichael@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-16 19:39:22 +0000
committerdmichael@chromium.org <dmichael@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-16 19:39:22 +0000
commit10305deb1ed8a625a34629c372c7aae171e07cac (patch)
treead8b7d5e3ea63b6848fa05a6cc298df7743a21d9 /ppapi/proxy/serialized_var.cc
parentc98ea3f52244b1a083e48ba760fb184fff664cd7 (diff)
downloadchromium_src-10305deb1ed8a625a34629c372c7aae171e07cac.zip
chromium_src-10305deb1ed8a625a34629c372c7aae171e07cac.tar.gz
chromium_src-10305deb1ed8a625a34629c372c7aae171e07cac.tar.bz2
PPAPI: Proxy VarArrayBuffer for out-of-process.
BUG=103435 TEST= Review URL: https://chromiumcodereview.appspot.com/9373032 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@122340 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi/proxy/serialized_var.cc')
-rw-r--r--ppapi/proxy/serialized_var.cc32
1 files changed, 29 insertions, 3 deletions
diff --git a/ppapi/proxy/serialized_var.cc b/ppapi/proxy/serialized_var.cc
index 7153c0c..eb20333 100644
--- a/ppapi/proxy/serialized_var.cc
+++ b/ppapi/proxy/serialized_var.cc
@@ -5,11 +5,13 @@
#include "ppapi/proxy/serialized_var.h"
#include "base/logging.h"
+#include "base/memory/ref_counted.h"
#include "ipc/ipc_message_utils.h"
#include "ppapi/proxy/dispatcher.h"
#include "ppapi/proxy/interface_proxy.h"
#include "ppapi/proxy/ppapi_param_traits.h"
#include "ppapi/proxy/var_serialization_rules.h"
+#include "ppapi/shared_impl/ppapi_globals.h"
#include "ppapi/shared_impl/var.h"
namespace ppapi {
@@ -116,10 +118,24 @@ void SerializedVar::Inner::WriteToMessage(IPC::Message* m) const {
m->WriteString(string_var ? *string_var->ptr() : std::string());
break;
}
- case PP_VARTYPE_ARRAY_BUFFER:
- // TODO(dmichael): Proxy ArrayBuffer.
- NOTIMPLEMENTED();
+ case PP_VARTYPE_ARRAY_BUFFER: {
+ // TODO(dmichael) in the case of an invalid var ID, it would be nice
+ // to send something to the other side such that a 0 ID would be
+ // generated there. Then the function implementing the interface can
+ // handle the invalid string as if it was in process rather than seeing
+ // what looks like a valid empty ArraryBuffer.
+ ArrayBufferVar* buffer_var = ArrayBufferVar::FromPPVar(var_);
+ if (buffer_var) {
+ // TODO(dmichael): If it wasn't already Mapped, Unmap it. (Though once
+ // we use shared memory, this will probably be
+ // completely different anyway).
+ m->WriteData(static_cast<const char*>(buffer_var->Map()),
+ buffer_var->ByteLength());
+ } else {
+ m->WriteData(NULL, 0);
+ }
break;
+ }
case PP_VARTYPE_OBJECT:
m->WriteInt64(var_.value.as_id);
break;
@@ -176,6 +192,16 @@ bool SerializedVar::Inner::ReadFromMessage(const IPC::Message* m, void** iter) {
var_ = StringVar::SwapValidatedUTF8StringIntoPPVar(&string_from_ipc);
break;
}
+ case PP_VARTYPE_ARRAY_BUFFER: {
+ int length = 0;
+ const char* message_bytes = NULL;
+ success = m->ReadData(iter, &message_bytes, &length);
+ if (success) {
+ var_ = PpapiGlobals::Get()->GetVarTracker()->MakeArrayBufferPPVar(
+ length, message_bytes);
+ }
+ break;
+ }
case PP_VARTYPE_OBJECT:
success = m->ReadInt64(iter, &var_.value.as_id);
break;