| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/browser/profiles/profile_dependency_manager.h" | 5 #include "chrome/browser/profiles/profile_dependency_manager.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <deque> | 8 #include <deque> |
| 9 #include <iterator> | 9 #include <iterator> |
| 10 | 10 |
| 11 #include "chrome/browser/autocomplete/network_action_predictor_factory.h" | 11 #include "chrome/browser/autocomplete/network_action_predictor_factory.h" |
| 12 #include "chrome/browser/autofill/personal_data_manager_factory.h" | 12 #include "chrome/browser/autofill/personal_data_manager_factory.h" |
| 13 #include "chrome/browser/background/background_contents_service_factory.h" | 13 #include "chrome/browser/background/background_contents_service_factory.h" |
| 14 #include "chrome/browser/content_settings/cookie_settings.h" | 14 #include "chrome/browser/content_settings/cookie_settings.h" |
| 15 #include "chrome/browser/plugin_prefs_factory.h" | 15 #include "chrome/browser/plugin_prefs_factory.h" |
| 16 #include "chrome/browser/prerender/prerender_manager_factory.h" | 16 #include "chrome/browser/prerender/prerender_manager_factory.h" |
| 17 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service_factory.
h" | 17 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service_factory.
h" |
| 18 #include "chrome/browser/profiles/profile.h" | 18 #include "chrome/browser/profiles/profile.h" |
| 19 #include "chrome/browser/profiles/profile_keyed_service.h" | 19 #include "chrome/browser/profiles/profile_keyed_service.h" |
| 20 #include "chrome/browser/profiles/profile_keyed_service_factory.h" | 20 #include "chrome/browser/profiles/profile_keyed_service_factory.h" |
| 21 #include "chrome/browser/search_engines/template_url_service_factory.h" | 21 #include "chrome/browser/search_engines/template_url_service_factory.h" |
| 22 #include "chrome/browser/sessions/session_service_factory.h" | 22 #include "chrome/browser/sessions/session_service_factory.h" |
| 23 #include "chrome/browser/sessions/tab_restore_service_factory.h" | 23 #include "chrome/browser/sessions/tab_restore_service_factory.h" |
| 24 #include "chrome/browser/speech/speech_input_extension_manager.h" | 24 #include "chrome/browser/speech/speech_input_extension_manager.h" |
| 25 #include "chrome/browser/sync/profile_sync_service_factory.h" |
| 25 | 26 |
| 26 class Profile; | 27 class Profile; |
| 27 | 28 |
| 28 namespace { | 29 namespace { |
| 29 | 30 |
| 30 bool g_initialized = false; | 31 bool g_initialized = false; |
| 31 | 32 |
| 32 // This method gets the instance of each ServiceFactory. We do this so that | 33 // This method gets the instance of each ServiceFactory. We do this so that |
| 33 // each ServiceFactory initializes iteslf and registers its dependencies with | 34 // each ServiceFactory initializes iteslf and registers its dependencies with |
| 34 // the global PreferenceDependencyManager. We need to have a complete | 35 // the global PreferenceDependencyManager. We need to have a complete |
| 35 // dependency graph when we create a profile so we can dispatch the profile | 36 // dependency graph when we create a profile so we can dispatch the profile |
| 36 // creation message to the services that want to create their services at | 37 // creation message to the services that want to create their services at |
| 37 // profile creation time. | 38 // profile creation time. |
| 38 // | 39 // |
| 39 // TODO(erg): This needs to be something else. I don't think putting every | 40 // TODO(erg): This needs to be something else. I don't think putting every |
| 40 // FooServiceFactory here will scale or is desireable long term. | 41 // FooServiceFactory here will scale or is desireable long term. |
| 41 void AssertFactoriesBuilt() { | 42 void AssertFactoriesBuilt() { |
| 42 if (!g_initialized) { | 43 if (!g_initialized) { |
| 43 BackgroundContentsServiceFactory::GetInstance(); | 44 BackgroundContentsServiceFactory::GetInstance(); |
| 44 CloudPrintProxyServiceFactory::GetInstance(); | 45 CloudPrintProxyServiceFactory::GetInstance(); |
| 45 CookieSettings::Factory::GetInstance(); | 46 CookieSettings::Factory::GetInstance(); |
| 46 NetworkActionPredictorFactory::GetInstance(); | 47 NetworkActionPredictorFactory::GetInstance(); |
| 47 PersonalDataManagerFactory::GetInstance(); | 48 PersonalDataManagerFactory::GetInstance(); |
| 48 PluginPrefsFactory::GetInstance(); | 49 PluginPrefsFactory::GetInstance(); |
| 49 prerender::PrerenderManagerFactory::GetInstance(); | 50 prerender::PrerenderManagerFactory::GetInstance(); |
| 51 ProfileSyncServiceFactory::GetInstance(); |
| 50 SessionServiceFactory::GetInstance(); | 52 SessionServiceFactory::GetInstance(); |
| 51 SpeechInputExtensionManager::InitializeFactory(); | 53 SpeechInputExtensionManager::InitializeFactory(); |
| 52 TabRestoreServiceFactory::GetInstance(); | 54 TabRestoreServiceFactory::GetInstance(); |
| 53 TemplateURLServiceFactory::GetInstance(); | 55 TemplateURLServiceFactory::GetInstance(); |
| 54 | 56 |
| 55 g_initialized = true; | 57 g_initialized = true; |
| 56 } | 58 } |
| 57 } | 59 } |
| 58 | 60 |
| 59 } // namespace | 61 } // namespace |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 } | 210 } |
| 209 } | 211 } |
| 210 | 212 |
| 211 if (edges.size()) { | 213 if (edges.size()) { |
| 212 NOTREACHED() << "Dependency graph has a cycle. We are doomed."; | 214 NOTREACHED() << "Dependency graph has a cycle. We are doomed."; |
| 213 } | 215 } |
| 214 | 216 |
| 215 std::reverse(output.begin(), output.end()); | 217 std::reverse(output.begin(), output.end()); |
| 216 destruction_order_ = output; | 218 destruction_order_ = output; |
| 217 } | 219 } |
| OLD | NEW |