| 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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 } | 57 } |
| 58 | 58 |
| 59 #ifndef NDEBUG | 59 #ifndef NDEBUG |
| 60 DumpBrowserContextDependencies(context); | 60 DumpBrowserContextDependencies(context); |
| 61 #endif | 61 #endif |
| 62 | 62 |
| 63 for (size_t i = 0; i < construction_order.size(); i++) { | 63 for (size_t i = 0; i < construction_order.size(); i++) { |
| 64 BrowserContextKeyedBaseFactory* factory = | 64 BrowserContextKeyedBaseFactory* factory = |
| 65 static_cast<BrowserContextKeyedBaseFactory*>(construction_order[i]); | 65 static_cast<BrowserContextKeyedBaseFactory*>(construction_order[i]); |
| 66 | 66 |
| 67 if (!context->IsOffTheRecord()) { | 67 if (is_testing_context || !context->IsOffTheRecord()) { |
| 68 // We only register preferences on normal contexts because the incognito | 68 // We only register preferences on normal contexts because the incognito |
| 69 // context shares the pref service with the normal one. | 69 // context shares the pref service with the normal one. Always register |
| 70 // for testing contexts, because they often are created standalone |
| 71 // without an associated "normal" context. |
| 70 factory->RegisterUserPrefsOnBrowserContext(context); | 72 factory->RegisterUserPrefsOnBrowserContext(context); |
| 71 } | 73 } |
| 72 | 74 |
| 73 if (is_testing_context && factory->ServiceIsNULLWhileTesting()) { | 75 if (is_testing_context && factory->ServiceIsNULLWhileTesting()) { |
| 74 factory->SetEmptyTestingFactory(context); | 76 factory->SetEmptyTestingFactory(context); |
| 75 } else if (factory->ServiceIsCreatedWithBrowserContext()) { | 77 } else if (factory->ServiceIsCreatedWithBrowserContext()) { |
| 76 // Create the service. | 78 // Create the service. |
| 77 factory->CreateServiceNow(context); | 79 factory->CreateServiceNow(context); |
| 78 } | 80 } |
| 79 } | 81 } |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 kDumpBrowserContextDependencyGraphFlag)) { | 152 kDumpBrowserContextDependencyGraphFlag)) { |
| 151 base::FilePath dot_file = | 153 base::FilePath dot_file = |
| 152 context->GetPath().AppendASCII("browser-context-dependencies.dot"); | 154 context->GetPath().AppendASCII("browser-context-dependencies.dot"); |
| 153 std::string contents = dependency_graph_.DumpAsGraphviz( | 155 std::string contents = dependency_graph_.DumpAsGraphviz( |
| 154 "BrowserContext", | 156 "BrowserContext", |
| 155 base::Bind(&BrowserContextKeyedBaseFactoryGetNodeName)); | 157 base::Bind(&BrowserContextKeyedBaseFactoryGetNodeName)); |
| 156 file_util::WriteFile(dot_file, contents.c_str(), contents.size()); | 158 file_util::WriteFile(dot_file, contents.c_str(), contents.size()); |
| 157 } | 159 } |
| 158 } | 160 } |
| 159 #endif // NDEBUG | 161 #endif // NDEBUG |
| OLD | NEW |