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

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: upload rebase 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 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 ProfileImpl::ProfileImpl(const FilePath& path, 219 ProfileImpl::ProfileImpl(const FilePath& path,
220 Delegate* delegate, 220 Delegate* delegate,
221 CreateMode create_mode) 221 CreateMode create_mode)
222 : path_(path), 222 : path_(path),
223 ALLOW_THIS_IN_INITIALIZER_LIST(visited_link_event_listener_( 223 ALLOW_THIS_IN_INITIALIZER_LIST(visited_link_event_listener_(
224 new VisitedLinkEventListener(this))), 224 new VisitedLinkEventListener(this))),
225 ALLOW_THIS_IN_INITIALIZER_LIST(io_data_(this)), 225 ALLOW_THIS_IN_INITIALIZER_LIST(io_data_(this)),
226 host_content_settings_map_(NULL), 226 host_content_settings_map_(NULL),
227 history_service_created_(false), 227 history_service_created_(false),
228 favicon_service_created_(false), 228 favicon_service_created_(false),
229 created_web_data_service_(false),
230 start_time_(Time::Now()), 229 start_time_(Time::Now()),
231 delegate_(delegate), 230 delegate_(delegate),
232 predictor_(NULL), 231 predictor_(NULL),
233 session_restore_enabled_(false) { 232 session_restore_enabled_(false) {
234 DCHECK(!path.empty()) << "Using an empty path will attempt to write " << 233 DCHECK(!path.empty()) << "Using an empty path will attempt to write " <<
235 "profile files to the root directory!"; 234 "profile files to the root directory!";
236 235
237 #if defined(ENABLE_SESSION_SERVICE) 236 #if defined(ENABLE_SESSION_SERVICE)
238 create_session_service_timer_.Start(FROM_HERE, 237 create_session_service_timer_.Start(FROM_HERE,
239 TimeDelta::FromMilliseconds(kCreateSessionServiceDelayMS), this, 238 TimeDelta::FromMilliseconds(kCreateSessionServiceDelayMS), this,
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
475 if (io_data_.HasMainRequestContext() && 474 if (io_data_.HasMainRequestContext() &&
476 default_request_context_ == GetRequestContext()) { 475 default_request_context_ == GetRequestContext()) {
477 default_request_context_ = NULL; 476 default_request_context_ = NULL;
478 } 477 }
479 478
480 // Destroy OTR profile and its profile services first. 479 // Destroy OTR profile and its profile services first.
481 DestroyOffTheRecordProfile(); 480 DestroyOffTheRecordProfile();
482 481
483 ProfileDependencyManager::GetInstance()->DestroyProfileServices(this); 482 ProfileDependencyManager::GetInstance()->DestroyProfileServices(this);
484 483
485 // Both HistoryService and WebDataService maintain threads for background 484 // HistoryService maintains threads for background
486 // processing. Its possible each thread still has tasks on it that have 485 // processing. Its possible each thread still has tasks on it that have
487 // increased the ref count of the service. In such a situation, when we 486 // increased the ref count of the service. In such a situation, when we
488 // decrement the refcount, it won't be 0, and the threads/databases aren't 487 // decrement the refcount, it won't be 0, and the threads/databases aren't
489 // properly shut down. By explicitly calling Cleanup/Shutdown we ensure the 488 // properly shut down. By explicitly calling Cleanup/Shutdown we ensure the
490 // databases are properly closed. 489 // databases are properly closed.
491 if (web_data_service_.get())
492 web_data_service_->Shutdown();
493 490
494 if (top_sites_.get()) 491 if (top_sites_.get())
495 top_sites_->Shutdown(); 492 top_sites_->Shutdown();
496 493
497 if (bookmark_bar_model_.get()) { 494 if (bookmark_bar_model_.get()) {
498 // It's possible that bookmarks haven't loaded and history is waiting for 495 // It's possible that bookmarks haven't loaded and history is waiting for
499 // bookmarks to complete loading. In such a situation history can't shutdown 496 // bookmarks to complete loading. In such a situation history can't shutdown
500 // (meaning if we invoked history_service_->Cleanup now, we would 497 // (meaning if we invoked history_service_->Cleanup now, we would
501 // deadlock). To break the deadlock we tell BookmarkModel it's about to be 498 // deadlock). To break the deadlock we tell BookmarkModel it's about to be
502 // deleted so that it can release the signal history is waiting on, allowing 499 // deleted so that it can release the signal history is waiting on, allowing
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
806 history::ShortcutsBackend* ProfileImpl::GetShortcutsBackend() { 803 history::ShortcutsBackend* ProfileImpl::GetShortcutsBackend() {
807 // This is called on one thread only - UI, so no magic is needed to protect 804 // This is called on one thread only - UI, so no magic is needed to protect
808 // against the multiple concurrent calls. 805 // against the multiple concurrent calls.
809 if (!shortcuts_backend_.get()) { 806 if (!shortcuts_backend_.get()) {
810 shortcuts_backend_ = new history::ShortcutsBackend(GetPath(), this); 807 shortcuts_backend_ = new history::ShortcutsBackend(GetPath(), this);
811 CHECK(shortcuts_backend_->Init()); 808 CHECK(shortcuts_backend_->Init());
812 } 809 }
813 return shortcuts_backend_.get(); 810 return shortcuts_backend_.get();
814 } 811 }
815 812
816 WebDataService* ProfileImpl::GetWebDataService(ServiceAccessType sat) {
817 if (!created_web_data_service_)
818 CreateWebDataService();
819 return web_data_service_.get();
820 }
821
822 WebDataService* ProfileImpl::GetWebDataServiceWithoutCreating() {
823 return web_data_service_.get();
824 }
825
826 void ProfileImpl::CreateWebDataService() {
827 DCHECK(!created_web_data_service_ && web_data_service_.get() == NULL);
828 created_web_data_service_ = true;
829 scoped_refptr<WebDataService> wds(new WebDataService());
830 if (!wds->Init(GetPath()))
831 return;
832 web_data_service_.swap(wds);
833 }
834
835 DownloadManager* ProfileImpl::GetDownloadManager() { 813 DownloadManager* ProfileImpl::GetDownloadManager() {
836 return DownloadServiceFactory::GetForProfile(this)->GetDownloadManager(); 814 return DownloadServiceFactory::GetForProfile(this)->GetDownloadManager();
837 } 815 }
838 816
839 bool ProfileImpl::DidLastSessionExitCleanly() { 817 bool ProfileImpl::DidLastSessionExitCleanly() {
840 // last_session_exited_cleanly_ is set when the preferences are loaded. Force 818 // last_session_exited_cleanly_ is set when the preferences are loaded. Force
841 // it to be set by asking for the prefs. 819 // it to be set by asking for the prefs.
842 GetPrefs(); 820 GetPrefs();
843 return last_session_exited_cleanly_; 821 return last_session_exited_cleanly_;
844 } 822 }
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
1163 FilePath* cache_path, 1141 FilePath* cache_path,
1164 int* max_size) { 1142 int* max_size) {
1165 DCHECK(cache_path); 1143 DCHECK(cache_path);
1166 DCHECK(max_size); 1144 DCHECK(max_size);
1167 FilePath path(prefs_->GetFilePath(prefs::kDiskCacheDir)); 1145 FilePath path(prefs_->GetFilePath(prefs::kDiskCacheDir));
1168 if (!path.empty()) 1146 if (!path.empty())
1169 *cache_path = path; 1147 *cache_path = path;
1170 *max_size = is_media_context ? prefs_->GetInteger(prefs::kMediaCacheSize) : 1148 *max_size = is_media_context ? prefs_->GetInteger(prefs::kMediaCacheSize) :
1171 prefs_->GetInteger(prefs::kDiskCacheSize); 1149 prefs_->GetInteger(prefs::kDiskCacheSize);
1172 } 1150 }
OLDNEW
« no previous file with comments | « chrome/browser/profiles/profile_impl.h ('k') | chrome/browser/search_engines/search_provider_install_data.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698