| 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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 content::BrowserContext* context) { | 64 content::BrowserContext* context) { |
| 65 DoCreateBrowserContextServices(context, true); | 65 DoCreateBrowserContextServices(context, true); |
| 66 } | 66 } |
| 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 MarkBrowserContextLiveForTesting(context); |
| 75 // often have similar stack structures. 0xWhatever might be created, go out | |
| 76 // of scope, and then a new BrowserContext object might be created | |
| 77 // at 0xWhatever. | |
| 78 dead_context_pointers_.erase(context); | |
| 79 #endif | 75 #endif |
| 80 | 76 |
| 81 std::vector<DependencyNode*> construction_order; | 77 std::vector<DependencyNode*> construction_order; |
| 82 if (!dependency_graph_.GetConstructionOrder(&construction_order)) { | 78 if (!dependency_graph_.GetConstructionOrder(&construction_order)) { |
| 83 NOTREACHED(); | 79 NOTREACHED(); |
| 84 } | 80 } |
| 85 | 81 |
| 86 #ifndef NDEBUG | 82 #ifndef NDEBUG |
| 87 DumpBrowserContextDependencies(context); | 83 DumpBrowserContextDependencies(context); |
| 88 #endif | 84 #endif |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 void BrowserContextDependencyManager::AssertBrowserContextWasntDestroyed( | 128 void BrowserContextDependencyManager::AssertBrowserContextWasntDestroyed( |
| 133 content::BrowserContext* context) { | 129 content::BrowserContext* context) { |
| 134 if (dead_context_pointers_.find(context) != dead_context_pointers_.end()) { | 130 if (dead_context_pointers_.find(context) != dead_context_pointers_.end()) { |
| 135 NOTREACHED() << "Attempted to access a BrowserContext that was ShutDown(). " | 131 NOTREACHED() << "Attempted to access a BrowserContext that was ShutDown(). " |
| 136 << "This is most likely a heap smasher in progress. After " | 132 << "This is most likely a heap smasher in progress. After " |
| 137 << "BrowserContextKeyedService::Shutdown() completes, your " | 133 << "BrowserContextKeyedService::Shutdown() completes, your " |
| 138 << "service MUST NOT refer to depended BrowserContext " | 134 << "service MUST NOT refer to depended BrowserContext " |
| 139 << "services again."; | 135 << "services again."; |
| 140 } | 136 } |
| 141 } | 137 } |
| 138 |
| 139 void BrowserContextDependencyManager::MarkBrowserContextLiveForTesting( |
| 140 content::BrowserContext* context) { |
| 141 dead_context_pointers_.erase(context); |
| 142 } |
| 142 #endif | 143 #endif |
| 143 | 144 |
| 144 // static | 145 // static |
| 145 BrowserContextDependencyManager* | 146 BrowserContextDependencyManager* |
| 146 BrowserContextDependencyManager::GetInstance() { | 147 BrowserContextDependencyManager::GetInstance() { |
| 147 return Singleton<BrowserContextDependencyManager>::get(); | 148 return Singleton<BrowserContextDependencyManager>::get(); |
| 148 } | 149 } |
| 149 | 150 |
| 150 BrowserContextDependencyManager::BrowserContextDependencyManager() { | 151 BrowserContextDependencyManager::BrowserContextDependencyManager() { |
| 151 } | 152 } |
| (...skipping 18 matching lines...) Expand all Loading... |
| 170 kDumpBrowserContextDependencyGraphFlag)) { | 171 kDumpBrowserContextDependencyGraphFlag)) { |
| 171 base::FilePath dot_file = | 172 base::FilePath dot_file = |
| 172 context->GetPath().AppendASCII("browser-context-dependencies.dot"); | 173 context->GetPath().AppendASCII("browser-context-dependencies.dot"); |
| 173 std::string contents = dependency_graph_.DumpAsGraphviz( | 174 std::string contents = dependency_graph_.DumpAsGraphviz( |
| 174 "BrowserContext", | 175 "BrowserContext", |
| 175 base::Bind(&BrowserContextKeyedBaseFactoryGetNodeName)); | 176 base::Bind(&BrowserContextKeyedBaseFactoryGetNodeName)); |
| 176 file_util::WriteFile(dot_file, contents.c_str(), contents.size()); | 177 file_util::WriteFile(dot_file, contents.c_str(), contents.size()); |
| 177 } | 178 } |
| 178 } | 179 } |
| 179 #endif // NDEBUG | 180 #endif // NDEBUG |
| OLD | NEW |