OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "apps/app_restore_service_factory.h" | 11 #include "base/bind.h" |
12 #include "apps/shortcut_manager_factory.h" | 12 #include "chrome/browser/profiles/profile_keyed_base_factory.h" |
13 #include "chrome/browser/autofill/autocheckout_whitelist_manager_factory.h" | 13 #include "content/public/browser/browser_context.h" |
14 #include "chrome/browser/autofill/personal_data_manager_factory.h" | |
15 #include "chrome/browser/background/background_contents_service_factory.h" | |
16 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | |
17 #include "chrome/browser/content_settings/cookie_settings.h" | |
18 #include "chrome/browser/custom_handlers/protocol_handler_registry_factory.h" | |
19 #include "chrome/browser/download/download_service_factory.h" | |
20 #include "chrome/browser/extensions/activity_log.h" | |
21 #include "chrome/browser/extensions/api/alarms/alarm_manager.h" | |
22 #include "chrome/browser/extensions/api/audio/audio_api.h" | |
23 #include "chrome/browser/extensions/api/bluetooth/bluetooth_api_factory.h" | |
24 #include "chrome/browser/extensions/api/bookmarks/bookmarks_api.h" | |
25 #include "chrome/browser/extensions/api/commands/command_service.h" | |
26 #include "chrome/browser/extensions/api/cookies/cookies_api.h" | |
27 #include "chrome/browser/extensions/api/dial/dial_api_factory.h" | |
28 #include "chrome/browser/extensions/api/discovery/suggested_links_registry_facto
ry.h" | |
29 #include "chrome/browser/extensions/api/extension_action/extension_action_api.h" | |
30 #include "chrome/browser/extensions/api/font_settings/font_settings_api.h" | |
31 #include "chrome/browser/extensions/api/history/history_api.h" | |
32 #include "chrome/browser/extensions/api/identity/identity_api.h" | |
33 #include "chrome/browser/extensions/api/idle/idle_manager_factory.h" | |
34 #include "chrome/browser/extensions/api/input/input.h" | |
35 #include "chrome/browser/extensions/api/managed_mode_private/managed_mode_privat
e_api.h" | |
36 #include "chrome/browser/extensions/api/management/management_api.h" | |
37 #include "chrome/browser/extensions/api/media_galleries_private/media_galleries_
private_api.h" | |
38 #include "chrome/browser/extensions/api/omnibox/omnibox_api.h" | |
39 #include "chrome/browser/extensions/api/preference/preference_api.h" | |
40 #include "chrome/browser/extensions/api/processes/processes_api.h" | |
41 #include "chrome/browser/extensions/api/push_messaging/push_messaging_api.h" | |
42 #include "chrome/browser/extensions/api/session_restore/session_restore_api.h" | |
43 #include "chrome/browser/extensions/api/spellcheck/spellcheck_api.h" | |
44 #include "chrome/browser/extensions/api/streams_private/streams_private_api.h" | |
45 #include "chrome/browser/extensions/api/system_info/system_info_api.h" | |
46 #include "chrome/browser/extensions/api/tab_capture/tab_capture_registry_factory
.h" | |
47 #include "chrome/browser/extensions/api/tabs/tabs_windows_api.h" | |
48 #include "chrome/browser/extensions/api/web_navigation/web_navigation_api.h" | |
49 #include "chrome/browser/extensions/extension_system_factory.h" | |
50 #include "chrome/browser/extensions/extension_web_ui_override_registrar.h" | |
51 #include "chrome/browser/extensions/install_tracker_factory.h" | |
52 #include "chrome/browser/extensions/token_cache/token_cache_service_factory.h" | |
53 #include "chrome/browser/favicon/favicon_service_factory.h" | |
54 #include "chrome/browser/geolocation/chrome_geolocation_permission_context_facto
ry.h" | |
55 #include "chrome/browser/google/google_url_tracker_factory.h" | |
56 #include "chrome/browser/history/history_service_factory.h" | |
57 #include "chrome/browser/history/shortcuts_backend_factory.h" | |
58 #include "chrome/browser/notifications/desktop_notification_service_factory.h" | |
59 #include "chrome/browser/password_manager/password_store_factory.h" | |
60 #include "chrome/browser/plugins/plugin_prefs_factory.h" | |
61 #include "chrome/browser/policy/profile_policy_connector_factory.h" | |
62 #include "chrome/browser/predictors/autocomplete_action_predictor_factory.h" | |
63 #include "chrome/browser/predictors/predictor_database_factory.h" | |
64 #include "chrome/browser/predictors/resource_prefetch_predictor_factory.h" | |
65 #include "chrome/browser/prerender/prerender_link_manager_factory.h" | |
66 #include "chrome/browser/prerender/prerender_manager_factory.h" | |
67 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service_factory.
h" | |
68 #include "chrome/browser/profiles/gaia_info_update_service_factory.h" | |
69 #include "chrome/browser/profiles/profile.h" | |
70 #include "chrome/browser/profiles/profile_keyed_service.h" | |
71 #include "chrome/browser/profiles/profile_keyed_service_factory.h" | |
72 #include "chrome/browser/search_engines/template_url_fetcher_factory.h" | |
73 #include "chrome/browser/search_engines/template_url_service_factory.h" | |
74 #include "chrome/browser/sessions/session_service_factory.h" | |
75 #include "chrome/browser/sessions/tab_restore_service_factory.h" | |
76 #include "chrome/browser/signin/about_signin_internals_factory.h" | |
77 #include "chrome/browser/signin/signin_manager_factory.h" | |
78 #include "chrome/browser/signin/token_service_factory.h" | |
79 #include "chrome/browser/speech/chrome_speech_recognition_preferences.h" | |
80 #include "chrome/browser/speech/extension_api/tts_extension_api.h" | |
81 #include "chrome/browser/spellchecker/spellcheck_factory.h" | |
82 #include "chrome/browser/sync/profile_sync_service_factory.h" | |
83 #include "chrome/browser/themes/theme_service_factory.h" | |
84 #include "chrome/browser/thumbnails/thumbnail_service_factory.h" | |
85 #include "chrome/browser/ui/find_bar/find_bar_state_factory.h" | |
86 #include "chrome/browser/ui/global_error/global_error_service_factory.h" | |
87 #include "chrome/browser/ui/tabs/pinned_tab_service_factory.h" | |
88 #include "chrome/browser/ui/webui/ntp/ntp_resource_cache_factory.h" | |
89 #include "chrome/browser/user_style_sheet_watcher_factory.h" | |
90 #include "chrome/browser/webdata/web_data_service_factory.h" | |
91 | |
92 #if defined(ENABLE_CAPTIVE_PORTAL_DETECTION) | |
93 #include "chrome/browser/captive_portal/captive_portal_service_factory.h" | |
94 #endif | |
95 | |
96 #if defined(ENABLE_CONFIGURATION_POLICY) | |
97 #if defined(OS_CHROMEOS) | |
98 #include "chrome/browser/chromeos/policy/user_cloud_policy_manager_factory_chrom
eos.h" | |
99 #include "chrome/browser/chromeos/policy/user_cloud_policy_token_forwarder_facto
ry.h" | |
100 #else | |
101 #include "chrome/browser/policy/cloud/user_cloud_policy_manager_factory.h" | |
102 #include "chrome/browser/policy/cloud/user_policy_signin_service_factory.h" | |
103 #endif | |
104 #endif | |
105 | |
106 #if defined(OS_CHROMEOS) | |
107 #include "chrome/browser/chromeos/extensions/input_method_api.h" | |
108 #include "chrome/browser/chromeos/extensions/media_player_api.h" | |
109 #include "chrome/browser/chromeos/extensions/networking_private_event_router_fac
tory.h" | |
110 #include "chrome/browser/extensions/api/input_ime/input_ime_api.h" | |
111 #if defined(FILE_MANAGER_EXTENSION) | |
112 #include "chrome/browser/chromeos/extensions/file_manager/file_browser_private_a
pi_factory.h" | |
113 #endif | |
114 #endif | |
115 | |
116 #if defined(USE_AURA) | |
117 #include "chrome/browser/ui/gesture_prefs_observer_factory_aura.h" | |
118 #endif | |
119 | |
120 #if !defined(OS_ANDROID) | |
121 #include "chrome/browser/media_galleries/media_galleries_preferences_factory.h" | |
122 #include "chrome/browser/notifications/sync_notifier/chrome_notifier_service_fac
tory.h" | |
123 #endif | |
124 | 14 |
125 #ifndef NDEBUG | 15 #ifndef NDEBUG |
126 #include "base/command_line.h" | 16 #include "base/command_line.h" |
127 #include "base/file_util.h" | 17 #include "base/file_util.h" |
128 #include "chrome/common/chrome_switches.h" | 18 #include "chrome/common/chrome_switches.h" |
129 #endif | 19 #endif |
130 | 20 |
131 class Profile; | 21 class Profile; |
132 | 22 |
133 void ProfileDependencyManager::AddComponent( | 23 void ProfileDependencyManager::AddComponent( |
134 ProfileKeyedBaseFactory* component) { | 24 ProfileKeyedBaseFactory* component) { |
135 dependency_graph_.AddNode(component); | 25 dependency_graph_.AddNode(component); |
136 } | 26 } |
137 | 27 |
138 void ProfileDependencyManager::RemoveComponent( | 28 void ProfileDependencyManager::RemoveComponent( |
139 ProfileKeyedBaseFactory* component) { | 29 ProfileKeyedBaseFactory* component) { |
140 dependency_graph_.RemoveNode(component); | 30 dependency_graph_.RemoveNode(component); |
141 } | 31 } |
142 | 32 |
143 void ProfileDependencyManager::AddEdge(ProfileKeyedBaseFactory* depended, | 33 void ProfileDependencyManager::AddEdge(ProfileKeyedBaseFactory* depended, |
144 ProfileKeyedBaseFactory* dependee) { | 34 ProfileKeyedBaseFactory* dependee) { |
145 dependency_graph_.AddEdge(depended, dependee); | 35 dependency_graph_.AddEdge(depended, dependee); |
146 } | 36 } |
147 | 37 |
148 void ProfileDependencyManager::CreateProfileServices(Profile* profile, | 38 void ProfileDependencyManager::CreateProfileServices( |
149 bool is_testing_profile) { | 39 content::BrowserContext* profile, bool is_testing_profile) { |
150 #ifndef NDEBUG | 40 #ifndef NDEBUG |
151 // Unmark |profile| as dead. This exists because of unit tests, which will | 41 // Unmark |profile| as dead. This exists because of unit tests, which will |
152 // often have similar stack structures. 0xWhatever might be created, go out | 42 // often have similar stack structures. 0xWhatever might be created, go out |
153 // of scope, and then a new Profile object might be created at 0xWhatever. | 43 // of scope, and then a new Profile object might be created at 0xWhatever. |
154 dead_profile_pointers_.erase(profile); | 44 dead_profile_pointers_.erase(profile); |
155 #endif | 45 #endif |
156 | 46 |
157 AssertFactoriesBuilt(); | |
158 | |
159 std::vector<DependencyNode*> construction_order; | 47 std::vector<DependencyNode*> construction_order; |
160 if (!dependency_graph_.GetConstructionOrder(&construction_order)) { | 48 if (!dependency_graph_.GetConstructionOrder(&construction_order)) { |
161 NOTREACHED(); | 49 NOTREACHED(); |
162 } | 50 } |
163 | 51 |
164 #ifndef NDEBUG | 52 #ifndef NDEBUG |
165 DumpProfileDependencies(profile); | 53 DumpProfileDependencies(profile); |
166 #endif | 54 #endif |
167 | 55 |
168 for (size_t i = 0; i < construction_order.size(); i++) { | 56 for (size_t i = 0; i < construction_order.size(); i++) { |
169 ProfileKeyedBaseFactory* factory = | 57 ProfileKeyedBaseFactory* factory = |
170 static_cast<ProfileKeyedBaseFactory*>(construction_order[i]); | 58 static_cast<ProfileKeyedBaseFactory*>(construction_order[i]); |
171 | 59 |
172 if (!profile->IsOffTheRecord()) { | 60 if (!profile->IsOffTheRecord()) { |
173 // We only register preferences on normal profiles because the incognito | 61 // We only register preferences on normal profiles because the incognito |
174 // profile shares the pref service with the normal one. | 62 // profile shares the pref service with the normal one. |
175 factory->RegisterUserPrefsOnProfile(profile); | 63 factory->RegisterUserPrefsOnProfile(profile); |
176 } | 64 } |
177 | 65 |
178 if (is_testing_profile && factory->ServiceIsNULLWhileTesting()) { | 66 if (is_testing_profile && factory->ServiceIsNULLWhileTesting()) { |
179 factory->SetEmptyTestingFactory(profile); | 67 factory->SetEmptyTestingFactory(profile); |
180 } else if (factory->ServiceIsCreatedWithProfile()) { | 68 } else if (factory->ServiceIsCreatedWithProfile()) { |
181 // Create the service. | 69 // Create the service. |
182 factory->CreateServiceNow(profile); | 70 factory->CreateServiceNow(profile); |
183 } | 71 } |
184 } | 72 } |
185 } | 73 } |
186 | 74 |
187 void ProfileDependencyManager::DestroyProfileServices(Profile* profile) { | 75 void ProfileDependencyManager::DestroyProfileServices( |
| 76 content::BrowserContext* profile) { |
188 std::vector<DependencyNode*> destruction_order; | 77 std::vector<DependencyNode*> destruction_order; |
189 if (!dependency_graph_.GetDestructionOrder(&destruction_order)) { | 78 if (!dependency_graph_.GetDestructionOrder(&destruction_order)) { |
190 NOTREACHED(); | 79 NOTREACHED(); |
191 } | 80 } |
192 | 81 |
193 #ifndef NDEBUG | 82 #ifndef NDEBUG |
194 DumpProfileDependencies(profile); | 83 DumpProfileDependencies(profile); |
195 #endif | 84 #endif |
196 | 85 |
197 for (size_t i = 0; i < destruction_order.size(); i++) { | 86 for (size_t i = 0; i < destruction_order.size(); i++) { |
198 ProfileKeyedBaseFactory* factory = | 87 ProfileKeyedBaseFactory* factory = |
199 static_cast<ProfileKeyedBaseFactory*>(destruction_order[i]); | 88 static_cast<ProfileKeyedBaseFactory*>(destruction_order[i]); |
200 factory->ProfileShutdown(profile); | 89 factory->ProfileShutdown(profile); |
201 } | 90 } |
202 | 91 |
203 #ifndef NDEBUG | 92 #ifndef NDEBUG |
204 // The profile is now dead to the rest of the program. | 93 // The profile is now dead to the rest of the program. |
205 dead_profile_pointers_.insert(profile); | 94 dead_profile_pointers_.insert(profile); |
206 #endif | 95 #endif |
207 | 96 |
208 for (size_t i = 0; i < destruction_order.size(); i++) { | 97 for (size_t i = 0; i < destruction_order.size(); i++) { |
209 ProfileKeyedBaseFactory* factory = | 98 ProfileKeyedBaseFactory* factory = |
210 static_cast<ProfileKeyedBaseFactory*>(destruction_order[i]); | 99 static_cast<ProfileKeyedBaseFactory*>(destruction_order[i]); |
211 factory->ProfileDestroyed(profile); | 100 factory->ProfileDestroyed(profile); |
212 } | 101 } |
213 } | 102 } |
214 | 103 |
215 #ifndef NDEBUG | 104 #ifndef NDEBUG |
216 void ProfileDependencyManager::AssertProfileWasntDestroyed(Profile* profile) { | 105 void ProfileDependencyManager::AssertProfileWasntDestroyed( |
| 106 content::BrowserContext* profile) { |
217 if (dead_profile_pointers_.find(profile) != dead_profile_pointers_.end()) { | 107 if (dead_profile_pointers_.find(profile) != dead_profile_pointers_.end()) { |
218 NOTREACHED() << "Attempted to access a Profile that was ShutDown(). This " | 108 NOTREACHED() << "Attempted to access a Profile that was ShutDown(). This " |
219 << "is most likely a heap smasher in progress. After " | 109 << "is most likely a heap smasher in progress. After " |
220 << "ProfileKeyedService::Shutdown() completes, your service " | 110 << "ProfileKeyedService::Shutdown() completes, your service " |
221 << "MUST NOT refer to depended Profile services again."; | 111 << "MUST NOT refer to depended Profile services again."; |
222 } | 112 } |
223 } | 113 } |
224 #endif | 114 #endif |
225 | 115 |
226 // static | 116 // static |
227 ProfileDependencyManager* ProfileDependencyManager::GetInstance() { | 117 ProfileDependencyManager* ProfileDependencyManager::GetInstance() { |
228 return Singleton<ProfileDependencyManager>::get(); | 118 return Singleton<ProfileDependencyManager>::get(); |
229 } | 119 } |
230 | 120 |
231 ProfileDependencyManager::ProfileDependencyManager() : built_factories_(false) { | 121 ProfileDependencyManager::ProfileDependencyManager() { |
232 } | 122 } |
233 | 123 |
234 ProfileDependencyManager::~ProfileDependencyManager() {} | 124 ProfileDependencyManager::~ProfileDependencyManager() { |
235 | |
236 // This method gets the instance of each ServiceFactory. We do this so that | |
237 // each ServiceFactory initializes itself and registers its dependencies with | |
238 // the global PreferenceDependencyManager. We need to have a complete | |
239 // dependency graph when we create a profile so we can dispatch the profile | |
240 // creation message to the services that want to create their services at | |
241 // profile creation time. | |
242 // | |
243 // TODO(erg): This needs to be something else. I don't think putting every | |
244 // FooServiceFactory here will scale or is desirable long term. | |
245 void ProfileDependencyManager::AssertFactoriesBuilt() { | |
246 if (built_factories_) | |
247 return; | |
248 | |
249 AboutSigninInternalsFactory::GetInstance(); | |
250 | |
251 #if defined(ENABLE_BACKGROUND) | |
252 BackgroundContentsServiceFactory::GetInstance(); | |
253 #endif | |
254 BookmarkModelFactory::GetInstance(); | |
255 #if defined(ENABLE_CAPTIVE_PORTAL_DETECTION) | |
256 captive_portal::CaptivePortalServiceFactory::GetInstance(); | |
257 #endif | |
258 ChromeGeolocationPermissionContextFactory::GetInstance(); | |
259 #if defined(ENABLE_PRINTING) | |
260 CloudPrintProxyServiceFactory::GetInstance(); | |
261 #endif | |
262 CookieSettings::Factory::GetInstance(); | |
263 #if defined(ENABLE_NOTIFICATIONS) | |
264 DesktopNotificationServiceFactory::GetInstance(); | |
265 #endif | |
266 DownloadServiceFactory::GetInstance(); | |
267 #if defined(ENABLE_EXTENSIONS) | |
268 apps::AppRestoreServiceFactory::GetInstance(); | |
269 apps::ShortcutManagerFactory::GetInstance(); | |
270 autofill::autocheckout::WhitelistManagerFactory::GetInstance(); | |
271 extensions::ActivityLogFactory::GetInstance(); | |
272 extensions::AlarmManager::GetFactoryInstance(); | |
273 extensions::AudioAPI::GetFactoryInstance(); | |
274 extensions::BookmarksAPI::GetFactoryInstance(); | |
275 extensions::BluetoothAPIFactory::GetInstance(); | |
276 extensions::CommandService::GetFactoryInstance(); | |
277 extensions::CookiesAPI::GetFactoryInstance(); | |
278 extensions::DialAPIFactory::GetInstance(); | |
279 extensions::ExtensionActionAPI::GetFactoryInstance(); | |
280 extensions::ExtensionSystemFactory::GetInstance(); | |
281 extensions::ExtensionWebUIOverrideRegistrar::GetFactoryInstance(); | |
282 extensions::FontSettingsAPI::GetFactoryInstance(); | |
283 extensions::HistoryAPI::GetFactoryInstance(); | |
284 extensions::IdentityAPI::GetFactoryInstance(); | |
285 extensions::IdleManagerFactory::GetInstance(); | |
286 extensions::InstallTrackerFactory::GetInstance(); | |
287 #if defined(TOOLKIT_VIEWS) | |
288 extensions::InputAPI::GetFactoryInstance(); | |
289 #endif | |
290 #if defined(OS_CHROMEOS) | |
291 extensions::InputImeAPI::GetFactoryInstance(); | |
292 extensions::InputMethodAPI::GetFactoryInstance(); | |
293 #endif | |
294 extensions::ManagedModeAPI::GetFactoryInstance(); | |
295 extensions::ManagementAPI::GetFactoryInstance(); | |
296 extensions::MediaGalleriesPrivateAPI::GetFactoryInstance(); | |
297 #if defined(OS_CHROMEOS) | |
298 extensions::MediaPlayerAPI::GetFactoryInstance(); | |
299 #endif | |
300 extensions::OmniboxAPI::GetFactoryInstance(); | |
301 extensions::PreferenceAPI::GetFactoryInstance(); | |
302 extensions::ProcessesAPI::GetFactoryInstance(); | |
303 extensions::PushMessagingAPI::GetFactoryInstance(); | |
304 extensions::SessionRestoreAPI::GetFactoryInstance(); | |
305 extensions::SpellcheckAPI::GetFactoryInstance(); | |
306 extensions::StreamsPrivateAPI::GetFactoryInstance(); | |
307 extensions::SystemInfoAPI::GetFactoryInstance(); | |
308 extensions::SuggestedLinksRegistryFactory::GetInstance(); | |
309 extensions::TabCaptureRegistryFactory::GetInstance(); | |
310 extensions::TabsWindowsAPI::GetFactoryInstance(); | |
311 extensions::TtsAPI::GetFactoryInstance(); | |
312 extensions::WebNavigationAPI::GetFactoryInstance(); | |
313 #endif // defined(ENABLE_EXTENSIONS) | |
314 FaviconServiceFactory::GetInstance(); | |
315 #if defined(OS_CHROMEOS) && defined(FILE_MANAGER_EXTENSION) | |
316 FileBrowserPrivateAPIFactory::GetInstance(); | |
317 #endif | |
318 FindBarStateFactory::GetInstance(); | |
319 GAIAInfoUpdateServiceFactory::GetInstance(); | |
320 #if defined(USE_AURA) | |
321 GesturePrefsObserverFactoryAura::GetInstance(); | |
322 #endif | |
323 GlobalErrorServiceFactory::GetInstance(); | |
324 GoogleURLTrackerFactory::GetInstance(); | |
325 HistoryServiceFactory::GetInstance(); | |
326 #if !defined(OS_ANDROID) | |
327 notifier::ChromeNotifierServiceFactory::GetInstance(); | |
328 MediaGalleriesPreferencesFactory::GetInstance(); | |
329 #endif | |
330 #if defined(OS_CHROMEOS) | |
331 chromeos::NetworkingPrivateEventRouterFactory::GetInstance(); | |
332 #endif | |
333 NTPResourceCacheFactory::GetInstance(); | |
334 PasswordStoreFactory::GetInstance(); | |
335 autofill::PersonalDataManagerFactory::GetInstance(); | |
336 #if !defined(OS_ANDROID) | |
337 PinnedTabServiceFactory::GetInstance(); | |
338 #endif | |
339 #if defined(ENABLE_PLUGINS) | |
340 PluginPrefsFactory::GetInstance(); | |
341 #endif | |
342 policy::ProfilePolicyConnectorFactory::GetInstance(); | |
343 #if defined(ENABLE_CONFIGURATION_POLICY) | |
344 #if defined(OS_CHROMEOS) | |
345 policy::UserCloudPolicyManagerFactoryChromeOS::GetInstance(); | |
346 policy::UserCloudPolicyTokenForwarderFactory::GetInstance(); | |
347 #else | |
348 policy::UserCloudPolicyManagerFactory::GetInstance(); | |
349 policy::UserPolicySigninServiceFactory::GetInstance(); | |
350 #endif | |
351 #endif | |
352 predictors::AutocompleteActionPredictorFactory::GetInstance(); | |
353 predictors::PredictorDatabaseFactory::GetInstance(); | |
354 predictors::ResourcePrefetchPredictorFactory::GetInstance(); | |
355 prerender::PrerenderManagerFactory::GetInstance(); | |
356 prerender::PrerenderLinkManagerFactory::GetInstance(); | |
357 ProfileSyncServiceFactory::GetInstance(); | |
358 ProtocolHandlerRegistryFactory::GetInstance(); | |
359 #if defined(ENABLE_SESSION_SERVICE) | |
360 SessionServiceFactory::GetInstance(); | |
361 #endif | |
362 ShortcutsBackendFactory::GetInstance(); | |
363 ThumbnailServiceFactory::GetInstance(); | |
364 SigninManagerFactory::GetInstance(); | |
365 #if defined(ENABLE_INPUT_SPEECH) | |
366 ChromeSpeechRecognitionPreferences::InitializeFactory(); | |
367 #endif | |
368 SpellcheckServiceFactory::GetInstance(); | |
369 TabRestoreServiceFactory::GetInstance(); | |
370 TemplateURLFetcherFactory::GetInstance(); | |
371 TemplateURLServiceFactory::GetInstance(); | |
372 #if defined(ENABLE_THEMES) | |
373 ThemeServiceFactory::GetInstance(); | |
374 #endif | |
375 TokenCacheServiceFactory::GetInstance(); | |
376 TokenServiceFactory::GetInstance(); | |
377 #if !defined(OS_ANDROID) | |
378 UserStyleSheetWatcherFactory::GetInstance(); | |
379 #endif | |
380 WebDataServiceFactory::GetInstance(); | |
381 | |
382 built_factories_ = true; | |
383 } | 125 } |
384 | 126 |
385 #ifndef NDEBUG | 127 #ifndef NDEBUG |
386 namespace { | 128 namespace { |
387 | 129 |
388 std::string ProfileKeyedBaseFactoryGetNodeName(DependencyNode* node) { | 130 std::string ProfileKeyedBaseFactoryGetNodeName(DependencyNode* node) { |
389 return static_cast<ProfileKeyedBaseFactory*>(node)->name(); | 131 return static_cast<ProfileKeyedBaseFactory*>(node)->name(); |
390 } | 132 } |
391 | 133 |
392 } // namespace | 134 } // namespace |
393 | 135 |
394 void ProfileDependencyManager::DumpProfileDependencies(Profile* profile) { | 136 void ProfileDependencyManager::DumpProfileDependencies( |
| 137 content::BrowserContext* profile) { |
395 // Whenever we try to build a destruction ordering, we should also dump a | 138 // Whenever we try to build a destruction ordering, we should also dump a |
396 // dependency graph to "/path/to/profile/profile-dependencies.dot". | 139 // dependency graph to "/path/to/profile/profile-dependencies.dot". |
397 if (CommandLine::ForCurrentProcess()->HasSwitch( | 140 if (CommandLine::ForCurrentProcess()->HasSwitch( |
398 switches::kDumpProfileDependencyGraph)) { | 141 switches::kDumpProfileDependencyGraph)) { |
399 base::FilePath dot_file = | 142 base::FilePath dot_file = |
400 profile->GetPath().AppendASCII("profile-dependencies.dot"); | 143 profile->GetPath().AppendASCII("profile-dependencies.dot"); |
401 std::string contents = dependency_graph_.DumpAsGraphviz( | 144 std::string contents = dependency_graph_.DumpAsGraphviz( |
402 "Profile", base::Bind(&ProfileKeyedBaseFactoryGetNodeName)); | 145 "Profile", base::Bind(&ProfileKeyedBaseFactoryGetNodeName)); |
403 file_util::WriteFile(dot_file, contents.c_str(), contents.size()); | 146 file_util::WriteFile(dot_file, contents.c_str(), contents.size()); |
404 } | 147 } |
405 } | 148 } |
406 #endif // NDEBUG | 149 #endif // NDEBUG |
OLD | NEW |