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

Side by Side Diff: chrome/browser/sync/profile_sync_service.cc

Issue 1310553005: [Sync] Replace ProfileSyncComponentsFactory with SyncClient (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Self review Created 5 years, 3 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
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/sync/profile_sync_service.h" 5 #include "chrome/browser/sync/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 26 matching lines...) Expand all
37 #include "chrome/browser/profiles/profile.h" 37 #include "chrome/browser/profiles/profile.h"
38 #include "chrome/browser/signin/about_signin_internals_factory.h" 38 #include "chrome/browser/signin/about_signin_internals_factory.h"
39 #include "chrome/browser/signin/chrome_signin_client_factory.h" 39 #include "chrome/browser/signin/chrome_signin_client_factory.h"
40 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" 40 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
41 #include "chrome/browser/signin/signin_manager_factory.h" 41 #include "chrome/browser/signin/signin_manager_factory.h"
42 #include "chrome/browser/sync/glue/chrome_report_unrecoverable_error.h" 42 #include "chrome/browser/sync/glue/chrome_report_unrecoverable_error.h"
43 #include "chrome/browser/sync/glue/sync_backend_host.h" 43 #include "chrome/browser/sync/glue/sync_backend_host.h"
44 #include "chrome/browser/sync/glue/sync_backend_host_impl.h" 44 #include "chrome/browser/sync/glue/sync_backend_host_impl.h"
45 #include "chrome/browser/sync/glue/sync_start_util.h" 45 #include "chrome/browser/sync/glue/sync_start_util.h"
46 #include "chrome/browser/sync/glue/typed_url_data_type_controller.h" 46 #include "chrome/browser/sync/glue/typed_url_data_type_controller.h"
47 #include "chrome/browser/sync/profile_sync_components_factory_impl.h"
48 #include "chrome/browser/sync/sessions/notification_service_sessions_router.h" 47 #include "chrome/browser/sync/sessions/notification_service_sessions_router.h"
49 #include "chrome/browser/sync/supervised_user_signin_manager_wrapper.h" 48 #include "chrome/browser/sync/supervised_user_signin_manager_wrapper.h"
50 #include "chrome/browser/sync/sync_type_preference_provider.h" 49 #include "chrome/browser/sync/sync_type_preference_provider.h"
51 #include "chrome/browser/ui/browser.h" 50 #include "chrome/browser/ui/browser.h"
52 #include "chrome/browser/ui/browser_list.h" 51 #include "chrome/browser/ui/browser_list.h"
53 #include "chrome/browser/ui/browser_window.h" 52 #include "chrome/browser/ui/browser_window.h"
54 #include "chrome/browser/ui/global_error/global_error_service.h" 53 #include "chrome/browser/ui/global_error/global_error_service.h"
55 #include "chrome/browser/ui/global_error/global_error_service_factory.h" 54 #include "chrome/browser/ui/global_error/global_error_service_factory.h"
56 #include "chrome/common/chrome_switches.h" 55 #include "chrome/common/chrome_switches.h"
57 #include "chrome/common/pref_names.h" 56 #include "chrome/common/pref_names.h"
58 #include "chrome/common/sync_util.h" 57 #include "chrome/common/sync_util.h"
59 #include "chrome/common/url_constants.h" 58 #include "chrome/common/url_constants.h"
60 #include "chrome/grit/generated_resources.h" 59 #include "chrome/grit/generated_resources.h"
61 #include "components/autofill/core/common/autofill_pref_names.h" 60 #include "components/autofill/core/common/autofill_pref_names.h"
62 #include "components/invalidation/impl/profile_invalidation_provider.h" 61 #include "components/invalidation/impl/profile_invalidation_provider.h"
63 #include "components/invalidation/public/invalidation_service.h" 62 #include "components/invalidation/public/invalidation_service.h"
64 #include "components/password_manager/core/browser/password_store.h" 63 #include "components/password_manager/core/browser/password_store.h"
65 #include "components/pref_registry/pref_registry_syncable.h" 64 #include "components/pref_registry/pref_registry_syncable.h"
66 #include "components/signin/core/browser/about_signin_internals.h" 65 #include "components/signin/core/browser/about_signin_internals.h"
67 #include "components/signin/core/browser/profile_oauth2_token_service.h" 66 #include "components/signin/core/browser/profile_oauth2_token_service.h"
68 #include "components/signin/core/browser/signin_manager.h" 67 #include "components/signin/core/browser/signin_manager.h"
69 #include "components/signin/core/browser/signin_metrics.h" 68 #include "components/signin/core/browser/signin_metrics.h"
70 #include "components/sync_driver/backend_migrator.h" 69 #include "components/sync_driver/backend_migrator.h"
71 #include "components/sync_driver/change_processor.h" 70 #include "components/sync_driver/change_processor.h"
72 #include "components/sync_driver/data_type_controller.h" 71 #include "components/sync_driver/data_type_controller.h"
73 #include "components/sync_driver/device_info.h" 72 #include "components/sync_driver/device_info.h"
74 #include "components/sync_driver/favicon_cache.h" 73 #include "components/sync_driver/favicon_cache.h"
75 #include "components/sync_driver/pref_names.h" 74 #include "components/sync_driver/pref_names.h"
75 #include "components/sync_driver/sync_api_component_factory.h"
76 #include "components/sync_driver/sync_error_controller.h" 76 #include "components/sync_driver/sync_error_controller.h"
77 #include "components/sync_driver/sync_stopped_reporter.h" 77 #include "components/sync_driver/sync_stopped_reporter.h"
78 #include "components/sync_driver/system_encryptor.h" 78 #include "components/sync_driver/system_encryptor.h"
79 #include "components/sync_driver/user_selectable_sync_type.h" 79 #include "components/sync_driver/user_selectable_sync_type.h"
80 #include "components/version_info/version_info_values.h" 80 #include "components/version_info/version_info_values.h"
81 #include "content/public/browser/browser_thread.h" 81 #include "content/public/browser/browser_thread.h"
82 #include "content/public/browser/notification_details.h" 82 #include "content/public/browser/notification_details.h"
83 #include "content/public/browser/notification_service.h" 83 #include "content/public/browser/notification_service.h"
84 #include "content/public/browser/notification_source.h" 84 #include "content/public/browser/notification_source.h"
85 #include "net/cookies/cookie_monster.h" 85 #include "net/cookies/cookie_monster.h"
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 } // anonymous namespace 197 } // anonymous namespace
198 198
199 bool ShouldShowActionOnUI( 199 bool ShouldShowActionOnUI(
200 const syncer::SyncProtocolError& error) { 200 const syncer::SyncProtocolError& error) {
201 return (error.action != syncer::UNKNOWN_ACTION && 201 return (error.action != syncer::UNKNOWN_ACTION &&
202 error.action != syncer::DISABLE_SYNC_ON_CLIENT && 202 error.action != syncer::DISABLE_SYNC_ON_CLIENT &&
203 error.action != syncer::STOP_SYNC_FOR_DISABLED_ACCOUNT); 203 error.action != syncer::STOP_SYNC_FOR_DISABLED_ACCOUNT);
204 } 204 }
205 205
206 ProfileSyncService::ProfileSyncService( 206 ProfileSyncService::ProfileSyncService(
207 scoped_ptr<ProfileSyncComponentsFactory> factory, 207 scoped_ptr<sync_driver::SyncApiComponentFactory> factory,
208 Profile* profile, 208 Profile* profile,
209 scoped_ptr<SupervisedUserSigninManagerWrapper> signin_wrapper, 209 scoped_ptr<SupervisedUserSigninManagerWrapper> signin_wrapper,
210 ProfileOAuth2TokenService* oauth2_token_service, 210 ProfileOAuth2TokenService* oauth2_token_service,
211 ProfileSyncServiceStartBehavior start_behavior) 211 ProfileSyncServiceStartBehavior start_behavior)
212 : OAuth2TokenService::Consumer("sync"), 212 : OAuth2TokenService::Consumer("sync"),
213 last_auth_error_(AuthError::AuthErrorNone()), 213 last_auth_error_(AuthError::AuthErrorNone()),
214 passphrase_required_reason_(syncer::REASON_PASSPHRASE_NOT_REQUIRED), 214 passphrase_required_reason_(syncer::REASON_PASSPHRASE_NOT_REQUIRED),
215 factory_(factory.Pass()), 215 factory_(factory.Pass()),
216 profile_(profile), 216 profile_(profile),
217 sync_prefs_(profile_->GetPrefs()), 217 sync_prefs_(profile_->GetPrefs()),
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 signin()->AddObserver(this); 415 signin()->AddObserver(this);
416 } 416 }
417 417
418 void ProfileSyncService::UnregisterAuthNotifications() { 418 void ProfileSyncService::UnregisterAuthNotifications() {
419 if (signin()) 419 if (signin())
420 signin()->RemoveObserver(this); 420 signin()->RemoveObserver(this);
421 oauth2_token_service_->RemoveObserver(this); 421 oauth2_token_service_->RemoveObserver(this);
422 } 422 }
423 423
424 void ProfileSyncService::RegisterDataTypeController( 424 void ProfileSyncService::RegisterDataTypeController(
425 DataTypeController* data_type_controller) { 425 sync_driver::DataTypeController* data_type_controller) {
426 DCHECK_EQ( 426 DCHECK_EQ(
427 directory_data_type_controllers_.count(data_type_controller->type()), 427 directory_data_type_controllers_.count(data_type_controller->type()),
428 0U); 428 0U);
429 DCHECK(!GetRegisteredNonBlockingDataTypes().Has( 429 DCHECK(!GetRegisteredNonBlockingDataTypes().Has(
430 data_type_controller->type())); 430 data_type_controller->type()));
431 directory_data_type_controllers_[data_type_controller->type()] = 431 directory_data_type_controllers_[data_type_controller->type()] =
432 data_type_controller; 432 data_type_controller;
433 } 433 }
434 434
435 void ProfileSyncService::RegisterNonBlockingType(syncer::ModelType type) { 435 void ProfileSyncService::RegisterNonBlockingType(syncer::ModelType type) {
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
474 ProfileSyncService::GetSyncedWindowDelegatesGetter() const { 474 ProfileSyncService::GetSyncedWindowDelegatesGetter() const {
475 return sessions_sync_manager_->GetSyncedWindowDelegatesGetter(); 475 return sessions_sync_manager_->GetSyncedWindowDelegatesGetter();
476 } 476 }
477 477
478 sync_driver::DeviceInfoTracker* ProfileSyncService::GetDeviceInfoTracker() 478 sync_driver::DeviceInfoTracker* ProfileSyncService::GetDeviceInfoTracker()
479 const { 479 const {
480 return device_info_sync_service_.get(); 480 return device_info_sync_service_.get();
481 } 481 }
482 482
483 sync_driver::LocalDeviceInfoProvider* 483 sync_driver::LocalDeviceInfoProvider*
484 ProfileSyncService::GetLocalDeviceInfoProvider() { 484 ProfileSyncService::GetLocalDeviceInfoProvider() const {
485 return local_device_.get(); 485 return local_device_.get();
486 } 486 }
487 487
488 void ProfileSyncService::GetDataTypeControllerStates( 488 void ProfileSyncService::GetDataTypeControllerStates(
489 DataTypeController::StateMap* state_map) const { 489 DataTypeController::StateMap* state_map) const {
490 for (DataTypeController::TypeMap::const_iterator iter = 490 for (DataTypeController::TypeMap::const_iterator iter =
491 directory_data_type_controllers_.begin(); 491 directory_data_type_controllers_.begin();
492 iter != directory_data_type_controllers_.end(); 492 iter != directory_data_type_controllers_.end();
493 ++iter) 493 ++iter)
494 (*state_map)[iter->first] = iter->second.get()->state(); 494 (*state_map)[iter->first] = iter->second.get()->state();
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
692 profile_); 692 profile_);
693 if (provider) 693 if (provider)
694 invalidator = provider->GetInvalidationService(); 694 invalidator = provider->GetInvalidationService();
695 } 695 }
696 696
697 directory_path_ = profile_->GetPath().Append(sync_folder); 697 directory_path_ = profile_->GetPath().Append(sync_folder);
698 698
699 backend_.reset( 699 backend_.reset(
700 factory_->CreateSyncBackendHost( 700 factory_->CreateSyncBackendHost(
701 profile_->GetDebugName(), 701 profile_->GetDebugName(),
702 profile_,
703 invalidator, 702 invalidator,
704 sync_prefs_.AsWeakPtr(), 703 sync_prefs_.AsWeakPtr(),
705 sync_folder)); 704 sync_folder));
706 705
707 // Initialize the backend. Every time we start up a new SyncBackendHost, 706 // Initialize the backend. Every time we start up a new SyncBackendHost,
708 // we'll want to start from a fresh SyncDB, so delete any old one that might 707 // we'll want to start from a fresh SyncDB, so delete any old one that might
709 // be there. 708 // be there.
710 InitializeBackend(ShouldDeleteSyncFolder()); 709 InitializeBackend(ShouldDeleteSyncFolder());
711 710
712 UpdateFirstSyncTimePref(); 711 UpdateFirstSyncTimePref();
(...skipping 2030 matching lines...) Expand 10 before | Expand all | Expand 10 after
2743 } else { 2742 } else {
2744 UMA_HISTOGRAM_COUNTS("Sync.MemoryPressureWarningBeforeCleanShutdown", 2743 UMA_HISTOGRAM_COUNTS("Sync.MemoryPressureWarningBeforeCleanShutdown",
2745 warning_received); 2744 warning_received);
2746 } 2745 }
2747 } 2746 }
2748 sync_prefs_.SetMemoryPressureWarningCount(0); 2747 sync_prefs_.SetMemoryPressureWarningCount(0);
2749 // Will set to true during a clean shutdown, so crash or something else will 2748 // Will set to true during a clean shutdown, so crash or something else will
2750 // remain this as false. 2749 // remain this as false.
2751 sync_prefs_.SetCleanShutdown(false); 2750 sync_prefs_.SetCleanShutdown(false);
2752 } 2751 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698