OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef PPAPI_SHARED_IMPL_VAR_VALUE_CONVERSIONS_H_ |
| 6 #define PPAPI_SHARED_IMPL_VAR_VALUE_CONVERSIONS_H_ |
| 7 |
| 8 #include "ppapi/c/pp_var.h" |
| 9 #include "ppapi/shared_impl/ppapi_shared_export.h" |
| 10 |
| 11 namespace base { |
| 12 class Value; |
| 13 } |
| 14 |
| 15 namespace ppapi { |
| 16 |
| 17 // Converts a PP_Var to a base::Value object. The caller takes ownership of the |
| 18 // returned object. |
| 19 // |
| 20 // Both PP_VARTYPE_UNDEFINED and PP_VARTYPE_NULL are converted to |
| 21 // base::Value::TYPE_NULL. In dictionary vars, key-value pairs whose value is |
| 22 // undefined (PP_VARTYPE_UNDEFINED) are ignored. If a node in |var| appears more |
| 23 // than once, it is duplicated in the result. For example, if |var| is an array |
| 24 // and it has two elements pointing to the same dictionary, the resulting list |
| 25 // value will have two copies of the dictionary. |
| 26 // |
| 27 // The conversion fails and returns NULL if |
| 28 // - |var| is object (PP_VARTYPE_OBJECT); or |
| 29 // - |var| is an array or dictionary, and calling CreateValueFromVar() on any of |
| 30 // the array elements or dictionary values fails; or |
| 31 // - there exist circular references, i.e., an array or dictionary is its own |
| 32 // ancestor/descendant. |
| 33 PPAPI_SHARED_EXPORT base::Value* CreateValueFromVar(const PP_Var& var); |
| 34 |
| 35 // The returned var has been added ref on behalf of the caller. |
| 36 // Returns an undefined var if the conversion fails. |
| 37 PPAPI_SHARED_EXPORT PP_Var CreateVarFromValue(const base::Value& value); |
| 38 |
| 39 } // namespace ppapi |
| 40 |
| 41 #endif // PPAPI_SHARED_IMPL_VAR_VALUE_CONVERSIONS_H_ |
OLD | NEW |