Index: chrome/browser/profiles/chrome_browser_main_extra_parts_profiles.cc |
diff --git a/chrome/browser/profiles/profile_dependency_manager.cc b/chrome/browser/profiles/chrome_browser_main_extra_parts_profiles.cc |
similarity index 72% |
copy from chrome/browser/profiles/profile_dependency_manager.cc |
copy to chrome/browser/profiles/chrome_browser_main_extra_parts_profiles.cc |
index 93e7610d47e60c5e011b37f88038d98b0ab51988..d1dee568f262ba4afa2941cad2907253a852dd12 100644 |
--- a/chrome/browser/profiles/profile_dependency_manager.cc |
+++ b/chrome/browser/profiles/chrome_browser_main_extra_parts_profiles.cc |
@@ -1,12 +1,8 @@ |
-// Copyright (c) 2013 The Chromium Authors. All rights reserved. |
+// Copyright 2013 The Chromium Authors. All rights reserved. |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
-#include "chrome/browser/profiles/profile_dependency_manager.h" |
- |
-#include <algorithm> |
-#include <deque> |
-#include <iterator> |
+#include "chrome/browser/profiles/chrome_browser_main_extra_parts_profiles.h" |
#include "apps/app_restore_service_factory.h" |
#include "apps/shortcut_manager_factory.h" |
@@ -14,6 +10,7 @@ |
#include "chrome/browser/autofill/personal_data_manager_factory.h" |
#include "chrome/browser/background/background_contents_service_factory.h" |
#include "chrome/browser/bookmarks/bookmark_model_factory.h" |
+#include "chrome/browser/chrome_browser_main.h" |
#include "chrome/browser/content_settings/cookie_settings.h" |
#include "chrome/browser/custom_handlers/protocol_handler_registry_factory.h" |
#include "chrome/browser/download/download_service_factory.h" |
@@ -66,9 +63,6 @@ |
#include "chrome/browser/prerender/prerender_manager_factory.h" |
#include "chrome/browser/printing/cloud_print/cloud_print_proxy_service_factory.h" |
#include "chrome/browser/profiles/gaia_info_update_service_factory.h" |
-#include "chrome/browser/profiles/profile.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_fetcher_factory.h" |
#include "chrome/browser/search_engines/template_url_service_factory.h" |
#include "chrome/browser/sessions/session_service_factory.h" |
@@ -122,117 +116,20 @@ |
#include "chrome/browser/notifications/sync_notifier/chrome_notifier_service_factory.h" |
#endif |
-#ifndef NDEBUG |
-#include "base/command_line.h" |
-#include "base/file_util.h" |
-#include "chrome/common/chrome_switches.h" |
-#endif |
- |
-class Profile; |
+namespace chrome { |
-void ProfileDependencyManager::AddComponent( |
- ProfileKeyedBaseFactory* component) { |
- dependency_graph_.AddNode(component); |
+void AddProfilesExtraParts(ChromeBrowserMainParts* main_parts) { |
+ main_parts->AddParts(new ChromeBrowserMainExtraPartsProfiles()); |
} |
-void ProfileDependencyManager::RemoveComponent( |
- ProfileKeyedBaseFactory* component) { |
- dependency_graph_.RemoveNode(component); |
-} |
+} // namespace chrome |
-void ProfileDependencyManager::AddEdge(ProfileKeyedBaseFactory* depended, |
- ProfileKeyedBaseFactory* dependee) { |
- dependency_graph_.AddEdge(depended, dependee); |
+ChromeBrowserMainExtraPartsProfiles::ChromeBrowserMainExtraPartsProfiles() { |
} |
-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(); |
- |
- std::vector<DependencyNode*> construction_order; |
- if (!dependency_graph_.GetConstructionOrder(&construction_order)) { |
- NOTREACHED(); |
- } |
- |
-#ifndef NDEBUG |
- DumpProfileDependencies(profile); |
-#endif |
- |
- for (size_t i = 0; i < construction_order.size(); i++) { |
- ProfileKeyedBaseFactory* factory = |
- static_cast<ProfileKeyedBaseFactory*>(construction_order[i]); |
- |
- if (!profile->IsOffTheRecord()) { |
- // We only register preferences on normal profiles because the incognito |
- // profile shares the pref service with the normal one. |
- factory->RegisterUserPrefsOnProfile(profile); |
- } |
- |
- if (is_testing_profile && factory->ServiceIsNULLWhileTesting()) { |
- factory->SetEmptyTestingFactory(profile); |
- } else if (factory->ServiceIsCreatedWithProfile()) { |
- // Create the service. |
- factory->CreateServiceNow(profile); |
- } |
- } |
+ChromeBrowserMainExtraPartsProfiles::~ChromeBrowserMainExtraPartsProfiles() { |
} |
-void ProfileDependencyManager::DestroyProfileServices(Profile* profile) { |
- std::vector<DependencyNode*> destruction_order; |
- if (!dependency_graph_.GetDestructionOrder(&destruction_order)) { |
- NOTREACHED(); |
- } |
- |
-#ifndef NDEBUG |
- DumpProfileDependencies(profile); |
-#endif |
- |
- for (size_t i = 0; i < destruction_order.size(); i++) { |
- ProfileKeyedBaseFactory* factory = |
- static_cast<ProfileKeyedBaseFactory*>(destruction_order[i]); |
- factory->ProfileShutdown(profile); |
- } |
- |
-#ifndef NDEBUG |
- // The profile is now dead to the rest of the program. |
- dead_profile_pointers_.insert(profile); |
-#endif |
- |
- for (size_t i = 0; i < destruction_order.size(); i++) { |
- ProfileKeyedBaseFactory* factory = |
- static_cast<ProfileKeyedBaseFactory*>(destruction_order[i]); |
- factory->ProfileDestroyed(profile); |
- } |
-} |
- |
-#ifndef NDEBUG |
-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 " |
- << "is most likely a heap smasher in progress. After " |
- << "ProfileKeyedService::Shutdown() completes, your service " |
- << "MUST NOT refer to depended Profile services again."; |
- } |
-} |
-#endif |
- |
-// static |
-ProfileDependencyManager* ProfileDependencyManager::GetInstance() { |
- return Singleton<ProfileDependencyManager>::get(); |
-} |
- |
-ProfileDependencyManager::ProfileDependencyManager() : built_factories_(false) { |
-} |
- |
-ProfileDependencyManager::~ProfileDependencyManager() {} |
- |
// This method gets the instance of each ServiceFactory. We do this so that |
// each ServiceFactory initializes itself and registers its dependencies with |
// the global PreferenceDependencyManager. We need to have a complete |
@@ -242,10 +139,10 @@ ProfileDependencyManager::~ProfileDependencyManager() {} |
// |
// TODO(erg): This needs to be something else. I don't think putting every |
// FooServiceFactory here will scale or is desirable long term. |
-void ProfileDependencyManager::AssertFactoriesBuilt() { |
- if (built_factories_) |
- return; |
- |
+// |
+// static |
+void |
+ChromeBrowserMainExtraPartsProfiles::EnsureProfileKeyedServiceFactoriesBuilt() { |
AboutSigninInternalsFactory::GetInstance(); |
#if defined(ENABLE_BACKGROUND) |
@@ -378,29 +275,8 @@ void ProfileDependencyManager::AssertFactoriesBuilt() { |
UserStyleSheetWatcherFactory::GetInstance(); |
#endif |
WebDataServiceFactory::GetInstance(); |
- |
- built_factories_ = true; |
} |
-#ifndef NDEBUG |
-namespace { |
- |
-std::string ProfileKeyedBaseFactoryGetNodeName(DependencyNode* node) { |
- return static_cast<ProfileKeyedBaseFactory*>(node)->name(); |
-} |
- |
-} // namespace |
- |
-void ProfileDependencyManager::DumpProfileDependencies(Profile* profile) { |
- // Whenever we try to build a destruction ordering, we should also dump a |
- // dependency graph to "/path/to/profile/profile-dependencies.dot". |
- if (CommandLine::ForCurrentProcess()->HasSwitch( |
- switches::kDumpProfileDependencyGraph)) { |
- base::FilePath dot_file = |
- profile->GetPath().AppendASCII("profile-dependencies.dot"); |
- std::string contents = dependency_graph_.DumpAsGraphviz( |
- "Profile", base::Bind(&ProfileKeyedBaseFactoryGetNodeName)); |
- file_util::WriteFile(dot_file, contents.c_str(), contents.size()); |
- } |
+void ChromeBrowserMainExtraPartsProfiles::PreProfileInit() { |
+ EnsureProfileKeyedServiceFactoriesBuilt(); |
} |
-#endif // NDEBUG |