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

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

Issue 9232011: sync: Make ProfileSyncService a ProfileKeyedService. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years, 11 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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 #include "chrome/browser/profiles/gaia_info_update_service.h" 67 #include "chrome/browser/profiles/gaia_info_update_service.h"
68 #include "chrome/browser/profiles/profile_dependency_manager.h" 68 #include "chrome/browser/profiles/profile_dependency_manager.h"
69 #include "chrome/browser/profiles/profile_info_cache.h" 69 #include "chrome/browser/profiles/profile_info_cache.h"
70 #include "chrome/browser/profiles/profile_manager.h" 70 #include "chrome/browser/profiles/profile_manager.h"
71 #include "chrome/browser/search_engines/template_url_fetcher.h" 71 #include "chrome/browser/search_engines/template_url_fetcher.h"
72 #include "chrome/browser/search_engines/template_url_service.h" 72 #include "chrome/browser/search_engines/template_url_service.h"
73 #include "chrome/browser/sessions/session_service_factory.h" 73 #include "chrome/browser/sessions/session_service_factory.h"
74 #include "chrome/browser/speech/chrome_speech_input_manager.h" 74 #include "chrome/browser/speech/chrome_speech_input_manager.h"
75 #include "chrome/browser/speech/chrome_speech_input_preferences.h" 75 #include "chrome/browser/speech/chrome_speech_input_preferences.h"
76 #include "chrome/browser/spellchecker/spellcheck_profile.h" 76 #include "chrome/browser/spellchecker/spellcheck_profile.h"
77 #include "chrome/browser/sync/profile_sync_components_factory_impl.h" 77 #include "chrome/browser/sync/profile_sync_service_factory.h"
78 #include "chrome/browser/sync/profile_sync_service.h"
79 #include "chrome/browser/tabs/pinned_tab_service_factory.h" 78 #include "chrome/browser/tabs/pinned_tab_service_factory.h"
80 #include "chrome/browser/transport_security_persister.h" 79 #include "chrome/browser/transport_security_persister.h"
81 #include "chrome/browser/ui/browser_init.h" 80 #include "chrome/browser/ui/browser_init.h"
82 #include "chrome/browser/ui/browser_list.h" 81 #include "chrome/browser/ui/browser_list.h"
83 #include "chrome/browser/ui/find_bar/find_bar_state.h" 82 #include "chrome/browser/ui/find_bar/find_bar_state.h"
84 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" 83 #include "chrome/browser/ui/webui/chrome_url_data_manager.h"
85 #include "chrome/browser/ui/webui/extensions/extension_icon_source.h" 84 #include "chrome/browser/ui/webui/extensions/extension_icon_source.h"
86 #include "chrome/browser/user_style_sheet_watcher.h" 85 #include "chrome/browser/user_style_sheet_watcher.h"
87 #include "chrome/browser/visitedlink/visitedlink_event_listener.h" 86 #include "chrome/browser/visitedlink/visitedlink_event_listener.h"
88 #include "chrome/browser/visitedlink/visitedlink_master.h" 87 #include "chrome/browser/visitedlink/visitedlink_master.h"
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 247
249 ProfileImpl::ProfileImpl(const FilePath& path, 248 ProfileImpl::ProfileImpl(const FilePath& path,
250 Profile::Delegate* delegate) 249 Profile::Delegate* delegate)
251 : path_(path), 250 : path_(path),
252 ALLOW_THIS_IN_INITIALIZER_LIST(visited_link_event_listener_( 251 ALLOW_THIS_IN_INITIALIZER_LIST(visited_link_event_listener_(
253 new VisitedLinkEventListener(this))), 252 new VisitedLinkEventListener(this))),
254 ALLOW_THIS_IN_INITIALIZER_LIST(io_data_(this)), 253 ALLOW_THIS_IN_INITIALIZER_LIST(io_data_(this)),
255 extension_devtools_manager_(NULL), 254 extension_devtools_manager_(NULL),
256 host_content_settings_map_(NULL), 255 host_content_settings_map_(NULL),
257 host_zoom_map_(NULL), 256 host_zoom_map_(NULL),
258 profile_sync_service_created_(false),
259 history_service_created_(false), 257 history_service_created_(false),
260 favicon_service_created_(false), 258 favicon_service_created_(false),
261 created_web_data_service_(false), 259 created_web_data_service_(false),
262 created_password_store_(false), 260 created_password_store_(false),
263 start_time_(Time::Now()), 261 start_time_(Time::Now()),
264 #if defined(OS_WIN) 262 #if defined(OS_WIN)
265 checked_instant_promo_(false), 263 checked_instant_promo_(false),
266 #endif 264 #endif
267 delegate_(delegate), 265 delegate_(delegate),
268 predictor_(NULL), 266 predictor_(NULL),
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after
567 BrowserThread::IO, FROM_HERE, 565 BrowserThread::IO, FROM_HERE,
568 base::Bind(&appcache::AppCacheService::set_clear_local_state_on_exit, 566 base::Bind(&appcache::AppCacheService::set_clear_local_state_on_exit,
569 appcache_service_.get(), true)); 567 appcache_service_.get(), true));
570 } 568 }
571 569
572 StopCreateSessionServiceTimer(); 570 StopCreateSessionServiceTimer();
573 571
574 // Remove pref observers 572 // Remove pref observers
575 pref_change_registrar_.RemoveAll(); 573 pref_change_registrar_.RemoveAll();
576 574
577 // The sync service needs to be deleted before the services it calls.
578 // TODO(stevet): Make ProfileSyncService into a PKS and let the PDM take care
579 // of the cleanup below.
580 sync_service_.reset();
581
582 ChromePluginServiceFilter::GetInstance()->UnregisterResourceContext( 575 ChromePluginServiceFilter::GetInstance()->UnregisterResourceContext(
583 &io_data_.GetResourceContextNoInit()); 576 &io_data_.GetResourceContextNoInit());
584 577
585 if (io_data_.HasMainRequestContext() && 578 if (io_data_.HasMainRequestContext() &&
586 default_request_context_ == GetRequestContext()) { 579 default_request_context_ == GetRequestContext()) {
587 default_request_context_ = NULL; 580 default_request_context_ = NULL;
588 } 581 }
589 582
590 ProfileDependencyManager::GetInstance()->DestroyProfileServices(this); 583 ProfileDependencyManager::GetInstance()->DestroyProfileServices(this);
591 584
(...skipping 574 matching lines...) Expand 10 before | Expand all | Expand 10 after
1166 fileapi::FileSystemContext* ProfileImpl::GetFileSystemContext() { 1159 fileapi::FileSystemContext* ProfileImpl::GetFileSystemContext() {
1167 CreateQuotaManagerAndClients(); 1160 CreateQuotaManagerAndClients();
1168 return file_system_context_.get(); 1161 return file_system_context_.get();
1169 } 1162 }
1170 1163
1171 quota::QuotaManager* ProfileImpl::GetQuotaManager() { 1164 quota::QuotaManager* ProfileImpl::GetQuotaManager() {
1172 CreateQuotaManagerAndClients(); 1165 CreateQuotaManagerAndClients();
1173 return quota_manager_.get(); 1166 return quota_manager_.get();
1174 } 1167 }
1175 1168
1176 bool ProfileImpl::HasProfileSyncService() const { 1169 bool ProfileImpl::HasProfileSyncService() {
1177 return (sync_service_.get() != NULL); 1170 return ProfileSyncServiceFactory::GetInstance()->HasProfileSyncService(this);
1178 } 1171 }
1179 1172
1180 bool ProfileImpl::DidLastSessionExitCleanly() { 1173 bool ProfileImpl::DidLastSessionExitCleanly() {
1181 // last_session_exited_cleanly_ is set when the preferences are loaded. Force 1174 // last_session_exited_cleanly_ is set when the preferences are loaded. Force
1182 // it to be set by asking for the prefs. 1175 // it to be set by asking for the prefs.
1183 GetPrefs(); 1176 GetPrefs();
1184 return last_session_exited_cleanly_; 1177 return last_session_exited_cleanly_;
1185 } 1178 }
1186 1179
1187 BookmarkModel* ProfileImpl::GetBookmarkModel() { 1180 BookmarkModel* ProfileImpl::GetBookmarkModel() {
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
1404 } 1397 }
1405 1398
1406 TokenService* ProfileImpl::GetTokenService() { 1399 TokenService* ProfileImpl::GetTokenService() {
1407 if (!token_service_.get()) { 1400 if (!token_service_.get()) {
1408 token_service_.reset(new TokenService()); 1401 token_service_.reset(new TokenService());
1409 } 1402 }
1410 return token_service_.get(); 1403 return token_service_.get();
1411 } 1404 }
1412 1405
1413 ProfileSyncService* ProfileImpl::GetProfileSyncService() { 1406 ProfileSyncService* ProfileImpl::GetProfileSyncService() {
1414 if (!ProfileSyncService::IsSyncEnabled()) 1407 return ProfileSyncServiceFactory::GetInstance()->GetForProfile(this);
1415 return NULL;
1416 if (!profile_sync_service_created_) {
1417 profile_sync_service_created_ = true;
1418 InitSyncService();
1419 }
1420 return sync_service_.get();
1421 }
1422
1423 void ProfileImpl::InitSyncService() {
1424 profile_sync_factory_.reset(
1425 new ProfileSyncComponentsFactoryImpl(this,
1426 CommandLine::ForCurrentProcess()));
1427 sync_service_.reset(profile_sync_factory_->CreateProfileSyncService());
1428 profile_sync_factory_->RegisterDataTypes(sync_service_.get());
1429 sync_service_->Initialize();
1430 } 1408 }
1431 1409
1432 ChromeBlobStorageContext* ProfileImpl::GetBlobStorageContext() { 1410 ChromeBlobStorageContext* ProfileImpl::GetBlobStorageContext() {
1433 if (!blob_storage_context_) { 1411 if (!blob_storage_context_) {
1434 blob_storage_context_ = new ChromeBlobStorageContext(); 1412 blob_storage_context_ = new ChromeBlobStorageContext();
1435 BrowserThread::PostTask( 1413 BrowserThread::PostTask(
1436 BrowserThread::IO, FROM_HERE, 1414 BrowserThread::IO, FROM_HERE,
1437 base::Bind(&ChromeBlobStorageContext::InitializeOnIOThread, 1415 base::Bind(&ChromeBlobStorageContext::InitializeOnIOThread,
1438 blob_storage_context_.get())); 1416 blob_storage_context_.get()));
1439 } 1417 }
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
1673 FilePath* cache_path, 1651 FilePath* cache_path,
1674 int* max_size) { 1652 int* max_size) {
1675 DCHECK(cache_path); 1653 DCHECK(cache_path);
1676 DCHECK(max_size); 1654 DCHECK(max_size);
1677 FilePath path(prefs_->GetFilePath(prefs::kDiskCacheDir)); 1655 FilePath path(prefs_->GetFilePath(prefs::kDiskCacheDir));
1678 if (!path.empty()) 1656 if (!path.empty())
1679 *cache_path = path; 1657 *cache_path = path;
1680 *max_size = is_media_context ? prefs_->GetInteger(prefs::kMediaCacheSize) : 1658 *max_size = is_media_context ? prefs_->GetInteger(prefs::kMediaCacheSize) :
1681 prefs_->GetInteger(prefs::kDiskCacheSize); 1659 prefs_->GetInteger(prefs::kDiskCacheSize);
1682 } 1660 }
OLDNEW
« no previous file with comments | « chrome/browser/profiles/profile_impl.h ('k') | chrome/browser/sync/abstract_profile_sync_service_test.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698