Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(176)

Side by Side Diff: ppapi/shared_impl/var_value_conversions.h

Issue 13080002: Apps V2 in Pepper: introduce singleton resource ExtensionsCommon. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ppapi/shared_impl/singleton_resource_id.h ('k') | ppapi/shared_impl/var_value_conversions.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef PPAPI_SHARED_IMPL_VAR_VALUE_CONVERSIONS_H_ 5 #ifndef PPAPI_SHARED_IMPL_VAR_VALUE_CONVERSIONS_H_
6 #define PPAPI_SHARED_IMPL_VAR_VALUE_CONVERSIONS_H_ 6 #define PPAPI_SHARED_IMPL_VAR_VALUE_CONVERSIONS_H_
7 7
8 #include <vector>
9
8 #include "ppapi/c/pp_var.h" 10 #include "ppapi/c/pp_var.h"
9 #include "ppapi/shared_impl/ppapi_shared_export.h" 11 #include "ppapi/shared_impl/ppapi_shared_export.h"
10 12
11 namespace base { 13 namespace base {
14 class ListValue;
12 class Value; 15 class Value;
13 } 16 }
14 17
15 namespace ppapi { 18 namespace ppapi {
16 19
17 // Converts a PP_Var to a base::Value object. The caller takes ownership of the 20 // Converts a PP_Var to a base::Value object. The caller takes ownership of the
18 // returned object. 21 // returned object.
19 // 22 //
20 // Both PP_VARTYPE_UNDEFINED and PP_VARTYPE_NULL are converted to 23 // 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 24 // 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 25 // undefined (PP_VARTYPE_UNDEFINED) or null (PP_VARTYPE_NULL) are ignored. If a
23 // than once, it is duplicated in the result. For example, if |var| is an array 26 // node in |var| appears more than once, it is duplicated in the result. For
24 // and it has two elements pointing to the same dictionary, the resulting list 27 // example, if |var| is an array and it has two elements pointing to the same
25 // value will have two copies of the dictionary. 28 // dictionary, the resulting list value will have two copies of the dictionary.
26 // 29 //
27 // The conversion fails and returns NULL if 30 // The conversion fails and returns NULL if
28 // - |var| is object (PP_VARTYPE_OBJECT); or 31 // - |var| is object (PP_VARTYPE_OBJECT); or
29 // - |var| is an array or dictionary, and calling CreateValueFromVar() on any of 32 // - |var| is an array or dictionary, and calling CreateValueFromVar() on any of
30 // the array elements or dictionary values fails; or 33 // the array elements or dictionary values fails; or
31 // - there exist circular references, i.e., an array or dictionary is its own 34 // - there exist circular references, i.e., an array or dictionary is its own
32 // ancestor/descendant. 35 // ancestor/descendant.
33 PPAPI_SHARED_EXPORT base::Value* CreateValueFromVar(const PP_Var& var); 36 PPAPI_SHARED_EXPORT base::Value* CreateValueFromVar(const PP_Var& var);
34 37
35 // The returned var has been added ref on behalf of the caller. 38 // The returned var has had 1 ref added on behalf of the caller.
36 // Returns an undefined var if the conversion fails. 39 // Returns an undefined var if the conversion fails.
37 PPAPI_SHARED_EXPORT PP_Var CreateVarFromValue(const base::Value& value); 40 PPAPI_SHARED_EXPORT PP_Var CreateVarFromValue(const base::Value& value);
38 41
42 // Calls CreateValueFromVar() on each element of |vars| and puts them in a
43 // base::ListValue. The caller takes ownership of the returned object.
44 //
45 // The conversion fails and returns NULL if any of the calls to
46 // CreateValueFromVar() fails.
47 PPAPI_SHARED_EXPORT base::ListValue* CreateListValueFromVarVector(
48 const std::vector<PP_Var>& vars);
49
50 // Calls CreateVarFromValue() on each element of |list_value| and puts them in
51 // |vars|. The returned vars have had 1 ref added on behalf of the caller.
52 //
53 // The conversion fails and returns false if any of the calls to
54 // CreateVarFromValue() fails. In that case, |vars| is untouched.
55 PPAPI_SHARED_EXPORT bool CreateVarVectorFromListValue(
56 const base::ListValue& list_value, std::vector<PP_Var>* vars);
57
39 } // namespace ppapi 58 } // namespace ppapi
40 59
41 #endif // PPAPI_SHARED_IMPL_VAR_VALUE_CONVERSIONS_H_ 60 #endif // PPAPI_SHARED_IMPL_VAR_VALUE_CONVERSIONS_H_
OLDNEW
« no previous file with comments | « ppapi/shared_impl/singleton_resource_id.h ('k') | ppapi/shared_impl/var_value_conversions.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698