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

Side by Side Diff: chrome/browser/profiles/profile_manager.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 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 <set> 5 #include <set>
6 6
7 #include "chrome/browser/profiles/profile_manager.h" 7 #include "chrome/browser/profiles/profile_manager.h"
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/file_path.h" 10 #include "base/file_path.h"
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 return profiles; 315 return profiles;
316 } 316 }
317 317
318 Profile* ProfileManager::GetProfile(const FilePath& profile_dir) { 318 Profile* ProfileManager::GetProfile(const FilePath& profile_dir) {
319 // If the profile is already loaded (e.g., chrome.exe launched twice), just 319 // If the profile is already loaded (e.g., chrome.exe launched twice), just
320 // return it. 320 // return it.
321 Profile* profile = GetProfileByPath(profile_dir); 321 Profile* profile = GetProfileByPath(profile_dir);
322 if (NULL != profile) 322 if (NULL != profile)
323 return profile; 323 return profile;
324 324
325 profile = CreateProfile(profile_dir); 325 profile = CreateProfileHelper(profile_dir);
326 DCHECK(profile); 326 DCHECK(profile);
327 if (profile) { 327 if (profile) {
328 bool result = AddProfile(profile); 328 bool result = AddProfile(profile);
329 DCHECK(result); 329 DCHECK(result);
330 } 330 }
331 return profile; 331 return profile;
332 } 332 }
333 333
334 void ProfileManager::CreateProfileAsync(const FilePath& user_data_dir, 334 void ProfileManager::CreateProfileAsync(const FilePath& user_data_dir,
335 ProfileManagerObserver* observer) { 335 ProfileManagerObserver* observer) {
336 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 336 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
337 ProfilesInfoMap::iterator iter = profiles_info_.find(user_data_dir); 337 ProfilesInfoMap::iterator iter = profiles_info_.find(user_data_dir);
338 if (iter != profiles_info_.end()) { 338 if (iter != profiles_info_.end()) {
339 ProfileInfo* info = iter->second.get(); 339 ProfileInfo* info = iter->second.get();
340 if (info->created) { 340 if (info->created) {
341 // Profile has already been created. Call observer immediately. 341 // Profile has already been created. Call observer immediately.
342 observer->OnProfileCreated( 342 observer->OnProfileCreated(
343 info->profile.get(), ProfileManagerObserver::STATUS_INITIALIZED); 343 info->profile.get(), ProfileManagerObserver::STATUS_INITIALIZED);
344 if (observer->DeleteAfter()) 344 if (observer->DeleteAfter())
345 delete observer; 345 delete observer;
346 } else { 346 } else {
347 // Profile is being created. Add observer to list. 347 // Profile is being created. Add observer to list.
348 info->observers.push_back(observer); 348 info->observers.push_back(observer);
349 } 349 }
350 } else { 350 } else {
351 // Initiate asynchronous creation process. 351 // Initiate asynchronous creation process.
352 ProfileInfo* info = 352 ProfileInfo* info =
353 RegisterProfile(Profile::CreateProfileAsync(user_data_dir, this), 353 RegisterProfile(CreateProfileAsyncHelper(user_data_dir, this),
354 false); 354 false);
355 info->observers.push_back(observer); 355 info->observers.push_back(observer);
356 } 356 }
357 } 357 }
358 358
359 // static 359 // static
360 void ProfileManager::CreateDefaultProfileAsync( 360 void ProfileManager::CreateDefaultProfileAsync(
361 ProfileManagerObserver* observer) { 361 ProfileManagerObserver* observer) {
362 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 362 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
363 ProfileManager* profile_manager = g_browser_process->profile_manager(); 363 ProfileManager* profile_manager = g_browser_process->profile_manager();
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
479 if (!command_line.HasSwitch(switches::kDisableWebResources)) 479 if (!command_line.HasSwitch(switches::kDisableWebResources))
480 profile->InitPromoResources(); 480 profile->InitPromoResources();
481 } 481 }
482 482
483 void ProfileManager::DoFinalInitLogging(Profile* profile) { 483 void ProfileManager::DoFinalInitLogging(Profile* profile) {
484 // Log the profile size after a reasonable startup delay. 484 // Log the profile size after a reasonable startup delay.
485 BrowserThread::PostDelayedTask(BrowserThread::FILE, FROM_HERE, 485 BrowserThread::PostDelayedTask(BrowserThread::FILE, FROM_HERE,
486 new ProfileSizeTask(profile), 112000); 486 new ProfileSizeTask(profile), 112000);
487 } 487 }
488 488
489 Profile* ProfileManager::CreateProfile(const FilePath& path) { 489 Profile* ProfileManager::CreateProfileHelper(const FilePath& path) {
490 return Profile::CreateProfile(path); 490 return Profile::CreateProfile(path);
491 } 491 }
492 492
493 Profile* ProfileManager::CreateProfileAsyncHelper(const FilePath& path,
494 Delegate* delegate) {
495 return Profile::CreateProfileAsync(path, delegate);
496 }
497
493 void ProfileManager::OnProfileCreated(Profile* profile, bool success) { 498 void ProfileManager::OnProfileCreated(Profile* profile, bool success) {
494 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 499 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
495 500
496 ProfilesInfoMap::iterator iter = profiles_info_.find(profile->GetPath()); 501 ProfilesInfoMap::iterator iter = profiles_info_.find(profile->GetPath());
497 DCHECK(iter != profiles_info_.end()); 502 DCHECK(iter != profiles_info_.end());
498 ProfileInfo* info = iter->second.get(); 503 ProfileInfo* info = iter->second.get();
499 504
500 std::vector<ProfileManagerObserver*> observers; 505 std::vector<ProfileManagerObserver*> observers;
501 info->observers.swap(observers); 506 info->observers.swap(observers);
502 507
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
705 RegisterProfile(profile, true); 710 RegisterProfile(profile, true);
706 if (add_to_cache) 711 if (add_to_cache)
707 AddProfileToCache(profile); 712 AddProfileToCache(profile);
708 } 713 }
709 714
710 #if defined(OS_WIN) 715 #if defined(OS_WIN)
711 void ProfileManager::RemoveProfileShortcutManagerForTesting() { 716 void ProfileManager::RemoveProfileShortcutManagerForTesting() {
712 profile_info_cache_->RemoveObserver(profile_shortcut_manager_.get()); 717 profile_info_cache_->RemoveObserver(profile_shortcut_manager_.get());
713 } 718 }
714 #endif 719 #endif
OLDNEW
« no previous file with comments | « chrome/browser/profiles/profile_manager.h ('k') | chrome/browser/profiles/profile_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698