Index: chrome/test/base/testing_profile.cc |
=================================================================== |
--- chrome/test/base/testing_profile.cc (revision 111700) |
+++ chrome/test/base/testing_profile.cc (working copy) |
@@ -132,7 +132,8 @@ |
testing_prefs_(NULL), |
incognito_(false), |
last_session_exited_cleanly_(true), |
- profile_dependency_manager_(ProfileDependencyManager::GetInstance()) { |
+ profile_dependency_manager_(ProfileDependencyManager::GetInstance()), |
+ delegate_(NULL) { |
if (!temp_dir_.CreateUniqueTempDir()) { |
LOG(ERROR) << "Failed to create unique temporary directory."; |
@@ -160,6 +161,7 @@ |
profile_path_ = temp_dir_.path(); |
Init(); |
+ FinishInit(); |
} |
TestingProfile::TestingProfile(const FilePath& path) |
@@ -168,21 +170,47 @@ |
incognito_(false), |
last_session_exited_cleanly_(true), |
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), |
+ 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() { |