Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(64)

Side by Side Diff: chrome/browser/profiles/profile_dependency_manager.cc

Issue 8598028: Clean up ExtensionServiceTest. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix for atexitmanager Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
(...skipping 19 matching lines...) Expand all
30 30
31 // This method gets the instance of each ServiceFactory. We do this so that 31 // This method gets the instance of each ServiceFactory. We do this so that
32 // each ServiceFactory initializes iteslf and registers its dependencies with 32 // each ServiceFactory initializes iteslf and registers its dependencies with
33 // the global PreferenceDependencyManager. We need to have a complete 33 // the global PreferenceDependencyManager. We need to have a complete
34 // dependency graph when we create a profile so we can dispatch the profile 34 // dependency graph when we create a profile so we can dispatch the profile
35 // creation message to the services that want to create their services at 35 // creation message to the services that want to create their services at
36 // profile creation time. 36 // profile creation time.
37 // 37 //
38 // TODO(erg): This needs to be something else. I don't think putting every 38 // TODO(erg): This needs to be something else. I don't think putting every
39 // FooServiceFactory here will scale or is desireable long term. 39 // FooServiceFactory here will scale or is desireable long term.
40 void AssertFactoriesBuilt() { 40 void AssertFactoriesBuilt(bool is_testing_profile) {
41 if (!g_initialized) { 41 if (!g_initialized || is_testing_profile) {
Elliot Glaysher 2011/11/21 18:47:06 I don't understand this fix. Won't g_initialized a
Yoyo Zhou 2011/11/21 23:14:52 It looks like rsesek has been working on fixing th
42 BackgroundContentsServiceFactory::GetInstance(); 42 BackgroundContentsServiceFactory::GetInstance();
43 CloudPrintProxyServiceFactory::GetInstance(); 43 CloudPrintProxyServiceFactory::GetInstance();
44 CookieSettings::Factory::GetInstance(); 44 CookieSettings::Factory::GetInstance();
45 SpeechInputExtensionManager::InitializeFactory(); 45 SpeechInputExtensionManager::InitializeFactory();
46 PersonalDataManagerFactory::GetInstance(); 46 PersonalDataManagerFactory::GetInstance();
47 PluginPrefsFactory::GetInstance(); 47 PluginPrefsFactory::GetInstance();
48 prerender::PrerenderManagerFactory::GetInstance(); 48 prerender::PrerenderManagerFactory::GetInstance();
49 SessionServiceFactory::GetInstance(); 49 SessionServiceFactory::GetInstance();
50 TabRestoreServiceFactory::GetInstance(); 50 TabRestoreServiceFactory::GetInstance();
51 TemplateURLServiceFactory::GetInstance(); 51 TemplateURLServiceFactory::GetInstance();
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 90
91 void ProfileDependencyManager::CreateProfileServices(Profile* profile, 91 void ProfileDependencyManager::CreateProfileServices(Profile* profile,
92 bool is_testing_profile) { 92 bool is_testing_profile) {
93 #ifndef NDEBUG 93 #ifndef NDEBUG
94 // Unmark |profile| as dead. This exists because of unit tests, which will 94 // Unmark |profile| as dead. This exists because of unit tests, which will
95 // often have similar stack structures. 0xWhatever might be created, go out 95 // often have similar stack structures. 0xWhatever might be created, go out
96 // of scope, and then a new Profile object might be created at 0xWhatever. 96 // of scope, and then a new Profile object might be created at 0xWhatever.
97 dead_profile_pointers_.erase(profile); 97 dead_profile_pointers_.erase(profile);
98 #endif 98 #endif
99 99
100 AssertFactoriesBuilt(); 100 AssertFactoriesBuilt(is_testing_profile);
101 101
102 if (destruction_order_.empty()) 102 if (destruction_order_.empty())
103 BuildDestructionOrder(); 103 BuildDestructionOrder();
104 104
105 // Iterate in reverse destruction order for creation. 105 // Iterate in reverse destruction order for creation.
106 for (std::vector<ProfileKeyedServiceFactory*>::reverse_iterator rit = 106 for (std::vector<ProfileKeyedServiceFactory*>::reverse_iterator rit =
107 destruction_order_.rbegin(); rit != destruction_order_.rend(); 107 destruction_order_.rbegin(); rit != destruction_order_.rend();
108 ++rit) { 108 ++rit) {
109 if (!profile->IsOffTheRecord() && !profile->AsTestingProfile()) { 109 if (!profile->IsOffTheRecord() && !profile->AsTestingProfile()) {
110 // We only register preferences on normal profiles because the incognito 110 // We only register preferences on normal profiles because the incognito
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 } 206 }
207 } 207 }
208 208
209 if (edges.size()) { 209 if (edges.size()) {
210 NOTREACHED() << "Dependency graph has a cycle. We are doomed."; 210 NOTREACHED() << "Dependency graph has a cycle. We are doomed.";
211 } 211 }
212 212
213 std::reverse(output.begin(), output.end()); 213 std::reverse(output.begin(), output.end());
214 destruction_order_ = output; 214 destruction_order_ = output;
215 } 215 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698