Index: chrome/browser/profiles/profile_dependency_manager.cc |
diff --git a/chrome/browser/profiles/profile_dependency_manager.cc b/chrome/browser/profiles/profile_dependency_manager.cc |
index e6479ad3aae9aaaa4d07b36d41ca72c67510c457..352ee77d5022742b7eb2e99a2294b33f0b437584 100644 |
--- a/chrome/browser/profiles/profile_dependency_manager.cc |
+++ b/chrome/browser/profiles/profile_dependency_manager.cc |
@@ -8,12 +8,35 @@ |
#include <deque> |
#include <iterator> |
+#include "chrome/browser/background/background_contents_service_factory.h" |
#include "chrome/browser/profiles/profile_keyed_service.h" |
#include "chrome/browser/profiles/profile_keyed_service_factory.h" |
+#include "chrome/browser/search_engines/template_url_service_factory.h" |
+#include "chrome/browser/sessions/session_service_factory.h" |
+#include "chrome/browser/sessions/tab_restore_service_factory.h" |
#include "content/common/notification_service.h" |
class Profile; |
+namespace { |
+ |
+bool g_initialized = false; |
+ |
+// TODO(erg): This needs to be something else. I don't think putting every |
+// FooServiceFactory here will scale or is desireable long term. |
Miranda Callahan
2011/07/20 20:53:09
Could you also add a comment here describing the f
|
+void AssertFactoriesBuilt() { |
+ if (!g_initialized) { |
+ BackgroundContentsServiceFactory::GetInstance(); |
+ SessionServiceFactory::GetInstance(); |
+ TabRestoreServiceFactory::GetInstance(); |
+ TemplateURLServiceFactory::GetInstance(); |
+ |
+ g_initialized = true; |
+ } |
+} |
+ |
+} // namespace |
+ |
void ProfileDependencyManager::AddComponent( |
ProfileKeyedServiceFactory* component) { |
all_components_.push_back(component); |
@@ -46,6 +69,33 @@ void ProfileDependencyManager::AddEdge(ProfileKeyedServiceFactory* depended, |
destruction_order_.clear(); |
} |
+void ProfileDependencyManager::CreateProfileServices(Profile* profile, |
+ bool is_testing_profile) { |
+#ifndef NDEBUG |
+ // Unmark |profile| as dead. This exists because of unit tests, which will |
+ // often have similar stack structures. 0xWhatever might be created, go out |
+ // of scope, and then a new Profile object might be created at 0xWhatever. |
+ dead_profile_pointers_.erase(profile); |
+#endif |
+ |
+ AssertFactoriesBuilt(); |
+ |
+ if (destruction_order_.empty()) |
+ BuildDestructionOrder(); |
+ |
+ // Iterate in reverse destruction order for creation. |
+ for (std::vector<ProfileKeyedServiceFactory*>::reverse_iterator rit = |
+ destruction_order_.rbegin(); rit != destruction_order_.rend(); |
+ ++rit) { |
+ if (is_testing_profile && (*rit)->ServiceIsNULLWhileTesting()) { |
+ (*rit)->SetTestingFactory(profile, NULL); |
+ } else if ((*rit)->ServiceIsCreatedWithProfile()) { |
+ // Create the service. |
+ (*rit)->GetServiceForProfile(profile, true); |
+ } |
+ } |
+} |
+ |
void ProfileDependencyManager::DestroyProfileServices(Profile* profile) { |
if (destruction_order_.empty()) |
BuildDestructionOrder(); |
@@ -67,10 +117,6 @@ void ProfileDependencyManager::DestroyProfileServices(Profile* profile) { |
} |
#ifndef NDEBUG |
-void ProfileDependencyManager::ProfileNowExists(Profile* profile) { |
- dead_profile_pointers_.erase(profile); |
-} |
- |
void ProfileDependencyManager::AssertProfileWasntDestroyed(Profile* profile) { |
if (dead_profile_pointers_.find(profile) != dead_profile_pointers_.end()) { |
NOTREACHED() << "Attempted to access a Profile that was ShutDown(). This " |