| 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/background/background_contents_service_factory.h" | 11 #include "chrome/browser/background/background_contents_service_factory.h" |
| 12 #include "chrome/browser/plugin_prefs.h" |
| 12 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service_factory.
h" | 13 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service_factory.
h" |
| 13 #include "chrome/browser/profiles/profile_keyed_service.h" | 14 #include "chrome/browser/profiles/profile_keyed_service.h" |
| 14 #include "chrome/browser/profiles/profile_keyed_service_factory.h" | 15 #include "chrome/browser/profiles/profile_keyed_service_factory.h" |
| 15 #include "chrome/browser/search_engines/template_url_service_factory.h" | 16 #include "chrome/browser/search_engines/template_url_service_factory.h" |
| 16 #include "chrome/browser/sessions/session_service_factory.h" | 17 #include "chrome/browser/sessions/session_service_factory.h" |
| 17 #include "chrome/browser/sessions/tab_restore_service_factory.h" | 18 #include "chrome/browser/sessions/tab_restore_service_factory.h" |
| 18 #include "content/common/notification_service.h" | 19 #include "content/common/notification_service.h" |
| 19 | 20 |
| 20 class Profile; | 21 class Profile; |
| 21 | 22 |
| 22 namespace { | 23 namespace { |
| 23 | 24 |
| 24 bool g_initialized = false; | 25 bool g_initialized = false; |
| 25 | 26 |
| 26 // This method gets the instance of each ServiceFactory. We do this so that | 27 // This method gets the instance of each ServiceFactory. We do this so that |
| 27 // each ServiceFactory initializes iteslf and registers its dependencies with | 28 // each ServiceFactory initializes iteslf and registers its dependencies with |
| 28 // the global PreferenceDependencyManager. We need to have a complete | 29 // the global PreferenceDependencyManager. We need to have a complete |
| 29 // dependency graph when we create a profile so we can dispatch the profile | 30 // dependency graph when we create a profile so we can dispatch the profile |
| 30 // creation message to the services that want to create their services at | 31 // creation message to the services that want to create their services at |
| 31 // profile creation time. | 32 // profile creation time. |
| 32 // | 33 // |
| 33 // TODO(erg): This needs to be something else. I don't think putting every | 34 // TODO(erg): This needs to be something else. I don't think putting every |
| 34 // FooServiceFactory here will scale or is desireable long term. | 35 // FooServiceFactory here will scale or is desireable long term. |
| 35 void AssertFactoriesBuilt() { | 36 void AssertFactoriesBuilt() { |
| 36 if (!g_initialized) { | 37 if (!g_initialized) { |
| 37 BackgroundContentsServiceFactory::GetInstance(); | 38 BackgroundContentsServiceFactory::GetInstance(); |
| 38 CloudPrintProxyServiceFactory::GetInstance(); | 39 CloudPrintProxyServiceFactory::GetInstance(); |
| 40 PluginPrefs::Initialize(); |
| 39 SessionServiceFactory::GetInstance(); | 41 SessionServiceFactory::GetInstance(); |
| 40 TabRestoreServiceFactory::GetInstance(); | 42 TabRestoreServiceFactory::GetInstance(); |
| 41 TemplateURLServiceFactory::GetInstance(); | 43 TemplateURLServiceFactory::GetInstance(); |
| 42 | 44 |
| 43 g_initialized = true; | 45 g_initialized = true; |
| 44 } | 46 } |
| 45 } | 47 } |
| 46 | 48 |
| 47 } // namespace | 49 } // namespace |
| 48 | 50 |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 } | 191 } |
| 190 } | 192 } |
| 191 | 193 |
| 192 if (edges.size()) { | 194 if (edges.size()) { |
| 193 NOTREACHED() << "Dependency graph has a cycle. We are doomed."; | 195 NOTREACHED() << "Dependency graph has a cycle. We are doomed."; |
| 194 } | 196 } |
| 195 | 197 |
| 196 std::reverse(output.begin(), output.end()); | 198 std::reverse(output.begin(), output.end()); |
| 197 destruction_order_ = output; | 199 destruction_order_ = output; |
| 198 } | 200 } |
| OLD | NEW |