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

Unified Diff: chrome/browser/profiles/dependency_graph.h

Issue 13454032: Extract DependencyGraph from ProfileDependencyManager. (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
« no previous file with comments | « no previous file | chrome/browser/profiles/dependency_graph.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/profiles/dependency_graph.h
diff --git a/chrome/browser/profiles/dependency_graph.h b/chrome/browser/profiles/dependency_graph.h
new file mode 100644
index 0000000000000000000000000000000000000000..511a21e350bf839dd362d38eeae7d4bf85650771
--- /dev/null
+++ b/chrome/browser/profiles/dependency_graph.h
@@ -0,0 +1,57 @@
+// Copyright 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 CHROME_BROWSER_PROFILES_DEPENDENCY_GRAPH_H_
+#define CHROME_BROWSER_PROFILES_DEPENDENCY_GRAPH_H_
+
+#include <map>
+#include <string>
+#include <vector>
+
+#include "base/callback.h"
+#include "base/compiler_specific.h"
+
+class DependencyGraph {
+ public:
+ typedef base::Callback<std::string(void*)> GetNodeNameCallback;
+
+ explicit DependencyGraph(const GetNodeNameCallback& callback);
+ ~DependencyGraph();
+
+ // Adds/Removes a node from our list of live nodes. Removing will
+ // also remove live dependency links.
+ void AddNode(void* node);
+ void RemoveNode(void* node);
+
+ // Adds a dependency between two nodes.
+ void AddEdge(void* depended, void* dependee);
Elliot Glaysher 2013/04/05 23:44:15 I'd prefer it if you got rid of these void pointer
Paweł Hajdan Jr. 2013/04/08 20:26:43 Glad to see a concern for safety and correctness.
Elliot Glaysher 2013/04/11 20:09:28 So what's the motivation for doing that? Creating
+
+ // Topologically sorts nodes to produce a safe construction order
+ // (all nodes after their dependees).
+ bool GetConstructionOrder(std::vector<void*>* order) WARN_UNUSED_RESULT;
+
+ // Topologically sorts nodes to produce a safe destruction order
+ // (all nodes before their dependees).
+ bool GetDestructionOrder(std::vector<void*>* order) WARN_UNUSED_RESULT;
+
+ // Returns representation of the dependency graph in graphviz format.
+ std::string DumpAsGraphviz(const std::string& toplevel_name);
+
+ private:
+ typedef std::multimap<void*, void*> EdgeMap;
+
+ bool BuildConstructionOrder() WARN_UNUSED_RESULT;
+
+ std::vector<void*> all_nodes_;
+
+ EdgeMap edges_;
+
+ std::vector<void*> construction_order_;
+
+ GetNodeNameCallback get_node_name_callback_;
+
+ DISALLOW_COPY_AND_ASSIGN(DependencyGraph);
+};
+
+#endif // CHROME_BROWSER_PROFILES_DEPENDENCY_GRAPH_H_
« no previous file with comments | « no previous file | chrome/browser/profiles/dependency_graph.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698