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

Side by Side Diff: chrome/browser/profiles/profile_impl.cc

Issue 9834056: Moved WebDataService to ProfileKeyedService (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed comments, fixed bug Created 8 years, 8 months 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) 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 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 Delegate* delegate, 225 Delegate* delegate,
226 CreateMode create_mode) 226 CreateMode create_mode)
227 : path_(path), 227 : path_(path),
228 ALLOW_THIS_IN_INITIALIZER_LIST(visited_link_event_listener_( 228 ALLOW_THIS_IN_INITIALIZER_LIST(visited_link_event_listener_(
229 new VisitedLinkEventListener(this))), 229 new VisitedLinkEventListener(this))),
230 ALLOW_THIS_IN_INITIALIZER_LIST(io_data_(this)), 230 ALLOW_THIS_IN_INITIALIZER_LIST(io_data_(this)),
231 extension_devtools_manager_(NULL), 231 extension_devtools_manager_(NULL),
232 host_content_settings_map_(NULL), 232 host_content_settings_map_(NULL),
233 history_service_created_(false), 233 history_service_created_(false),
234 favicon_service_created_(false), 234 favicon_service_created_(false),
235 created_web_data_service_(false),
236 start_time_(Time::Now()), 235 start_time_(Time::Now()),
237 #if defined(OS_WIN) 236 #if defined(OS_WIN)
238 checked_instant_promo_(false), 237 checked_instant_promo_(false),
239 #endif 238 #endif
240 delegate_(delegate), 239 delegate_(delegate),
241 predictor_(NULL), 240 predictor_(NULL),
242 session_restore_enabled_(false) { 241 session_restore_enabled_(false) {
243 DCHECK(!path.empty()) << "Using an empty path will attempt to write " << 242 DCHECK(!path.empty()) << "Using an empty path will attempt to write " <<
244 "profile files to the root directory!"; 243 "profile files to the root directory!";
245 244
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after
581 if (io_data_.HasMainRequestContext() && 580 if (io_data_.HasMainRequestContext() &&
582 default_request_context_ == GetRequestContext()) { 581 default_request_context_ == GetRequestContext()) {
583 default_request_context_ = NULL; 582 default_request_context_ = NULL;
584 } 583 }
585 584
586 // Destroy OTR profile and its profile services first. 585 // Destroy OTR profile and its profile services first.
587 DestroyOffTheRecordProfile(); 586 DestroyOffTheRecordProfile();
588 587
589 ProfileDependencyManager::GetInstance()->DestroyProfileServices(this); 588 ProfileDependencyManager::GetInstance()->DestroyProfileServices(this);
590 589
591 // Both HistoryService and WebDataService maintain threads for background 590 // HistoryService maintains threads for background
592 // processing. Its possible each thread still has tasks on it that have 591 // processing. Its possible each thread still has tasks on it that have
593 // increased the ref count of the service. In such a situation, when we 592 // increased the ref count of the service. In such a situation, when we
594 // decrement the refcount, it won't be 0, and the threads/databases aren't 593 // decrement the refcount, it won't be 0, and the threads/databases aren't
595 // properly shut down. By explicitly calling Cleanup/Shutdown we ensure the 594 // properly shut down. By explicitly calling Cleanup/Shutdown we ensure the
596 // databases are properly closed. 595 // databases are properly closed.
597 if (web_data_service_.get())
598 web_data_service_->Shutdown();
599 596
600 if (top_sites_.get()) 597 if (top_sites_.get())
601 top_sites_->Shutdown(); 598 top_sites_->Shutdown();
602 599
603 if (bookmark_bar_model_.get()) { 600 if (bookmark_bar_model_.get()) {
604 // It's possible that bookmarks haven't loaded and history is waiting for 601 // It's possible that bookmarks haven't loaded and history is waiting for
605 // bookmarks to complete loading. In such a situation history can't shutdown 602 // bookmarks to complete loading. In such a situation history can't shutdown
606 // (meaning if we invoked history_service_->Cleanup now, we would 603 // (meaning if we invoked history_service_->Cleanup now, we would
607 // deadlock). To break the deadlock we tell BookmarkModel it's about to be 604 // deadlock). To break the deadlock we tell BookmarkModel it's about to be
608 // deleted so that it can release the signal history is waiting on, allowing 605 // 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
965 history::ShortcutsBackend* ProfileImpl::GetShortcutsBackend() { 962 history::ShortcutsBackend* ProfileImpl::GetShortcutsBackend() {
966 // This is called on one thread only - UI, so no magic is needed to protect 963 // This is called on one thread only - UI, so no magic is needed to protect
967 // against the multiple concurrent calls. 964 // against the multiple concurrent calls.
968 if (!shortcuts_backend_.get()) { 965 if (!shortcuts_backend_.get()) {
969 shortcuts_backend_ = new history::ShortcutsBackend(GetPath(), this); 966 shortcuts_backend_ = new history::ShortcutsBackend(GetPath(), this);
970 CHECK(shortcuts_backend_->Init()); 967 CHECK(shortcuts_backend_->Init());
971 } 968 }
972 return shortcuts_backend_.get(); 969 return shortcuts_backend_.get();
973 } 970 }
974 971
975 WebDataService* ProfileImpl::GetWebDataService(ServiceAccessType sat) {
976 if (!created_web_data_service_)
977 CreateWebDataService();
978 return web_data_service_.get();
979 }
980
981 WebDataService* ProfileImpl::GetWebDataServiceWithoutCreating() {
982 return web_data_service_.get();
983 }
984
985 void ProfileImpl::CreateWebDataService() {
986 DCHECK(!created_web_data_service_ && web_data_service_.get() == NULL);
987 created_web_data_service_ = true;
988 scoped_refptr<WebDataService> wds(new WebDataService());
989 if (!wds->Init(GetPath()))
990 return;
991 web_data_service_.swap(wds);
992 }
993
994 DownloadManager* ProfileImpl::GetDownloadManager() { 972 DownloadManager* ProfileImpl::GetDownloadManager() {
995 return DownloadServiceFactory::GetForProfile(this)->GetDownloadManager(); 973 return DownloadServiceFactory::GetForProfile(this)->GetDownloadManager();
996 } 974 }
997 975
998 bool ProfileImpl::DidLastSessionExitCleanly() { 976 bool ProfileImpl::DidLastSessionExitCleanly() {
999 // last_session_exited_cleanly_ is set when the preferences are loaded. Force 977 // last_session_exited_cleanly_ is set when the preferences are loaded. Force
1000 // it to be set by asking for the prefs. 978 // it to be set by asking for the prefs.
1001 GetPrefs(); 979 GetPrefs();
1002 return last_session_exited_cleanly_; 980 return last_session_exited_cleanly_;
1003 } 981 }
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
1346 FilePath* cache_path, 1324 FilePath* cache_path,
1347 int* max_size) { 1325 int* max_size) {
1348 DCHECK(cache_path); 1326 DCHECK(cache_path);
1349 DCHECK(max_size); 1327 DCHECK(max_size);
1350 FilePath path(prefs_->GetFilePath(prefs::kDiskCacheDir)); 1328 FilePath path(prefs_->GetFilePath(prefs::kDiskCacheDir));
1351 if (!path.empty()) 1329 if (!path.empty())
1352 *cache_path = path; 1330 *cache_path = path;
1353 *max_size = is_media_context ? prefs_->GetInteger(prefs::kMediaCacheSize) : 1331 *max_size = is_media_context ? prefs_->GetInteger(prefs::kMediaCacheSize) :
1354 prefs_->GetInteger(prefs::kDiskCacheSize); 1332 prefs_->GetInteger(prefs::kDiskCacheSize);
1355 } 1333 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698