Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/autofill/personal_data_manager_factory.h" | 11 #include "chrome/browser/autofill/personal_data_manager_factory.h" |
| 12 #include "chrome/browser/background/background_contents_service_factory.h" | 12 #include "chrome/browser/background/background_contents_service_factory.h" |
| 13 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 13 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
| 14 #if defined(OS_CHROMEOS) | |
| 15 #include "chrome/browser/chromeos/session_length_limiter_factory.h" | |
| 16 #endif | |
|
Mattias Nissler (ping if slow)
2012/12/12 10:12:57
By convention, conditional includes go below the m
bartfab (slow)
2012/12/13 16:22:48
Done.
| |
| 14 #include "chrome/browser/content_settings/cookie_settings.h" | 17 #include "chrome/browser/content_settings/cookie_settings.h" |
| 15 #include "chrome/browser/custom_handlers/protocol_handler_registry_factory.h" | 18 #include "chrome/browser/custom_handlers/protocol_handler_registry_factory.h" |
| 16 #include "chrome/browser/download/download_service_factory.h" | 19 #include "chrome/browser/download/download_service_factory.h" |
| 17 #include "chrome/browser/extensions/api/bluetooth/bluetooth_api_factory.h" | 20 #include "chrome/browser/extensions/api/bluetooth/bluetooth_api_factory.h" |
| 18 #include "chrome/browser/extensions/api/commands/command_service_factory.h" | 21 #include "chrome/browser/extensions/api/commands/command_service_factory.h" |
| 19 #include "chrome/browser/extensions/api/cookies/cookies_api_factory.h" | 22 #include "chrome/browser/extensions/api/cookies/cookies_api_factory.h" |
| 20 #include "chrome/browser/extensions/api/dial/dial_api_factory.h" | 23 #include "chrome/browser/extensions/api/dial/dial_api_factory.h" |
| 21 #include "chrome/browser/extensions/api/discovery/suggested_links_registry_facto ry.h" | 24 #include "chrome/browser/extensions/api/discovery/suggested_links_registry_facto ry.h" |
| 22 #include "chrome/browser/extensions/api/font_settings/font_settings_api_factory. h" | 25 #include "chrome/browser/extensions/api/font_settings/font_settings_api_factory. h" |
| 23 #include "chrome/browser/extensions/api/idle/idle_manager_factory.h" | 26 #include "chrome/browser/extensions/api/idle/idle_manager_factory.h" |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 189 return Singleton<ProfileDependencyManager>::get(); | 192 return Singleton<ProfileDependencyManager>::get(); |
| 190 } | 193 } |
| 191 | 194 |
| 192 ProfileDependencyManager::ProfileDependencyManager() | 195 ProfileDependencyManager::ProfileDependencyManager() |
| 193 : built_factories_(false) { | 196 : built_factories_(false) { |
| 194 } | 197 } |
| 195 | 198 |
| 196 ProfileDependencyManager::~ProfileDependencyManager() {} | 199 ProfileDependencyManager::~ProfileDependencyManager() {} |
| 197 | 200 |
| 198 // This method gets the instance of each ServiceFactory. We do this so that | 201 // This method gets the instance of each ServiceFactory. We do this so that |
| 199 // each ServiceFactory initializes iteslf and registers its dependencies with | 202 // each ServiceFactory initializes itself and registers its dependencies with |
| 200 // the global PreferenceDependencyManager. We need to have a complete | 203 // the global PreferenceDependencyManager. We need to have a complete |
| 201 // dependency graph when we create a profile so we can dispatch the profile | 204 // dependency graph when we create a profile so we can dispatch the profile |
| 202 // creation message to the services that want to create their services at | 205 // creation message to the services that want to create their services at |
| 203 // profile creation time. | 206 // profile creation time. |
| 204 // | 207 // |
| 205 // TODO(erg): This needs to be something else. I don't think putting every | 208 // TODO(erg): This needs to be something else. I don't think putting every |
| 206 // FooServiceFactory here will scale or is desireable long term. | 209 // FooServiceFactory here will scale or is desirable long term. |
| 207 void ProfileDependencyManager::AssertFactoriesBuilt() { | 210 void ProfileDependencyManager::AssertFactoriesBuilt() { |
| 208 if (built_factories_) | 211 if (built_factories_) |
| 209 return; | 212 return; |
| 210 | 213 |
| 211 #if defined(ENABLE_BACKGROUND) | 214 #if defined(ENABLE_BACKGROUND) |
| 212 BackgroundContentsServiceFactory::GetInstance(); | 215 BackgroundContentsServiceFactory::GetInstance(); |
| 213 #endif | 216 #endif |
| 214 BookmarkModelFactory::GetInstance(); | 217 BookmarkModelFactory::GetInstance(); |
| 215 #if defined(ENABLE_CAPTIVE_PORTAL_DETECTION) | 218 #if defined(ENABLE_CAPTIVE_PORTAL_DETECTION) |
| 216 captive_portal::CaptivePortalServiceFactory::GetInstance(); | 219 captive_portal::CaptivePortalServiceFactory::GetInstance(); |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 287 #if defined(ENABLE_THEMES) | 290 #if defined(ENABLE_THEMES) |
| 288 ThemeServiceFactory::GetInstance(); | 291 ThemeServiceFactory::GetInstance(); |
| 289 #endif | 292 #endif |
| 290 TokenServiceFactory::GetInstance(); | 293 TokenServiceFactory::GetInstance(); |
| 291 UserStyleSheetWatcherFactory::GetInstance(); | 294 UserStyleSheetWatcherFactory::GetInstance(); |
| 292 VisitedLinkMasterFactory::GetInstance(); | 295 VisitedLinkMasterFactory::GetInstance(); |
| 293 WebDataServiceFactory::GetInstance(); | 296 WebDataServiceFactory::GetInstance(); |
| 294 #if defined(ENABLE_WEB_INTENTS) | 297 #if defined(ENABLE_WEB_INTENTS) |
| 295 WebIntentsRegistryFactory::GetInstance(); | 298 WebIntentsRegistryFactory::GetInstance(); |
| 296 #endif | 299 #endif |
| 300 #if defined(OS_CHROMEOS) | |
| 301 chromeos::SessionLengthLimiterFactory::GetInstance(); | |
| 302 #endif | |
| 297 | 303 |
| 298 built_factories_ = true; | 304 built_factories_ = true; |
| 299 } | 305 } |
| 300 | 306 |
| 301 void ProfileDependencyManager::BuildDestructionOrder(Profile* profile) { | 307 void ProfileDependencyManager::BuildDestructionOrder(Profile* profile) { |
| 302 #if !defined(NDEBUG) | 308 #if !defined(NDEBUG) |
| 303 // Whenever we try to build a destruction ordering, we should also dump a | 309 // Whenever we try to build a destruction ordering, we should also dump a |
| 304 // dependency graph to "/path/to/profile/profile-dependencies.dot". | 310 // dependency graph to "/path/to/profile/profile-dependencies.dot". |
| 305 if (CommandLine::ForCurrentProcess()->HasSwitch( | 311 if (CommandLine::ForCurrentProcess()->HasSwitch( |
| 306 switches::kDumpProfileDependencyGraph)) { | 312 switches::kDumpProfileDependencyGraph)) { |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 401 } | 407 } |
| 402 | 408 |
| 403 result.append("\n /* Toplevel profile */\n"); | 409 result.append("\n /* Toplevel profile */\n"); |
| 404 result.append(" Profile [shape=box];\n"); | 410 result.append(" Profile [shape=box];\n"); |
| 405 | 411 |
| 406 result.append("}\n"); | 412 result.append("}\n"); |
| 407 return result; | 413 return result; |
| 408 } | 414 } |
| 409 | 415 |
| 410 #endif | 416 #endif |
| OLD | NEW |