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

Unified Diff: chrome/test/base/testing_profile.cc

Issue 8565032: Fixing ProfileManagerTest to use the TestingProfile instead of a real profile. This will allow ea... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/test/base/testing_profile.h ('k') | chrome/test/base/testing_profile_manager.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/base/testing_profile.cc
===================================================================
--- chrome/test/base/testing_profile.cc (revision 110703)
+++ chrome/test/base/testing_profile.cc (working copy)
@@ -132,7 +132,9 @@
testing_prefs_(NULL),
incognito_(false),
last_session_exited_cleanly_(true),
- profile_dependency_manager_(ProfileDependencyManager::GetInstance()) {
+ enable_lazy_service_initialization_(false),
+ profile_dependency_manager_(ProfileDependencyManager::GetInstance()),
+ delegate_(NULL) {
if (!temp_dir_.CreateUniqueTempDir()) {
LOG(ERROR) << "Failed to create unique temporary directory.";
@@ -160,6 +162,7 @@
profile_path_ = temp_dir_.path();
Init();
+ FinishInit();
}
TestingProfile::TestingProfile(const FilePath& path)
@@ -167,22 +170,50 @@
testing_prefs_(NULL),
incognito_(false),
last_session_exited_cleanly_(true),
+ enable_lazy_service_initialization_(false),
profile_path_(path),
- profile_dependency_manager_(ProfileDependencyManager::GetInstance()) {
+ profile_dependency_manager_(ProfileDependencyManager::GetInstance()),
+ delegate_(NULL) {
Init();
+ FinishInit();
}
+TestingProfile::TestingProfile(const FilePath& path,
+ Delegate* delegate)
+ : start_time_(Time::Now()),
+ testing_prefs_(NULL),
+ incognito_(false),
+ last_session_exited_cleanly_(true),
+ enable_lazy_service_initialization_(false),
+ profile_path_(path),
+ profile_dependency_manager_(ProfileDependencyManager::GetInstance()),
+ delegate_(delegate) {
+ Init();
+ if (delegate_) {
+ MessageLoop::current()->PostTask(FROM_HERE,
+ base::Bind(&TestingProfile::FinishInit,
+ base::Unretained(this)));
+ } else {
+ FinishInit();
+ }
+}
+
void TestingProfile::Init() {
profile_dependency_manager_->CreateProfileServices(this, true);
// Install profile keyed service factory hooks for dummy/test services
DesktopNotificationServiceFactory::GetInstance()->SetTestingFactory(
this, CreateTestDesktopNotificationService);
+}
+void TestingProfile::FinishInit() {
content::NotificationService::current()->Notify(
chrome::NOTIFICATION_PROFILE_CREATED,
content::Source<Profile>(static_cast<Profile*>(this)),
content::NotificationService::NoDetails());
+
+ if (delegate_)
+ delegate_->OnProfileCreated(this, true);
}
TestingProfile::~TestingProfile() {
@@ -383,6 +414,8 @@
}
TestingPrefService* TestingProfile::GetTestingPrefService() {
+ // Always lazily initialize so no check for
Paweł Hajdan Jr. 2011/11/22 09:18:42 I don't understand the difference here. It seems t
rpetterson 2011/11/22 21:43:25 The intention of enable_lazy_service_initializatio
+ // enable_lazy_service_initialization_.
if (!prefs_.get())
CreateTestingPrefService();
DCHECK(testing_prefs_);
@@ -480,10 +513,14 @@
}
FaviconService* TestingProfile::GetFaviconService(ServiceAccessType access) {
+ if (enable_lazy_service_initialization_ && !favicon_service_.get())
+ CreateFaviconService();
return favicon_service_.get();
}
HistoryService* TestingProfile::GetHistoryService(ServiceAccessType access) {
+ if (enable_lazy_service_initialization_ && !history_service_.get())
+ CreateHistoryService(true, false);
return history_service_.get();
}
@@ -507,6 +544,8 @@
}
WebDataService* TestingProfile::GetWebDataService(ServiceAccessType access) {
+ if (enable_lazy_service_initialization_ && !web_data_service_.get())
+ CreateWebDataService(false);
return web_data_service_.get();
}
@@ -685,6 +724,8 @@
}
BookmarkModel* TestingProfile::GetBookmarkModel() {
+ if (enable_lazy_service_initialization_ && !bookmark_bar_model_.get())
+ CreateBookmarkModel(true);
return bookmark_bar_model_.get();
}
« no previous file with comments | « chrome/test/base/testing_profile.h ('k') | chrome/test/base/testing_profile_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698