OLD | NEW |
---|---|
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_impl.h" | 5 #include "chrome/browser/profiles/profile_impl.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/environment.h" | 9 #include "base/environment.h" |
10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
(...skipping 30 matching lines...) Expand all Loading... | |
41 #include "chrome/browser/geolocation/chrome_geolocation_permission_context.h" | 41 #include "chrome/browser/geolocation/chrome_geolocation_permission_context.h" |
42 #include "chrome/browser/geolocation/geolocation_content_settings_map.h" | 42 #include "chrome/browser/geolocation/geolocation_content_settings_map.h" |
43 #include "chrome/browser/history/history.h" | 43 #include "chrome/browser/history/history.h" |
44 #include "chrome/browser/history/shortcuts_backend.h" | 44 #include "chrome/browser/history/shortcuts_backend.h" |
45 #include "chrome/browser/history/top_sites.h" | 45 #include "chrome/browser/history/top_sites.h" |
46 #include "chrome/browser/instant/instant_controller.h" | 46 #include "chrome/browser/instant/instant_controller.h" |
47 #include "chrome/browser/metrics/metrics_service.h" | 47 #include "chrome/browser/metrics/metrics_service.h" |
48 #include "chrome/browser/net/chrome_url_request_context.h" | 48 #include "chrome/browser/net/chrome_url_request_context.h" |
49 #include "chrome/browser/net/gaia/token_service.h" | 49 #include "chrome/browser/net/gaia/token_service.h" |
50 #include "chrome/browser/net/net_pref_observer.h" | 50 #include "chrome/browser/net/net_pref_observer.h" |
51 #include "chrome/browser/net/predictor.h" | |
51 #include "chrome/browser/net/pref_proxy_config_service.h" | 52 #include "chrome/browser/net/pref_proxy_config_service.h" |
52 #include "chrome/browser/net/ssl_config_service_manager.h" | 53 #include "chrome/browser/net/ssl_config_service_manager.h" |
53 #include "chrome/browser/password_manager/password_store_default.h" | 54 #include "chrome/browser/password_manager/password_store_default.h" |
54 #include "chrome/browser/policy/configuration_policy_pref_store.h" | 55 #include "chrome/browser/policy/configuration_policy_pref_store.h" |
55 #include "chrome/browser/prefs/browser_prefs.h" | 56 #include "chrome/browser/prefs/browser_prefs.h" |
56 #include "chrome/browser/prefs/pref_value_store.h" | 57 #include "chrome/browser/prefs/pref_value_store.h" |
57 #include "chrome/browser/prefs/scoped_user_pref_update.h" | 58 #include "chrome/browser/prefs/scoped_user_pref_update.h" |
58 #include "chrome/browser/prerender/prerender_manager.h" | 59 #include "chrome/browser/prerender/prerender_manager.h" |
59 #include "chrome/browser/profiles/profile_dependency_manager.h" | 60 #include "chrome/browser/profiles/profile_dependency_manager.h" |
60 #include "chrome/browser/profiles/profile_manager.h" | 61 #include "chrome/browser/profiles/profile_manager.h" |
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
302 favicon_service_created_(false), | 303 favicon_service_created_(false), |
303 created_web_data_service_(false), | 304 created_web_data_service_(false), |
304 created_password_store_(false), | 305 created_password_store_(false), |
305 created_download_manager_(false), | 306 created_download_manager_(false), |
306 start_time_(Time::Now()), | 307 start_time_(Time::Now()), |
307 spellcheck_host_(NULL), | 308 spellcheck_host_(NULL), |
308 spellcheck_host_ready_(false), | 309 spellcheck_host_ready_(false), |
309 #if defined(OS_WIN) | 310 #if defined(OS_WIN) |
310 checked_instant_promo_(false), | 311 checked_instant_promo_(false), |
311 #endif | 312 #endif |
312 delegate_(delegate) { | 313 delegate_(delegate), |
314 predictor_(NULL) { | |
313 DCHECK(!path.empty()) << "Using an empty path will attempt to write " << | 315 DCHECK(!path.empty()) << "Using an empty path will attempt to write " << |
314 "profile files to the root directory!"; | 316 "profile files to the root directory!"; |
315 | 317 |
316 create_session_service_timer_.Start( | 318 create_session_service_timer_.Start( |
317 TimeDelta::FromMilliseconds(kCreateSessionServiceDelayMS), this, | 319 TimeDelta::FromMilliseconds(kCreateSessionServiceDelayMS), this, |
318 &ProfileImpl::EnsureSessionServiceCreated); | 320 &ProfileImpl::EnsureSessionServiceCreated); |
319 | 321 |
322 predictor_ = new chrome_browser_net::Predictor(); | |
323 predictor_->AddRef(); | |
willchan no longer on Chromium
2011/08/10 07:04:08
I don't think the AddRef() is needed since I advis
rpetterson
2011/08/12 03:12:36
Done.
| |
324 | |
320 if (delegate_) { | 325 if (delegate_) { |
321 prefs_.reset(PrefService::CreatePrefService( | 326 prefs_.reset(PrefService::CreatePrefService( |
322 GetPrefFilePath(), | 327 GetPrefFilePath(), |
323 new ExtensionPrefStore(GetExtensionPrefValueMap(), false), | 328 new ExtensionPrefStore(GetExtensionPrefValueMap(), false), |
324 true)); | 329 true)); |
325 // Wait for the notifcation that prefs has been loaded (successfully or | 330 // Wait for the notifcation that prefs has been loaded (successfully or |
326 // not). | 331 // not). |
327 registrar_.Add(this, chrome::NOTIFICATION_PREF_INITIALIZATION_COMPLETED, | 332 registrar_.Add(this, chrome::NOTIFICATION_PREF_INITIALIZATION_COMPLETED, |
328 Source<PrefService>(prefs_.get())); | 333 Source<PrefService>(prefs_.get())); |
329 } else { | 334 } else { |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
431 FilePath extensions_cookie_path = GetPath(); | 436 FilePath extensions_cookie_path = GetPath(); |
432 extensions_cookie_path = | 437 extensions_cookie_path = |
433 extensions_cookie_path.Append(chrome::kExtensionsCookieFilename); | 438 extensions_cookie_path.Append(chrome::kExtensionsCookieFilename); |
434 | 439 |
435 FilePath app_path = GetPath().Append(chrome::kIsolatedAppStateDirname); | 440 FilePath app_path = GetPath().Append(chrome::kIsolatedAppStateDirname); |
436 | 441 |
437 // Make sure we initialize the ProfileIOData after everything else has been | 442 // Make sure we initialize the ProfileIOData after everything else has been |
438 // initialized that we might be reading from the IO thread. | 443 // initialized that we might be reading from the IO thread. |
439 io_data_.Init(cookie_path, cache_path, cache_max_size, | 444 io_data_.Init(cookie_path, cache_path, cache_max_size, |
440 media_cache_path, media_cache_max_size, extensions_cookie_path, | 445 media_cache_path, media_cache_max_size, extensions_cookie_path, |
441 app_path); | 446 app_path, predictor_); |
442 | 447 |
443 // Creation has been finished. | 448 // Creation has been finished. |
444 if (delegate_) | 449 if (delegate_) |
445 delegate_->OnProfileCreated(this, true); | 450 delegate_->OnProfileCreated(this, true); |
446 | 451 |
447 NotificationService::current()->Notify( | 452 NotificationService::current()->Notify( |
448 chrome::NOTIFICATION_PROFILE_CREATED, | 453 chrome::NOTIFICATION_PROFILE_CREATED, |
449 Source<Profile>(this), | 454 Source<Profile>(this), |
450 NotificationService::NoDetails()); | 455 NotificationService::NoDetails()); |
451 } | 456 } |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
643 | 648 |
644 FilePath ProfileImpl::last_selected_directory() { | 649 FilePath ProfileImpl::last_selected_directory() { |
645 return GetPrefs()->GetFilePath(prefs::kSelectFileLastDirectory); | 650 return GetPrefs()->GetFilePath(prefs::kSelectFileLastDirectory); |
646 } | 651 } |
647 | 652 |
648 void ProfileImpl::set_last_selected_directory(const FilePath& path) { | 653 void ProfileImpl::set_last_selected_directory(const FilePath& path) { |
649 GetPrefs()->SetFilePath(prefs::kSelectFileLastDirectory, path); | 654 GetPrefs()->SetFilePath(prefs::kSelectFileLastDirectory, path); |
650 } | 655 } |
651 | 656 |
652 ProfileImpl::~ProfileImpl() { | 657 ProfileImpl::~ProfileImpl() { |
658 DCHECK(predictor_); | |
659 predictor_->SaveStateForNextStartupAndTrim(GetPrefs()); | |
660 predictor_->Shutdown(); | |
willchan no longer on Chromium
2011/08/10 07:04:08
According to the comments in predictor.h, this is
rpetterson
2011/08/12 03:12:36
Thanks for catching this. Since the profile doesn'
| |
661 | |
653 NotificationService::current()->Notify( | 662 NotificationService::current()->Notify( |
654 chrome::NOTIFICATION_PROFILE_DESTROYED, | 663 chrome::NOTIFICATION_PROFILE_DESTROYED, |
655 Source<Profile>(this), | 664 Source<Profile>(this), |
656 NotificationService::NoDetails()); | 665 NotificationService::NoDetails()); |
657 | 666 |
658 if (appcache_service_ && clear_local_state_on_exit_) { | 667 if (appcache_service_ && clear_local_state_on_exit_) { |
659 BrowserThread::PostTask( | 668 BrowserThread::PostTask( |
660 BrowserThread::IO, FROM_HERE, | 669 BrowserThread::IO, FROM_HERE, |
661 NewRunnableMethod( | 670 NewRunnableMethod( |
662 appcache_service_.get(), | 671 appcache_service_.get(), |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
889 // as early as possible. The constructor takes care of that. | 898 // as early as possible. The constructor takes care of that. |
890 extension_prefs_.reset(new ExtensionPrefs( | 899 extension_prefs_.reset(new ExtensionPrefs( |
891 prefs_.get(), | 900 prefs_.get(), |
892 GetPath().AppendASCII(ExtensionService::kInstallDirectoryName), | 901 GetPath().AppendASCII(ExtensionService::kInstallDirectoryName), |
893 GetExtensionPrefValueMap())); | 902 GetExtensionPrefValueMap())); |
894 | 903 |
895 ProfileDependencyManager::GetInstance()->CreateProfileServices(this, false); | 904 ProfileDependencyManager::GetInstance()->CreateProfileServices(this, false); |
896 | 905 |
897 DCHECK(!net_pref_observer_.get()); | 906 DCHECK(!net_pref_observer_.get()); |
898 net_pref_observer_.reset( | 907 net_pref_observer_.reset( |
899 new NetPrefObserver(prefs_.get(), GetPrerenderManager())); | 908 new NetPrefObserver(prefs_.get(), GetPrerenderManager(), predictor_)); |
900 | 909 |
901 DoFinalInit(); | 910 DoFinalInit(); |
902 } | 911 } |
903 | 912 |
904 PrefService* ProfileImpl::GetPrefs() { | 913 PrefService* ProfileImpl::GetPrefs() { |
905 DCHECK(prefs_.get()); // Should explicitly be initialized. | 914 DCHECK(prefs_.get()); // Should explicitly be initialized. |
906 return prefs_.get(); | 915 return prefs_.get(); |
907 } | 916 } |
908 | 917 |
909 PrefService* ProfileImpl::GetOffTheRecordPrefs() { | 918 PrefService* ProfileImpl::GetOffTheRecordPrefs() { |
(...skipping 829 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1739 new prerender::PrerenderManager( | 1748 new prerender::PrerenderManager( |
1740 this, g_browser_process->prerender_tracker())); | 1749 this, g_browser_process->prerender_tracker())); |
1741 #if defined(OS_CHROMEOS) | 1750 #if defined(OS_CHROMEOS) |
1742 prerender_manager_->AddCondition( | 1751 prerender_manager_->AddCondition( |
1743 new chromeos::PrerenderConditionNetwork( | 1752 new chromeos::PrerenderConditionNetwork( |
1744 chromeos::CrosLibrary::Get()->GetNetworkLibrary())); | 1753 chromeos::CrosLibrary::Get()->GetNetworkLibrary())); |
1745 #endif | 1754 #endif |
1746 } | 1755 } |
1747 return prerender_manager_.get(); | 1756 return prerender_manager_.get(); |
1748 } | 1757 } |
1758 | |
1759 chrome_browser_net::Predictor* ProfileImpl::GetNetworkPredictor() { | |
1760 return predictor_; | |
1761 } | |
OLD | NEW |