From 7e3461079b02605faf2a1e767bfad03bb5e8eaf1 Mon Sep 17 00:00:00 2001 From: "raymes@chromium.org" Date: Thu, 16 May 2013 18:03:57 +0000 Subject: 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 --- webkit/plugins/ppapi/v8_var_converter.h | 41 +++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 webkit/plugins/ppapi/v8_var_converter.h (limited to 'webkit/plugins/ppapi/v8_var_converter.h') 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 context, + v8::Handle* 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 val, + v8::Handle context, + PP_Var* result) const; + + DISALLOW_COPY_AND_ASSIGN(V8VarConverter); +}; + +} // namespace ppapi +} // namespace webkit + +#endif // WEBKIT_PLUGINS_PPAPI_V8_VAR_CONVERTER_H -- cgit v1.1