diff options
author | raymes@chromium.org <raymes@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-05-16 18:03:57 +0000 |
---|---|---|
committer | raymes@chromium.org <raymes@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-05-16 18:03:57 +0000 |
commit | 7e3461079b02605faf2a1e767bfad03bb5e8eaf1 (patch) | |
tree | 951e1edba29f6461f74cfb6564383e6183148d3f /webkit/plugins/ppapi/v8_var_converter.h | |
parent | 05893fabc7515cb9fc253ef5a9822d3325e6d344 (diff) | |
download | chromium_src-7e3461079b02605faf2a1e767bfad03bb5e8eaf1.zip chromium_src-7e3461079b02605faf2a1e767bfad03bb5e8eaf1.tar.gz chromium_src-7e3461079b02605faf2a1e767bfad03bb5e8eaf1.tar.bz2 |
Implement a V8 value<->PP_Var converter
NOTE: This patch is being relanded after it was reverted in 199944 due to a unittest breakage, fixed by 200279.
This implements a converter for transforming between V8 values and PP_Vars. This is needed to support transferring arrays/dictionaries (or arrays/objects in javascript) to and from the plugin using the pepper Post/HandleMessage APIs. The entire object graph is converted in the process.
TBR=dmichael@chromium.org
BUG=236958
Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=199938
Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=200283
Review URL: https://codereview.chromium.org/14424006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@200578 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/plugins/ppapi/v8_var_converter.h')
-rw-r--r-- | webkit/plugins/ppapi/v8_var_converter.h | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/webkit/plugins/ppapi/v8_var_converter.h b/webkit/plugins/ppapi/v8_var_converter.h new file mode 100644 index 0000000..c19644c --- /dev/null +++ b/webkit/plugins/ppapi/v8_var_converter.h @@ -0,0 +1,41 @@ +// Copyright (c) 2013 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 WEBKIT_PLUGINS_PPAPI_V8_VAR_CONVERTER_H +#define WEBKIT_PLUGINS_PPAPI_V8_VAR_CONVERTER_H + + +#include "base/basictypes.h" +#include "base/compiler_specific.h" +#include "ppapi/c/pp_var.h" +#include "v8/include/v8.h" +#include "webkit/plugins/webkit_plugins_export.h" + +namespace webkit { +namespace ppapi { + +// Class to convert between PP_Vars and V8 values. +class WEBKIT_PLUGINS_EXPORT V8VarConverter { + public: + V8VarConverter(); + + // Converts the given PP_Var to a v8::Value. True is returned upon success. + bool ToV8Value(const PP_Var& var, + v8::Handle<v8::Context> context, + v8::Handle<v8::Value>* result) const; + // Converts the given v8::Value to a PP_Var. True is returned upon success. + // Every PP_Var in the reference graph of which |result| is apart will have + // a refcount equal to the number of references to it in the graph. |result| + // will have one additional reference. + bool FromV8Value(v8::Handle<v8::Value> val, + v8::Handle<v8::Context> context, + PP_Var* result) const; + + DISALLOW_COPY_AND_ASSIGN(V8VarConverter); +}; + +} // namespace ppapi +} // namespace webkit + +#endif // WEBKIT_PLUGINS_PPAPI_V8_VAR_CONVERTER_H |