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

Unified Diff: ppapi/shared_impl/var_graph.h

Issue 13887007: Introduce RawVarData and associated classes for serializing PP_Vars (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 side-by-side diff with in-line comments
Download patch
Index: ppapi/shared_impl/var_graph.h
diff --git a/ppapi/shared_impl/var_graph.h b/ppapi/shared_impl/var_graph.h
new file mode 100644
index 0000000000000000000000000000000000000000..b5e80499a5a137dabdd42145528860423c2c987b
--- /dev/null
+++ b/ppapi/shared_impl/var_graph.h
@@ -0,0 +1,45 @@
+// 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 PPAPI_SHARED_IMPL_VAR_GRAPH_H_
+#define PPAPI_SHARED_IMPL_VAR_GRAPH_H_
+
+#include <stddef.h>
+#include <stdint.h>
+#include <map>
+#include <vector>
+
+#include "ppapi/c/pp_var.h"
+
+namespace ppapi {
+
+// PP_Vars form a graph when one PP_Var holds a reference to another PP_Var.
+// For example PP_VARTYPE_ARRAY PP_Vars hold an array of other PP_Vars.
+// A VarGraph is an intermediate representation of a graph of PP_Vars which is
dmichael (off chromium) 2013/04/12 22:40:38 nit: is is
raymes 2013/04/14 16:32:57 this is removed now
+// is useful for serializing the graph or converting it to some other format.
+// The VarGraph is computed by computing the transitive closure of a
+// starting node and storing them in |nodes|.
+//
+// |id_map| holds a mapping of the PP_Var |as_id| value to an index into
+// |nodes|. For example if a PP_Var had an |as_id| value of 23 and was contained
+// at index 2 in |nodes|, there would be an entry of 23->2 in |id_map|. Note
+// that only PP_Vars that point to objects in the VarTracker are considered.
+// Other PP_Vars are either primitives or null references which are guaranteed
+// to be leaves in the graph. Since they cannot be identified by an id, they
+// are not added to the list of nodes.
+//
+// Note: this is a very simple, minimal representation of a graph of
+// PP_Vars. We could have a more complex structure later if it was warranted.
+struct VarGraph {
dmichael (off chromium) 2013/04/12 22:40:38 This isn't really a Graph, best I can tell. It see
raymes 2013/04/14 16:32:57 This is removed now
+ // Creates a VarGraph starting at |start_node| and storing the result in
+ // |result|. True is returned on success, false otherwise.
+ static bool Create(const PP_Var& start_node, VarGraph* result);
+
+ std::vector<PP_Var> nodes;
+ std::map<int64_t, size_t> id_map;
dmichael (off chromium) 2013/04/12 22:40:38 hash map is probably a better choice for int64_t
raymes 2013/04/14 16:32:57 Done.
+};
+
+} // namespace ppapi
+
+#endif // PPAPI_SHARED_IMPL_VAR_GRAPH_H_

Powered by Google App Engine
This is Rietveld 408576698