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

Side by Side 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: no void* 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
OLDNEW
(Empty)
1 // Copyright 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 CHROME_BROWSER_PROFILES_DEPENDENCY_GRAPH_H_
6 #define CHROME_BROWSER_PROFILES_DEPENDENCY_GRAPH_H_
7
8 #include <map>
9 #include <string>
10 #include <vector>
11
12 #include "base/callback.h"
13 #include "base/compiler_specific.h"
14
15 class DependencyNode;
16
17 class DependencyGraph {
18 public:
19 typedef base::Callback<std::string(DependencyNode*)> GetNodeNameCallback;
20
21 explicit DependencyGraph(const GetNodeNameCallback& callback);
22 ~DependencyGraph();
23
24 // Adds/Removes a node from our list of live nodes. Removing will
25 // also remove live dependency links.
26 void AddNode(DependencyNode* node);
27 void RemoveNode(DependencyNode* node);
28
29 // Adds a dependency between two nodes.
30 void AddEdge(DependencyNode* depended, DependencyNode* dependee);
31
32 // Topologically sorts nodes to produce a safe construction order
33 // (all nodes after their dependees).
34 bool GetConstructionOrder(
35 std::vector<DependencyNode*>* order) WARN_UNUSED_RESULT;
36
37 // Topologically sorts nodes to produce a safe destruction order
38 // (all nodes before their dependees).
39 bool GetDestructionOrder(
40 std::vector<DependencyNode*>* order) WARN_UNUSED_RESULT;
41
42 // Returns representation of the dependency graph in graphviz format.
43 std::string DumpAsGraphviz(const std::string& toplevel_name);
44
45 private:
46 typedef std::multimap<DependencyNode*, DependencyNode*> EdgeMap;
47
48 bool BuildConstructionOrder() WARN_UNUSED_RESULT;
49
50 std::vector<DependencyNode*> all_nodes_;
51
52 EdgeMap edges_;
53
54 std::vector<DependencyNode*> construction_order_;
55
56 GetNodeNameCallback get_node_name_callback_;
57
58 DISALLOW_COPY_AND_ASSIGN(DependencyGraph);
59 };
60
61 #endif // CHROME_BROWSER_PROFILES_DEPENDENCY_GRAPH_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/profiles/dependency_graph.cc » ('j') | chrome/browser/profiles/dependency_node.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698