diff options
author | dmichael@chromium.org <dmichael@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-12-15 21:22:31 +0000 |
---|---|---|
committer | dmichael@chromium.org <dmichael@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-12-15 21:22:31 +0000 |
commit | 8cc26a4c78767feaf47fa94af34471d63e3596e5 (patch) | |
tree | 24399869b26449df2a6a838796941c984106f4b2 /ppapi/proxy | |
parent | b40a1f1acb4d3fa0c56a3706dd47a2ca8d471834 (diff) | |
download | chromium_src-8cc26a4c78767feaf47fa94af34471d63e3596e5.zip chromium_src-8cc26a4c78767feaf47fa94af34471d63e3596e5.tar.gz chromium_src-8cc26a4c78767feaf47fa94af34471d63e3596e5.tar.bz2 |
Implement in-process PPB_VarArrayBuffer_Dev.
+tony TBR for webkit/glue/webkit_glue.gypi
BUG=103435
TEST=N/A
TBR=tony
Review URL: http://codereview.chromium.org/8930010
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@114700 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi/proxy')
-rw-r--r-- | ppapi/proxy/plugin_array_buffer_var.cc | 31 | ||||
-rw-r--r-- | ppapi/proxy/plugin_array_buffer_var.h | 36 | ||||
-rw-r--r-- | ppapi/proxy/plugin_var_tracker.cc | 5 | ||||
-rw-r--r-- | ppapi/proxy/plugin_var_tracker.h | 3 | ||||
-rw-r--r-- | ppapi/proxy/proxy_object_var.cc | 11 | ||||
-rw-r--r-- | ppapi/proxy/proxy_object_var.h | 1 | ||||
-rw-r--r-- | ppapi/proxy/serialized_var.cc | 5 |
7 files changed, 78 insertions, 14 deletions
diff --git a/ppapi/proxy/plugin_array_buffer_var.cc b/ppapi/proxy/plugin_array_buffer_var.cc new file mode 100644 index 0000000..d88ca7b --- /dev/null +++ b/ppapi/proxy/plugin_array_buffer_var.cc @@ -0,0 +1,31 @@ +// 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. + +#include "ppapi/proxy/plugin_array_buffer_var.h" + +#include <stdlib.h> + +#include <limits> + +namespace ppapi { + +PluginArrayBufferVar::PluginArrayBufferVar(uint32 size_in_bytes) + : buffer_(size_in_bytes) { +} + +PluginArrayBufferVar::~PluginArrayBufferVar() { +} + +void* PluginArrayBufferVar::Map() { + if (buffer_.empty()) + return NULL; + return &(buffer_[0]); +} + +uint32 PluginArrayBufferVar::ByteLength() { + return buffer_.size(); +} + +} // namespace ppapi + diff --git a/ppapi/proxy/plugin_array_buffer_var.h b/ppapi/proxy/plugin_array_buffer_var.h new file mode 100644 index 0000000..5e4d702 --- /dev/null +++ b/ppapi/proxy/plugin_array_buffer_var.h @@ -0,0 +1,36 @@ +// 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_PROXY_PLUGIN_ARRAY_BUFFER_VAR_H_ +#define PPAPI_PROXY_PLUGIN_ARRAY_BUFFER_VAR_H_ + +#include <vector> + +#include "base/basictypes.h" +#include "ppapi/c/pp_stdint.h" +#include "ppapi/shared_impl/var.h" + +namespace ppapi { + +// Represents a plugin-side ArrayBufferVar. In the plugin process, it's +// owned as a vector. +class PluginArrayBufferVar : public ArrayBufferVar { + public: + explicit PluginArrayBufferVar(uint32 size_in_bytes); + virtual ~PluginArrayBufferVar(); + + // ArrayBufferVar implementation. + virtual void* Map() OVERRIDE; + virtual uint32 ByteLength() OVERRIDE; + + private: + // TODO(dmichael): Use shared memory for this. + std::vector<uint8> buffer_; + + DISALLOW_COPY_AND_ASSIGN(PluginArrayBufferVar); +}; + +} // namespace ppapi + +#endif // PPAPI_PROXY_PLUGIN_ARRAY_BUFFER_VAR_H_ diff --git a/ppapi/proxy/plugin_var_tracker.cc b/ppapi/proxy/plugin_var_tracker.cc index 8ea25b1..a5f499a 100644 --- a/ppapi/proxy/plugin_var_tracker.cc +++ b/ppapi/proxy/plugin_var_tracker.cc @@ -7,6 +7,7 @@ #include "base/memory/ref_counted.h" #include "base/memory/singleton.h" #include "ppapi/c/ppb_var.h" +#include "ppapi/proxy/plugin_array_buffer_var.h" #include "ppapi/proxy/plugin_dispatcher.h" #include "ppapi/proxy/ppapi_messages.h" #include "ppapi/proxy/proxy_object_var.h" @@ -156,6 +157,10 @@ int PluginVarTracker::GetTrackedWithNoReferenceCountForObject( return found->second.track_with_no_reference_count; } +ArrayBufferVar* PluginVarTracker::CreateArrayBuffer(uint32 size_in_bytes) { + return new PluginArrayBufferVar(size_in_bytes); +} + int32 PluginVarTracker::AddVarInternal(Var* var, AddVarRefMode mode) { // Normal adding. int32 new_id = VarTracker::AddVarInternal(var, mode); diff --git a/ppapi/proxy/plugin_var_tracker.h b/ppapi/proxy/plugin_var_tracker.h index b6bb893..c2ede10 100644 --- a/ppapi/proxy/plugin_var_tracker.h +++ b/ppapi/proxy/plugin_var_tracker.h @@ -62,12 +62,13 @@ class PPAPI_PROXY_EXPORT PluginVarTracker : public VarTracker { int GetRefCountForObject(const PP_Var& plugin_object); int GetTrackedWithNoReferenceCountForObject(const PP_Var& plugin_object); - protected: + private: // VarTracker protected overrides. virtual int32 AddVarInternal(Var* var, AddVarRefMode mode) OVERRIDE; virtual void TrackedObjectGettingOneRef(VarMap::const_iterator iter) OVERRIDE; virtual void ObjectGettingZeroRef(VarMap::iterator iter) OVERRIDE; virtual bool DeleteObjectInfoIfNecessary(VarMap::iterator iter) OVERRIDE; + virtual ArrayBufferVar* CreateArrayBuffer(uint32 size_in_bytes) OVERRIDE; private: friend struct DefaultSingletonTraits<PluginVarTracker>; diff --git a/ppapi/proxy/proxy_object_var.cc b/ppapi/proxy/proxy_object_var.cc index 4a185e8..acd53f3 100644 --- a/ppapi/proxy/proxy_object_var.cc +++ b/ppapi/proxy/proxy_object_var.cc @@ -27,17 +27,6 @@ ProxyObjectVar* ProxyObjectVar::AsProxyObjectVar() { return this; } -PP_Var ProxyObjectVar::GetPPVar() { - int32 id = GetOrCreateVarID(); - if (!id) - return PP_MakeNull(); - - PP_Var result; - result.type = PP_VARTYPE_OBJECT; - result.value.as_id = id; - return result; -} - PP_VarType ProxyObjectVar::GetType() const { return PP_VARTYPE_OBJECT; } diff --git a/ppapi/proxy/proxy_object_var.h b/ppapi/proxy/proxy_object_var.h index e8d7aed..e9760f9 100644 --- a/ppapi/proxy/proxy_object_var.h +++ b/ppapi/proxy/proxy_object_var.h @@ -26,7 +26,6 @@ class ProxyObjectVar : public Var { // Var overrides. virtual ProxyObjectVar* AsProxyObjectVar() OVERRIDE; - virtual PP_Var GetPPVar() OVERRIDE; virtual PP_VarType GetType() const OVERRIDE; proxy::PluginDispatcher* dispatcher() const { return dispatcher_; } diff --git a/ppapi/proxy/serialized_var.cc b/ppapi/proxy/serialized_var.cc index 7a9eb6f..b892daf 100644 --- a/ppapi/proxy/serialized_var.cc +++ b/ppapi/proxy/serialized_var.cc @@ -152,12 +152,15 @@ void SerializedVar::Inner::WriteToMessage(IPC::Message* m) const { // what looks like a valid empty string. m->WriteString(string_value_); break; + case PP_VARTYPE_ARRAY_BUFFER: + // TODO(dmichael): Proxy ArrayBuffer. + NOTIMPLEMENTED(); + break; case PP_VARTYPE_OBJECT: m->WriteInt64(var_.value.as_id); break; case PP_VARTYPE_ARRAY: case PP_VARTYPE_DICTIONARY: - case PP_VARTYPE_ARRAY_BUFFER: // TODO(brettw) when these are supported, implement this. NOTIMPLEMENTED(); break; |