OLD | NEW |
---|---|
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 #include "components/browser_context_keyed_service/browser_context_dependency_ma nager.h" | 5 #include "components/browser_context_keyed_service/browser_context_dependency_ma nager.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <deque> | 8 #include <deque> |
9 #include <iterator> | 9 #include <iterator> |
10 | 10 |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
67 | 67 |
68 void BrowserContextDependencyManager::DoCreateBrowserContextServices( | 68 void BrowserContextDependencyManager::DoCreateBrowserContextServices( |
69 content::BrowserContext* context, | 69 content::BrowserContext* context, |
70 bool is_testing_context) { | 70 bool is_testing_context) { |
71 TRACE_EVENT0("browser", | 71 TRACE_EVENT0("browser", |
72 "BrowserContextDependencyManager::DoCreateBrowserContextServices") | 72 "BrowserContextDependencyManager::DoCreateBrowserContextServices") |
73 #ifndef NDEBUG | 73 #ifndef NDEBUG |
74 // Unmark |context| as dead. This exists because of unit tests, which will | 74 // Unmark |context| as dead. This exists because of unit tests, which will |
75 // often have similar stack structures. 0xWhatever might be created, go out | 75 // often have similar stack structures. 0xWhatever might be created, go out |
76 // of scope, and then a new BrowserContext object might be created | 76 // of scope, and then a new BrowserContext object might be created |
77 // at 0xWhatever. | 77 // at 0xWhatever. |
Elliot Glaysher
2014/02/13 17:23:53
The only thing I can think of to improve this patc
blundell
2014/02/13 21:45:40
Done.
| |
78 dead_context_pointers_.erase(context); | 78 dead_context_pointers_.erase(context); |
79 #endif | 79 #endif |
80 | 80 |
81 std::vector<DependencyNode*> construction_order; | 81 std::vector<DependencyNode*> construction_order; |
82 if (!dependency_graph_.GetConstructionOrder(&construction_order)) { | 82 if (!dependency_graph_.GetConstructionOrder(&construction_order)) { |
83 NOTREACHED(); | 83 NOTREACHED(); |
84 } | 84 } |
85 | 85 |
86 #ifndef NDEBUG | 86 #ifndef NDEBUG |
87 DumpBrowserContextDependencies(context); | 87 DumpBrowserContextDependencies(context); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
132 void BrowserContextDependencyManager::AssertBrowserContextWasntDestroyed( | 132 void BrowserContextDependencyManager::AssertBrowserContextWasntDestroyed( |
133 content::BrowserContext* context) { | 133 content::BrowserContext* context) { |
134 if (dead_context_pointers_.find(context) != dead_context_pointers_.end()) { | 134 if (dead_context_pointers_.find(context) != dead_context_pointers_.end()) { |
135 NOTREACHED() << "Attempted to access a BrowserContext that was ShutDown(). " | 135 NOTREACHED() << "Attempted to access a BrowserContext that was ShutDown(). " |
136 << "This is most likely a heap smasher in progress. After " | 136 << "This is most likely a heap smasher in progress. After " |
137 << "BrowserContextKeyedService::Shutdown() completes, your " | 137 << "BrowserContextKeyedService::Shutdown() completes, your " |
138 << "service MUST NOT refer to depended BrowserContext " | 138 << "service MUST NOT refer to depended BrowserContext " |
139 << "services again."; | 139 << "services again."; |
140 } | 140 } |
141 } | 141 } |
142 | |
143 void BrowserContextDependencyManager::MarkBrowserContextLiveForTesting( | |
144 content::BrowserContext* context) { | |
145 dead_context_pointers_.erase(context); | |
146 } | |
142 #endif | 147 #endif |
143 | 148 |
144 // static | 149 // static |
145 BrowserContextDependencyManager* | 150 BrowserContextDependencyManager* |
146 BrowserContextDependencyManager::GetInstance() { | 151 BrowserContextDependencyManager::GetInstance() { |
147 return Singleton<BrowserContextDependencyManager>::get(); | 152 return Singleton<BrowserContextDependencyManager>::get(); |
148 } | 153 } |
149 | 154 |
150 BrowserContextDependencyManager::BrowserContextDependencyManager() { | 155 BrowserContextDependencyManager::BrowserContextDependencyManager() { |
151 } | 156 } |
(...skipping 18 matching lines...) Expand all Loading... | |
170 kDumpBrowserContextDependencyGraphFlag)) { | 175 kDumpBrowserContextDependencyGraphFlag)) { |
171 base::FilePath dot_file = | 176 base::FilePath dot_file = |
172 context->GetPath().AppendASCII("browser-context-dependencies.dot"); | 177 context->GetPath().AppendASCII("browser-context-dependencies.dot"); |
173 std::string contents = dependency_graph_.DumpAsGraphviz( | 178 std::string contents = dependency_graph_.DumpAsGraphviz( |
174 "BrowserContext", | 179 "BrowserContext", |
175 base::Bind(&BrowserContextKeyedBaseFactoryGetNodeName)); | 180 base::Bind(&BrowserContextKeyedBaseFactoryGetNodeName)); |
176 file_util::WriteFile(dot_file, contents.c_str(), contents.size()); | 181 file_util::WriteFile(dot_file, contents.c_str(), contents.size()); |
177 } | 182 } |
178 } | 183 } |
179 #endif // NDEBUG | 184 #endif // NDEBUG |
OLD | NEW |