OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/environment.h" | 10 #include "base/environment.h" |
(...skipping 571 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
582 DestroyOffTheRecordProfile(); | 582 DestroyOffTheRecordProfile(); |
583 | 583 |
584 ProfileDependencyManager::GetInstance()->DestroyProfileServices(this); | 584 ProfileDependencyManager::GetInstance()->DestroyProfileServices(this); |
585 | 585 |
586 // Both HistoryService and WebDataService maintain threads for background | 586 // Both HistoryService and WebDataService maintain threads for background |
587 // processing. Its possible each thread still has tasks on it that have | 587 // processing. Its possible each thread still has tasks on it that have |
588 // increased the ref count of the service. In such a situation, when we | 588 // increased the ref count of the service. In such a situation, when we |
589 // decrement the refcount, it won't be 0, and the threads/databases aren't | 589 // decrement the refcount, it won't be 0, and the threads/databases aren't |
590 // properly shut down. By explicitly calling Cleanup/Shutdown we ensure the | 590 // properly shut down. By explicitly calling Cleanup/Shutdown we ensure the |
591 // databases are properly closed. | 591 // databases are properly closed. |
592 if (web_data_service_.get()) | 592 if (web_data_service_.get()) |
rpetterson
2012/03/27 01:15:06
Should this even be here? The profile shouldn't ev
GeorgeY
2012/03/30 19:20:12
yes removed and adjusted the comment
| |
593 web_data_service_->Shutdown(); | 593 web_data_service_ = NULL; |
594 | 594 |
595 if (top_sites_.get()) | 595 if (top_sites_.get()) |
596 top_sites_->Shutdown(); | 596 top_sites_->Shutdown(); |
597 | 597 |
598 if (bookmark_bar_model_.get()) { | 598 if (bookmark_bar_model_.get()) { |
599 // It's possible that bookmarks haven't loaded and history is waiting for | 599 // It's possible that bookmarks haven't loaded and history is waiting for |
600 // bookmarks to complete loading. In such a situation history can't shutdown | 600 // bookmarks to complete loading. In such a situation history can't shutdown |
601 // (meaning if we invoked history_service_->Cleanup now, we would | 601 // (meaning if we invoked history_service_->Cleanup now, we would |
602 // deadlock). To break the deadlock we tell BookmarkModel it's about to be | 602 // deadlock). To break the deadlock we tell BookmarkModel it's about to be |
603 // deleted so that it can release the signal history is waiting on, allowing | 603 // deleted so that it can release the signal history is waiting on, allowing |
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
960 history::ShortcutsBackend* ProfileImpl::GetShortcutsBackend() { | 960 history::ShortcutsBackend* ProfileImpl::GetShortcutsBackend() { |
961 // This is called on one thread only - UI, so no magic is needed to protect | 961 // This is called on one thread only - UI, so no magic is needed to protect |
962 // against the multiple concurrent calls. | 962 // against the multiple concurrent calls. |
963 if (!shortcuts_backend_.get()) { | 963 if (!shortcuts_backend_.get()) { |
964 shortcuts_backend_ = new history::ShortcutsBackend(GetPath(), this); | 964 shortcuts_backend_ = new history::ShortcutsBackend(GetPath(), this); |
965 CHECK(shortcuts_backend_->Init()); | 965 CHECK(shortcuts_backend_->Init()); |
966 } | 966 } |
967 return shortcuts_backend_.get(); | 967 return shortcuts_backend_.get(); |
968 } | 968 } |
969 | 969 |
970 WebDataService* ProfileImpl::GetWebDataService(ServiceAccessType sat) { | |
971 if (!created_web_data_service_) | |
972 CreateWebDataService(); | |
973 return web_data_service_.get(); | |
974 } | |
975 | |
976 WebDataService* ProfileImpl::GetWebDataServiceWithoutCreating() { | |
977 return web_data_service_.get(); | |
978 } | |
979 | |
980 void ProfileImpl::CreateWebDataService() { | |
981 DCHECK(!created_web_data_service_ && web_data_service_.get() == NULL); | |
982 created_web_data_service_ = true; | |
983 scoped_refptr<WebDataService> wds(new WebDataService()); | |
984 if (!wds->Init(GetPath())) | |
985 return; | |
986 web_data_service_.swap(wds); | |
987 } | |
988 | |
989 DownloadManager* ProfileImpl::GetDownloadManager() { | 970 DownloadManager* ProfileImpl::GetDownloadManager() { |
990 return DownloadServiceFactory::GetForProfile(this)->GetDownloadManager(); | 971 return DownloadServiceFactory::GetForProfile(this)->GetDownloadManager(); |
991 } | 972 } |
992 | 973 |
993 bool ProfileImpl::DidLastSessionExitCleanly() { | 974 bool ProfileImpl::DidLastSessionExitCleanly() { |
994 // last_session_exited_cleanly_ is set when the preferences are loaded. Force | 975 // last_session_exited_cleanly_ is set when the preferences are loaded. Force |
995 // it to be set by asking for the prefs. | 976 // it to be set by asking for the prefs. |
996 GetPrefs(); | 977 GetPrefs(); |
997 return last_session_exited_cleanly_; | 978 return last_session_exited_cleanly_; |
998 } | 979 } |
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1341 FilePath* cache_path, | 1322 FilePath* cache_path, |
1342 int* max_size) { | 1323 int* max_size) { |
1343 DCHECK(cache_path); | 1324 DCHECK(cache_path); |
1344 DCHECK(max_size); | 1325 DCHECK(max_size); |
1345 FilePath path(prefs_->GetFilePath(prefs::kDiskCacheDir)); | 1326 FilePath path(prefs_->GetFilePath(prefs::kDiskCacheDir)); |
1346 if (!path.empty()) | 1327 if (!path.empty()) |
1347 *cache_path = path; | 1328 *cache_path = path; |
1348 *max_size = is_media_context ? prefs_->GetInteger(prefs::kMediaCacheSize) : | 1329 *max_size = is_media_context ? prefs_->GetInteger(prefs::kMediaCacheSize) : |
1349 prefs_->GetInteger(prefs::kDiskCacheSize); | 1330 prefs_->GetInteger(prefs::kDiskCacheSize); |
1350 } | 1331 } |
OLD | NEW |