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

Side by Side Diff: components/browser_sync/browser/profile_sync_service.cc

Issue 1421003007: [Sync] Componentize ProfileSyncComponentsFactoryImpl (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix browser_tests Created 5 years, 1 month 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
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 "components/browser_sync/browser/profile_sync_service.h" 5 #include "components/browser_sync/browser/profile_sync_service.h"
6 6
7 #include <cstddef> 7 #include <cstddef>
8 #include <map> 8 #include <map>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 encrypted_types_(syncer::SyncEncryptionHandler::SensitiveTypes()), 204 encrypted_types_(syncer::SyncEncryptionHandler::SensitiveTypes()),
205 encrypt_everything_allowed_(true), 205 encrypt_everything_allowed_(true),
206 encrypt_everything_(false), 206 encrypt_everything_(false),
207 encryption_pending_(false), 207 encryption_pending_(false),
208 configure_status_(DataTypeManager::UNKNOWN), 208 configure_status_(DataTypeManager::UNKNOWN),
209 oauth2_token_service_(oauth2_token_service), 209 oauth2_token_service_(oauth2_token_service),
210 request_access_token_backoff_(&kRequestAccessTokenBackoffPolicy), 210 request_access_token_backoff_(&kRequestAccessTokenBackoffPolicy),
211 connection_status_(syncer::CONNECTION_NOT_ATTEMPTED), 211 connection_status_(syncer::CONNECTION_NOT_ATTEMPTED),
212 last_get_token_error_(GoogleServiceAuthError::AuthErrorNone()), 212 last_get_token_error_(GoogleServiceAuthError::AuthErrorNone()),
213 network_resources_(new syncer::HttpBridgeNetworkResources), 213 network_resources_(new syncer::HttpBridgeNetworkResources),
214 start_behavior_(start_behavior),
214 backend_mode_(IDLE), 215 backend_mode_(IDLE),
215 need_backup_(false), 216 need_backup_(false),
216 backup_finished_(false), 217 backup_finished_(false),
217 catch_up_configure_in_progress_(false), 218 catch_up_configure_in_progress_(false),
218 passphrase_prompt_triggered_by_version_(false), 219 passphrase_prompt_triggered_by_version_(false),
219 weak_factory_(this), 220 weak_factory_(this),
220 startup_controller_weak_factory_(this) { 221 startup_controller_weak_factory_(this) {
221 DCHECK(thread_checker_.CalledOnValidThread()); 222 DCHECK(thread_checker_.CalledOnValidThread());
222 DCHECK(sync_client_); 223 DCHECK(sync_client_);
223 startup_controller_.reset(new browser_sync::StartupController(
224 start_behavior,
225 oauth2_token_service,
226 &sync_prefs_,
227 signin_.get(),
228 base::Bind(&ProfileSyncService::StartUpSlowBackendComponents,
229 startup_controller_weak_factory_.GetWeakPtr(),
230 SYNC)));
231 backup_rollback_controller_.reset(new sync_driver::BackupRollbackController(
232 &sync_prefs_,
233 signin_.get(),
234 base::Bind(&ProfileSyncService::StartUpSlowBackendComponents,
235 startup_controller_weak_factory_.GetWeakPtr(),
236 BACKUP),
237 base::Bind(&ProfileSyncService::StartUpSlowBackendComponents,
238 startup_controller_weak_factory_.GetWeakPtr(),
239 ROLLBACK)));
240 scoped_ptr<browser_sync::LocalSessionEventRouter> router(
241 sync_client_->GetSyncSessionsClient()->GetLocalSessionEventRouter());
242 local_device_ = sync_client_->GetSyncApiComponentFactory()
243 ->CreateLocalDeviceInfoProvider();
244 sync_stopped_reporter_.reset(new browser_sync::SyncStoppedReporter(
245 sync_service_url_, local_device_->GetSyncUserAgent(),
246 url_request_context_,
247 browser_sync::SyncStoppedReporter::ResultCallback()));
248 sessions_sync_manager_.reset(new SessionsSyncManager(
249 sync_client_->GetSyncSessionsClient(), &sync_prefs_, local_device_.get(),
250 router.Pass(),
251 base::Bind(&ProfileSyncService::NotifyForeignSessionUpdated,
252 weak_factory_.GetWeakPtr()),
253 base::Bind(&ProfileSyncService::TriggerRefresh,
254 weak_factory_.GetWeakPtr(),
255 syncer::ModelTypeSet(syncer::SESSIONS))));
256 device_info_sync_service_.reset(
257 new DeviceInfoSyncService(local_device_.get()));
258
259 std::string last_version = sync_prefs_.GetLastRunVersion(); 224 std::string last_version = sync_prefs_.GetLastRunVersion();
260 std::string current_version = PRODUCT_VERSION; 225 std::string current_version = PRODUCT_VERSION;
261 sync_prefs_.SetLastRunVersion(current_version); 226 sync_prefs_.SetLastRunVersion(current_version);
262 227
263 // Check for a major version change. Note that the versions have format 228 // Check for a major version change. Note that the versions have format
264 // MAJOR.MINOR.BUILD.PATCH. 229 // MAJOR.MINOR.BUILD.PATCH.
265 if (last_version.substr(0, last_version.find('.')) != 230 if (last_version.substr(0, last_version.find('.')) !=
266 current_version.substr(0, current_version.find('.'))) { 231 current_version.substr(0, current_version.find('.'))) {
267 passphrase_prompt_triggered_by_version_ = true; 232 passphrase_prompt_triggered_by_version_ = true;
268 } 233 }
(...skipping 11 matching lines...) Expand all
280 245
281 bool ProfileSyncService::IsOAuthRefreshTokenAvailable() { 246 bool ProfileSyncService::IsOAuthRefreshTokenAvailable() {
282 if (!oauth2_token_service_) 247 if (!oauth2_token_service_)
283 return false; 248 return false;
284 249
285 return oauth2_token_service_->RefreshTokenIsAvailable( 250 return oauth2_token_service_->RefreshTokenIsAvailable(
286 signin_->GetAccountIdToUse()); 251 signin_->GetAccountIdToUse());
287 } 252 }
288 253
289 void ProfileSyncService::Initialize() { 254 void ProfileSyncService::Initialize() {
290 sync_client_->Initialize(this); 255 startup_controller_.reset(new browser_sync::StartupController(
256 start_behavior_, oauth2_token_service_, &sync_prefs_, signin_.get(),
257 base::Bind(&ProfileSyncService::StartUpSlowBackendComponents,
258 startup_controller_weak_factory_.GetWeakPtr(), SYNC)));
259 backup_rollback_controller_.reset(new sync_driver::BackupRollbackController(
260 &sync_prefs_,
261 signin_.get(),
262 base::Bind(&ProfileSyncService::StartUpSlowBackendComponents,
263 startup_controller_weak_factory_.GetWeakPtr(),
264 BACKUP),
265 base::Bind(&ProfileSyncService::StartUpSlowBackendComponents,
266 startup_controller_weak_factory_.GetWeakPtr(),
267 ROLLBACK)));
268 scoped_ptr<browser_sync::LocalSessionEventRouter> router(
269 sync_client_->GetSyncSessionsClient()->GetLocalSessionEventRouter());
270 local_device_ = sync_client_->GetSyncApiComponentFactory()
271 ->CreateLocalDeviceInfoProvider();
272 sync_stopped_reporter_.reset(new browser_sync::SyncStoppedReporter(
273 sync_service_url_, local_device_->GetSyncUserAgent(),
274 url_request_context_,
275 browser_sync::SyncStoppedReporter::ResultCallback()));
276 sessions_sync_manager_.reset(new SessionsSyncManager(
277 sync_client_->GetSyncSessionsClient(), &sync_prefs_, local_device_.get(),
278 router.Pass(),
279 base::Bind(&ProfileSyncService::NotifyForeignSessionUpdated,
280 weak_factory_.GetWeakPtr()),
281 base::Bind(&ProfileSyncService::TriggerRefresh,
282 weak_factory_.GetWeakPtr(),
283 syncer::ModelTypeSet(syncer::SESSIONS))));
284 device_info_sync_service_.reset(
285 new DeviceInfoSyncService(local_device_.get()));
286
287 sync_driver::SyncApiComponentFactory::RegisterDataTypesMethod
288 register_platform_types_callback =
289 sync_client_->GetRegisterPlatformTypesCallback();
290 sync_client_->GetSyncApiComponentFactory()->RegisterDataTypes(
291 register_platform_types_callback);
291 292
292 // We clear this here (vs Shutdown) because we want to remember that an error 293 // We clear this here (vs Shutdown) because we want to remember that an error
293 // happened on shutdown so we can display details (message, location) about it 294 // happened on shutdown so we can display details (message, location) about it
294 // in about:sync. 295 // in about:sync.
295 ClearStaleErrors(); 296 ClearStaleErrors();
296 297
297 sync_prefs_.AddSyncPrefObserver(this); 298 sync_prefs_.AddSyncPrefObserver(this);
298 299
299 // If sync isn't allowed, the only thing to do is to turn it off. 300 // If sync isn't allowed, the only thing to do is to turn it off.
300 if (!IsSyncAllowed()) { 301 if (!IsSyncAllowed()) {
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after
665 base::FilePath(kSyncDataFolderName) : 666 base::FilePath(kSyncDataFolderName) :
666 base::FilePath(kSyncBackupDataFolderName); 667 base::FilePath(kSyncBackupDataFolderName);
667 668
668 invalidation::InvalidationService* invalidator = 669 invalidation::InvalidationService* invalidator =
669 backend_mode_ == SYNC ? sync_client_->GetInvalidationService() : nullptr; 670 backend_mode_ == SYNC ? sync_client_->GetInvalidationService() : nullptr;
670 671
671 directory_path_ = base_directory_.Append(sync_folder); 672 directory_path_ = base_directory_.Append(sync_folder);
672 673
673 backend_.reset( 674 backend_.reset(
674 sync_client_->GetSyncApiComponentFactory()->CreateSyncBackendHost( 675 sync_client_->GetSyncApiComponentFactory()->CreateSyncBackendHost(
675 debug_identifier_, sync_client_.get(), invalidator, 676 debug_identifier_, invalidator, sync_prefs_.AsWeakPtr(),
676 sync_prefs_.AsWeakPtr(), directory_path_)); 677 directory_path_));
677 678
678 // Initialize the backend. Every time we start up a new SyncBackendHost, 679 // Initialize the backend. Every time we start up a new SyncBackendHost,
679 // we'll want to start from a fresh SyncDB, so delete any old one that might 680 // we'll want to start from a fresh SyncDB, so delete any old one that might
680 // be there. 681 // be there.
681 InitializeBackend(ShouldDeleteSyncFolder()); 682 InitializeBackend(ShouldDeleteSyncFolder());
682 683
683 UpdateFirstSyncTimePref(); 684 UpdateFirstSyncTimePref();
684 685
685 ReportPreviousSessionMemoryWarningCount(); 686 ReportPreviousSessionMemoryWarningCount();
686 } 687 }
(...skipping 2009 matching lines...) Expand 10 before | Expand all | Expand 10 after
2696 } 2697 }
2697 2698
2698 std::string ProfileSyncService::unrecoverable_error_message() const { 2699 std::string ProfileSyncService::unrecoverable_error_message() const {
2699 return unrecoverable_error_message_; 2700 return unrecoverable_error_message_;
2700 } 2701 }
2701 2702
2702 tracked_objects::Location ProfileSyncService::unrecoverable_error_location() 2703 tracked_objects::Location ProfileSyncService::unrecoverable_error_location()
2703 const { 2704 const {
2704 return unrecoverable_error_location_; 2705 return unrecoverable_error_location_;
2705 } 2706 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698