| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/keyed_service/content/browser_context_dependency_manager.h" | 5 #include "components/keyed_service/content/browser_context_dependency_manager.h" |
| 6 | 6 |
| 7 #include "base/memory/singleton.h" | 7 #include "base/memory/singleton.h" |
| 8 #include "base/trace_event/trace_event.h" | 8 #include "base/trace_event/trace_event.h" |
| 9 #include "content/public/browser/browser_context.h" | 9 #include "content/public/browser/browser_context.h" |
| 10 | 10 |
| 11 #ifndef NDEBUG | 11 #ifndef NDEBUG |
| 12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
| 13 #include "base/files/file_util.h" | 13 #include "base/files/file_util.h" |
| 14 | 14 |
| 15 // Dumps dependency information about our browser context keyed services | 15 // Dumps dependency information about our browser context keyed services |
| 16 // into a dot file in the browser context directory. | 16 // into a dot file in the browser context directory. |
| 17 const char kDumpBrowserContextDependencyGraphFlag[] = | 17 const char kDumpBrowserContextDependencyGraphFlag[] = |
| 18 "dump-browser-context-graph"; | 18 "dump-browser-context-graph"; |
| 19 #endif // NDEBUG | 19 #endif // NDEBUG |
| 20 | 20 |
| 21 void BrowserContextDependencyManager::RegisterProfilePrefsForServices( | 21 void BrowserContextDependencyManager::RegisterProfilePrefsForServices( |
| 22 const content::BrowserContext* context, | 22 content::BrowserContext* context, |
| 23 user_prefs::PrefRegistrySyncable* pref_registry) { | 23 user_prefs::PrefRegistrySyncable* pref_registry) { |
| 24 TRACE_EVENT0( | 24 TRACE_EVENT0( |
| 25 "browser", | 25 "browser", |
| 26 "BrowserContextDependencyManager::RegisterProfilePrefsForServices"); | 26 "BrowserContextDependencyManager::RegisterProfilePrefsForServices"); |
| 27 RegisterPrefsForServices(context, pref_registry); | 27 RegisterPrefsForServices(context, pref_registry); |
| 28 } | 28 } |
| 29 | 29 |
| 30 void BrowserContextDependencyManager::CreateBrowserContextServices( | 30 void BrowserContextDependencyManager::CreateBrowserContextServices( |
| 31 content::BrowserContext* context) { | 31 content::BrowserContext* context) { |
| 32 DoCreateBrowserContextServices(context, false); | 32 DoCreateBrowserContextServices(context, false); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 DependencyManager::MarkContextLiveForTesting(context); | 70 DependencyManager::MarkContextLiveForTesting(context); |
| 71 } | 71 } |
| 72 #endif // NDEBUG | 72 #endif // NDEBUG |
| 73 | 73 |
| 74 // static | 74 // static |
| 75 BrowserContextDependencyManager* | 75 BrowserContextDependencyManager* |
| 76 BrowserContextDependencyManager::GetInstance() { | 76 BrowserContextDependencyManager::GetInstance() { |
| 77 return Singleton<BrowserContextDependencyManager>::get(); | 77 return Singleton<BrowserContextDependencyManager>::get(); |
| 78 } | 78 } |
| 79 | 79 |
| 80 BrowserContextDependencyManager::BrowserContextDependencyManager() {} | 80 BrowserContextDependencyManager::BrowserContextDependencyManager() { |
| 81 } |
| 81 | 82 |
| 82 BrowserContextDependencyManager::~BrowserContextDependencyManager() {} | 83 BrowserContextDependencyManager::~BrowserContextDependencyManager() { |
| 84 } |
| 83 | 85 |
| 84 #ifndef NDEBUG | 86 #ifndef NDEBUG |
| 85 void BrowserContextDependencyManager::DumpContextDependencies( | 87 void BrowserContextDependencyManager::DumpContextDependencies( |
| 86 const base::SupportsUserData* context) const { | 88 base::SupportsUserData* context) const { |
| 87 // Whenever we try to build a destruction ordering, we should also dump a | 89 // Whenever we try to build a destruction ordering, we should also dump a |
| 88 // dependency graph to "/path/to/context/context-dependencies.dot". | 90 // dependency graph to "/path/to/context/context-dependencies.dot". |
| 89 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 91 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 90 kDumpBrowserContextDependencyGraphFlag)) { | 92 kDumpBrowserContextDependencyGraphFlag)) { |
| 91 base::FilePath dot_file = | 93 base::FilePath dot_file = |
| 92 static_cast<const content::BrowserContext*>(context) | 94 static_cast<const content::BrowserContext*>(context) |
| 93 ->GetPath() | 95 ->GetPath() |
| 94 .AppendASCII("browser-context-dependencies.dot"); | 96 .AppendASCII("browser-context-dependencies.dot"); |
| 95 DumpDependenciesAsGraphviz("BrowserContext", dot_file); | 97 DumpDependenciesAsGraphviz("BrowserContext", dot_file); |
| 96 } | 98 } |
| 97 } | 99 } |
| 98 #endif // NDEBUG | 100 #endif // NDEBUG |
| OLD | NEW |