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

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

Issue 10698014: [Sync] Rename csync namespace to syncer (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments Created 8 years, 5 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/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 <set> 9 #include <set>
10 #include <utility> 10 #include <utility>
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 #include "sync/internal_api/public/util/experiments.h" 61 #include "sync/internal_api/public/util/experiments.h"
62 #include "sync/js/js_arg_list.h" 62 #include "sync/js/js_arg_list.h"
63 #include "sync/js/js_event_details.h" 63 #include "sync/js/js_event_details.h"
64 #include "sync/util/cryptographer.h" 64 #include "sync/util/cryptographer.h"
65 #include "ui/base/l10n/l10n_util.h" 65 #include "ui/base/l10n/l10n_util.h"
66 66
67 using browser_sync::ChangeProcessor; 67 using browser_sync::ChangeProcessor;
68 using browser_sync::DataTypeController; 68 using browser_sync::DataTypeController;
69 using browser_sync::DataTypeManager; 69 using browser_sync::DataTypeManager;
70 using browser_sync::SyncBackendHost; 70 using browser_sync::SyncBackendHost;
71 using csync::JsBackend;
72 using csync::JsController;
73 using csync::JsEventDetails;
74 using csync::JsEventHandler;
75 using csync::ModelSafeRoutingInfo;
76 using csync::SyncCredentials;
77 using csync::SyncProtocolError;
78 using csync::WeakHandle;
79 using syncable::ModelType; 71 using syncable::ModelType;
80 using syncable::ModelTypeSet; 72 using syncable::ModelTypeSet;
73 using syncer::JsBackend;
74 using syncer::JsController;
75 using syncer::JsEventDetails;
76 using syncer::JsEventHandler;
77 using syncer::ModelSafeRoutingInfo;
78 using syncer::SyncCredentials;
79 using syncer::SyncProtocolError;
80 using syncer::WeakHandle;
81 81
82 typedef GoogleServiceAuthError AuthError; 82 typedef GoogleServiceAuthError AuthError;
83 83
84 const char* ProfileSyncService::kSyncServerUrl = 84 const char* ProfileSyncService::kSyncServerUrl =
85 "https://clients4.google.com/chrome-sync"; 85 "https://clients4.google.com/chrome-sync";
86 86
87 const char* ProfileSyncService::kDevServerUrl = 87 const char* ProfileSyncService::kDevServerUrl =
88 "https://clients4.google.com/chrome-sync/dev"; 88 "https://clients4.google.com/chrome-sync/dev";
89 89
90 static const int kSyncClearDataTimeoutInSeconds = 60; // 1 minute. 90 static const int kSyncClearDataTimeoutInSeconds = 60; // 1 minute.
(...skipping 10 matching lines...) Expand all
101 // Helper to check if the given token service is relevant for sync. 101 // Helper to check if the given token service is relevant for sync.
102 static bool IsTokenServiceRelevant(const std::string& service) { 102 static bool IsTokenServiceRelevant(const std::string& service) {
103 for (int i = 0; i < kRelevantTokenServicesCount; ++i) { 103 for (int i = 0; i < kRelevantTokenServicesCount; ++i) {
104 if (service == kRelevantTokenServices[i]) 104 if (service == kRelevantTokenServices[i])
105 return true; 105 return true;
106 } 106 }
107 return false; 107 return false;
108 } 108 }
109 109
110 bool ShouldShowActionOnUI( 110 bool ShouldShowActionOnUI(
111 const csync::SyncProtocolError& error) { 111 const syncer::SyncProtocolError& error) {
112 return (error.action != csync::UNKNOWN_ACTION && 112 return (error.action != syncer::UNKNOWN_ACTION &&
113 error.action != csync::DISABLE_SYNC_ON_CLIENT); 113 error.action != syncer::DISABLE_SYNC_ON_CLIENT);
114 } 114 }
115 115
116 ProfileSyncService::ProfileSyncService(ProfileSyncComponentsFactory* factory, 116 ProfileSyncService::ProfileSyncService(ProfileSyncComponentsFactory* factory,
117 Profile* profile, 117 Profile* profile,
118 SigninManager* signin_manager, 118 SigninManager* signin_manager,
119 StartBehavior start_behavior) 119 StartBehavior start_behavior)
120 : last_auth_error_(AuthError::None()), 120 : last_auth_error_(AuthError::None()),
121 passphrase_required_reason_(csync::REASON_PASSPHRASE_NOT_REQUIRED), 121 passphrase_required_reason_(syncer::REASON_PASSPHRASE_NOT_REQUIRED),
122 factory_(factory), 122 factory_(factory),
123 profile_(profile), 123 profile_(profile),
124 // |profile| may be NULL in unit tests. 124 // |profile| may be NULL in unit tests.
125 sync_prefs_(profile_ ? profile_->GetPrefs() : NULL), 125 sync_prefs_(profile_ ? profile_->GetPrefs() : NULL),
126 invalidator_storage_(profile_ ? profile_->GetPrefs(): NULL), 126 invalidator_storage_(profile_ ? profile_->GetPrefs(): NULL),
127 sync_service_url_(kDevServerUrl), 127 sync_service_url_(kDevServerUrl),
128 backend_initialized_(false), 128 backend_initialized_(false),
129 is_auth_in_progress_(false), 129 is_auth_in_progress_(false),
130 signin_(signin_manager), 130 signin_(signin_manager),
131 unrecoverable_error_reason_(ERROR_REASON_UNSET), 131 unrecoverable_error_reason_(ERROR_REASON_UNSET),
132 weak_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), 132 weak_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)),
133 expect_sync_configuration_aborted_(false), 133 expect_sync_configuration_aborted_(false),
134 encrypted_types_(csync::Cryptographer::SensitiveTypes()), 134 encrypted_types_(syncer::Cryptographer::SensitiveTypes()),
135 encrypt_everything_(false), 135 encrypt_everything_(false),
136 encryption_pending_(false), 136 encryption_pending_(false),
137 auto_start_enabled_(start_behavior == AUTO_START), 137 auto_start_enabled_(start_behavior == AUTO_START),
138 failed_datatypes_handler_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), 138 failed_datatypes_handler_(ALLOW_THIS_IN_INITIALIZER_LIST(this)),
139 configure_status_(DataTypeManager::UNKNOWN), 139 configure_status_(DataTypeManager::UNKNOWN),
140 setup_in_progress_(false) { 140 setup_in_progress_(false) {
141 #if defined(OS_ANDROID) 141 #if defined(OS_ANDROID)
142 chrome::VersionInfo version_info; 142 chrome::VersionInfo version_info;
143 if (version_info.IsOfficialBuild()) { 143 if (version_info.IsOfficialBuild()) {
144 sync_service_url_ = GURL(kSyncServerUrl); 144 sync_service_url_ = GURL(kSyncServerUrl);
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after
472 registrar_.Remove( 472 registrar_.Remove(
473 this, 473 this,
474 chrome::NOTIFICATION_SYNC_CONFIGURE_BLOCKED, 474 chrome::NOTIFICATION_SYNC_CONFIGURE_BLOCKED,
475 content::Source<DataTypeManager>(data_type_manager_.get())); 475 content::Source<DataTypeManager>(data_type_manager_.get()));
476 data_type_manager_.reset(); 476 data_type_manager_.reset();
477 } 477 }
478 478
479 // Shutdown the migrator before the backend to ensure it doesn't pull a null 479 // Shutdown the migrator before the backend to ensure it doesn't pull a null
480 // snapshot. 480 // snapshot.
481 migrator_.reset(); 481 migrator_.reset();
482 sync_js_controller_.AttachJsBackend(WeakHandle<csync::JsBackend>()); 482 sync_js_controller_.AttachJsBackend(WeakHandle<syncer::JsBackend>());
483 483
484 // Move aside the backend so nobody else tries to use it while we are 484 // Move aside the backend so nobody else tries to use it while we are
485 // shutting it down. 485 // shutting it down.
486 scoped_ptr<SyncBackendHost> doomed_backend(backend_.release()); 486 scoped_ptr<SyncBackendHost> doomed_backend(backend_.release());
487 if (doomed_backend.get()) { 487 if (doomed_backend.get()) {
488 doomed_backend->Shutdown(sync_disabled); 488 doomed_backend->Shutdown(sync_disabled);
489 489
490 doomed_backend.reset(); 490 doomed_backend.reset();
491 } 491 }
492 base::TimeDelta shutdown_time = base::Time::Now() - shutdown_start_time; 492 base::TimeDelta shutdown_time = base::Time::Now() - shutdown_start_time;
493 UMA_HISTOGRAM_TIMES("Sync.Shutdown.BackendDestroyedTime", shutdown_time); 493 UMA_HISTOGRAM_TIMES("Sync.Shutdown.BackendDestroyedTime", shutdown_time);
494 494
495 weak_factory_.InvalidateWeakPtrs(); 495 weak_factory_.InvalidateWeakPtrs();
496 496
497 // Clear various flags. 497 // Clear various flags.
498 expect_sync_configuration_aborted_ = false; 498 expect_sync_configuration_aborted_ = false;
499 is_auth_in_progress_ = false; 499 is_auth_in_progress_ = false;
500 backend_initialized_ = false; 500 backend_initialized_ = false;
501 cached_passphrase_.clear(); 501 cached_passphrase_.clear();
502 encryption_pending_ = false; 502 encryption_pending_ = false;
503 encrypt_everything_ = false; 503 encrypt_everything_ = false;
504 encrypted_types_ = csync::Cryptographer::SensitiveTypes(); 504 encrypted_types_ = syncer::Cryptographer::SensitiveTypes();
505 passphrase_required_reason_ = csync::REASON_PASSPHRASE_NOT_REQUIRED; 505 passphrase_required_reason_ = syncer::REASON_PASSPHRASE_NOT_REQUIRED;
506 last_auth_error_ = GoogleServiceAuthError::None(); 506 last_auth_error_ = GoogleServiceAuthError::None();
507 507
508 if (sync_global_error_.get()) { 508 if (sync_global_error_.get()) {
509 GlobalErrorServiceFactory::GetForProfile(profile_)->RemoveGlobalError( 509 GlobalErrorServiceFactory::GetForProfile(profile_)->RemoveGlobalError(
510 sync_global_error_.get()); 510 sync_global_error_.get());
511 RemoveObserver(sync_global_error_.get()); 511 RemoveObserver(sync_global_error_.get());
512 sync_global_error_.reset(NULL); 512 sync_global_error_.reset(NULL);
513 } 513 }
514 } 514 }
515 515
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
579 if (data_type_controllers_.count(data_type) > 0) 579 if (data_type_controllers_.count(data_type) > 0)
580 return; 580 return;
581 NOTREACHED(); 581 NOTREACHED();
582 } 582 }
583 583
584 // An invariant has been violated. Transition to an error state where we try 584 // An invariant has been violated. Transition to an error state where we try
585 // to do as little work as possible, to avoid further corruption or crashes. 585 // to do as little work as possible, to avoid further corruption or crashes.
586 void ProfileSyncService::OnUnrecoverableError( 586 void ProfileSyncService::OnUnrecoverableError(
587 const tracked_objects::Location& from_here, 587 const tracked_objects::Location& from_here,
588 const std::string& message) { 588 const std::string& message) {
589 // Unrecoverable errors that arrive via the csync::UnrecoverableErrorHandler 589 // Unrecoverable errors that arrive via the syncer::UnrecoverableErrorHandler
590 // interface are assumed to originate within the syncer. 590 // interface are assumed to originate within the syncer.
591 unrecoverable_error_reason_ = ERROR_REASON_SYNCER; 591 unrecoverable_error_reason_ = ERROR_REASON_SYNCER;
592 OnUnrecoverableErrorImpl(from_here, message, true); 592 OnUnrecoverableErrorImpl(from_here, message, true);
593 } 593 }
594 594
595 void ProfileSyncService::OnUnrecoverableErrorImpl( 595 void ProfileSyncService::OnUnrecoverableErrorImpl(
596 const tracked_objects::Location& from_here, 596 const tracked_objects::Location& from_here,
597 const std::string& message, 597 const std::string& message,
598 bool delete_sync_database) { 598 bool delete_sync_database) {
599 DCHECK(HasUnrecoverableError()); 599 DCHECK(HasUnrecoverableError());
(...skipping 17 matching lines...) Expand all
617 } 617 }
618 618
619 void ProfileSyncService::DisableBrokenDatatype( 619 void ProfileSyncService::DisableBrokenDatatype(
620 syncable::ModelType type, 620 syncable::ModelType type,
621 const tracked_objects::Location& from_here, 621 const tracked_objects::Location& from_here,
622 std::string message) { 622 std::string message) {
623 // First deactivate the type so that no further server changes are 623 // First deactivate the type so that no further server changes are
624 // passed onto the change processor. 624 // passed onto the change processor.
625 DeactivateDataType(type); 625 DeactivateDataType(type);
626 626
627 csync::SyncError error(from_here, message, type); 627 syncer::SyncError error(from_here, message, type);
628 628
629 std::list<csync::SyncError> errors; 629 std::list<syncer::SyncError> errors;
630 errors.push_back(error); 630 errors.push_back(error);
631 631
632 // Update this before posting a task. So if a configure happens before 632 // Update this before posting a task. So if a configure happens before
633 // the task that we are going to post, this type would still be disabled. 633 // the task that we are going to post, this type would still be disabled.
634 failed_datatypes_handler_.UpdateFailedDatatypes(errors, 634 failed_datatypes_handler_.UpdateFailedDatatypes(errors,
635 FailedDatatypesHandler::RUNTIME); 635 FailedDatatypesHandler::RUNTIME);
636 636
637 MessageLoop::current()->PostTask(FROM_HERE, 637 MessageLoop::current()->PostTask(FROM_HERE,
638 base::Bind(&ProfileSyncService::ReconfigureDatatypeManager, 638 base::Bind(&ProfileSyncService::ReconfigureDatatypeManager,
639 weak_factory_.GetWeakPtr())); 639 weak_factory_.GetWeakPtr()));
640 } 640 }
641 641
642 void ProfileSyncService::OnBackendInitialized( 642 void ProfileSyncService::OnBackendInitialized(
643 const csync::WeakHandle<csync::JsBackend>& js_backend, bool success) { 643 const syncer::WeakHandle<syncer::JsBackend>& js_backend, bool success) {
644 if (!HasSyncSetupCompleted()) { 644 if (!HasSyncSetupCompleted()) {
645 UMA_HISTOGRAM_BOOLEAN("Sync.BackendInitializeFirstTimeSuccess", success); 645 UMA_HISTOGRAM_BOOLEAN("Sync.BackendInitializeFirstTimeSuccess", success);
646 } else { 646 } else {
647 UMA_HISTOGRAM_BOOLEAN("Sync.BackendInitializeRestoreSuccess", success); 647 UMA_HISTOGRAM_BOOLEAN("Sync.BackendInitializeRestoreSuccess", success);
648 } 648 }
649 649
650 if (!success) { 650 if (!success) {
651 // Something went unexpectedly wrong. Play it safe: stop syncing at once 651 // Something went unexpectedly wrong. Play it safe: stop syncing at once
652 // and surface error UI to alert the user sync has stopped. 652 // and surface error UI to alert the user sync has stopped.
653 // Keep the directory around for now so that on restart we will retry 653 // Keep the directory around for now so that on restart we will retry
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
702 // rely on the local clock, which may be off significantly. 702 // rely on the local clock, which may be off significantly.
703 MessageLoop::current()->PostTask(FROM_HERE, 703 MessageLoop::current()->PostTask(FROM_HERE,
704 base::Bind(&browser_sync::SessionModelAssociator::DeleteStaleSessions, 704 base::Bind(&browser_sync::SessionModelAssociator::DeleteStaleSessions,
705 GetSessionModelAssociator()->AsWeakPtr())); 705 GetSessionModelAssociator()->AsWeakPtr()));
706 } 706 }
707 DVLOG(2) << "Notifying observers sync cycle completed"; 707 DVLOG(2) << "Notifying observers sync cycle completed";
708 NotifyObservers(); 708 NotifyObservers();
709 } 709 }
710 710
711 void ProfileSyncService::OnExperimentsChanged( 711 void ProfileSyncService::OnExperimentsChanged(
712 const csync::Experiments& experiments) { 712 const syncer::Experiments& experiments) {
713 if (current_experiments.Matches(experiments)) 713 if (current_experiments.Matches(experiments))
714 return; 714 return;
715 715
716 // If this is a first time sync for a client, this will be called before 716 // If this is a first time sync for a client, this will be called before
717 // OnBackendInitialized() to ensure the new datatypes are available at sync 717 // OnBackendInitialized() to ensure the new datatypes are available at sync
718 // setup. As a result, the migrator won't exist yet. This is fine because for 718 // setup. As a result, the migrator won't exist yet. This is fine because for
719 // first time sync cases we're only concerned with making the datatype 719 // first time sync cases we're only concerned with making the datatype
720 // available. 720 // available.
721 if (migrator_.get() && 721 if (migrator_.get() &&
722 migrator_->state() != browser_sync::BackendMigrator::IDLE) { 722 migrator_->state() != browser_sync::BackendMigrator::IDLE) {
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
786 is_auth_in_progress_ = false; 786 is_auth_in_progress_ = false;
787 last_auth_error_ = error; 787 last_auth_error_ = error;
788 788
789 // Fan the notification out to interested UI-thread components. 789 // Fan the notification out to interested UI-thread components.
790 NotifyObservers(); 790 NotifyObservers();
791 } 791 }
792 792
793 namespace { 793 namespace {
794 794
795 GoogleServiceAuthError ConnectionStatusToAuthError( 795 GoogleServiceAuthError ConnectionStatusToAuthError(
796 csync::ConnectionStatus status) { 796 syncer::ConnectionStatus status) {
797 switch (status) { 797 switch (status) {
798 case csync::CONNECTION_OK: 798 case syncer::CONNECTION_OK:
799 return GoogleServiceAuthError::None(); 799 return GoogleServiceAuthError::None();
800 break; 800 break;
801 case csync::CONNECTION_AUTH_ERROR: 801 case syncer::CONNECTION_AUTH_ERROR:
802 return GoogleServiceAuthError( 802 return GoogleServiceAuthError(
803 GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS); 803 GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS);
804 break; 804 break;
805 case csync::CONNECTION_SERVER_ERROR: 805 case syncer::CONNECTION_SERVER_ERROR:
806 return GoogleServiceAuthError(GoogleServiceAuthError::CONNECTION_FAILED); 806 return GoogleServiceAuthError(GoogleServiceAuthError::CONNECTION_FAILED);
807 break; 807 break;
808 default: 808 default:
809 NOTREACHED(); 809 NOTREACHED();
810 return GoogleServiceAuthError(GoogleServiceAuthError::CONNECTION_FAILED); 810 return GoogleServiceAuthError(GoogleServiceAuthError::CONNECTION_FAILED);
811 } 811 }
812 } 812 }
813 813
814 } // namespace 814 } // namespace
815 815
816 void ProfileSyncService::OnConnectionStatusChange( 816 void ProfileSyncService::OnConnectionStatusChange(
817 csync::ConnectionStatus status) { 817 syncer::ConnectionStatus status) {
818 UpdateAuthErrorState(ConnectionStatusToAuthError(status)); 818 UpdateAuthErrorState(ConnectionStatusToAuthError(status));
819 } 819 }
820 820
821 void ProfileSyncService::OnStopSyncingPermanently() { 821 void ProfileSyncService::OnStopSyncingPermanently() {
822 UpdateAuthErrorState( 822 UpdateAuthErrorState(
823 GoogleServiceAuthError(GoogleServiceAuthError::SERVICE_UNAVAILABLE)); 823 GoogleServiceAuthError(GoogleServiceAuthError::SERVICE_UNAVAILABLE));
824 sync_prefs_.SetStartSuppressed(true); 824 sync_prefs_.SetStartSuppressed(true);
825 DisableForUser(); 825 DisableForUser();
826 } 826 }
827 827
828 void ProfileSyncService::OnPassphraseRequired( 828 void ProfileSyncService::OnPassphraseRequired(
829 csync::PassphraseRequiredReason reason, 829 syncer::PassphraseRequiredReason reason,
830 const sync_pb::EncryptedData& pending_keys) { 830 const sync_pb::EncryptedData& pending_keys) {
831 DCHECK(backend_.get()); 831 DCHECK(backend_.get());
832 DCHECK(backend_->IsNigoriEnabled()); 832 DCHECK(backend_->IsNigoriEnabled());
833 833
834 // TODO(lipalani) : add this check to other locations as well. 834 // TODO(lipalani) : add this check to other locations as well.
835 if (HasUnrecoverableError()) { 835 if (HasUnrecoverableError()) {
836 // When unrecoverable error is detected we post a task to shutdown the 836 // When unrecoverable error is detected we post a task to shutdown the
837 // backend. The task might not have executed yet. 837 // backend. The task might not have executed yet.
838 return; 838 return;
839 } 839 }
840 840
841 DVLOG(1) << "Passphrase required with reason: " 841 DVLOG(1) << "Passphrase required with reason: "
842 << csync::PassphraseRequiredReasonToString(reason); 842 << syncer::PassphraseRequiredReasonToString(reason);
843 passphrase_required_reason_ = reason; 843 passphrase_required_reason_ = reason;
844 844
845 // Notify observers that the passphrase status may have changed. 845 // Notify observers that the passphrase status may have changed.
846 NotifyObservers(); 846 NotifyObservers();
847 } 847 }
848 848
849 void ProfileSyncService::OnPassphraseAccepted() { 849 void ProfileSyncService::OnPassphraseAccepted() {
850 DVLOG(1) << "Received OnPassphraseAccepted."; 850 DVLOG(1) << "Received OnPassphraseAccepted.";
851 // If we are not using an explicit passphrase, and we have a cache of the gaia 851 // If we are not using an explicit passphrase, and we have a cache of the gaia
852 // password, use it for encryption at this point. 852 // password, use it for encryption at this point.
853 DCHECK(cached_passphrase_.empty()) << 853 DCHECK(cached_passphrase_.empty()) <<
854 "Passphrase no longer required but there is still a cached passphrase"; 854 "Passphrase no longer required but there is still a cached passphrase";
855 855
856 // Reset passphrase_required_reason_ since we know we no longer require the 856 // Reset passphrase_required_reason_ since we know we no longer require the
857 // passphrase. We do this here rather than down in ResolvePassphraseRequired() 857 // passphrase. We do this here rather than down in ResolvePassphraseRequired()
858 // because that can be called by OnPassphraseRequired() if no encrypted data 858 // because that can be called by OnPassphraseRequired() if no encrypted data
859 // types are enabled, and we don't want to clobber the true passphrase error. 859 // types are enabled, and we don't want to clobber the true passphrase error.
860 passphrase_required_reason_ = csync::REASON_PASSPHRASE_NOT_REQUIRED; 860 passphrase_required_reason_ = syncer::REASON_PASSPHRASE_NOT_REQUIRED;
861 861
862 // Make sure the data types that depend on the passphrase are started at 862 // Make sure the data types that depend on the passphrase are started at
863 // this time. 863 // this time.
864 const syncable::ModelTypeSet types = GetPreferredDataTypes(); 864 const syncable::ModelTypeSet types = GetPreferredDataTypes();
865 865
866 if (data_type_manager_.get()) { 866 if (data_type_manager_.get()) {
867 // Unblock the data type manager if necessary. 867 // Unblock the data type manager if necessary.
868 data_type_manager_->Configure(types, 868 data_type_manager_->Configure(types,
869 csync::CONFIGURE_REASON_RECONFIGURATION); 869 syncer::CONFIGURE_REASON_RECONFIGURATION);
870 } 870 }
871 871
872 NotifyObservers(); 872 NotifyObservers();
873 } 873 }
874 874
875 void ProfileSyncService::OnEncryptedTypesChanged( 875 void ProfileSyncService::OnEncryptedTypesChanged(
876 syncable::ModelTypeSet encrypted_types, 876 syncable::ModelTypeSet encrypted_types,
877 bool encrypt_everything) { 877 bool encrypt_everything) {
878 encrypted_types_ = encrypted_types; 878 encrypted_types_ = encrypted_types;
879 encrypt_everything_ = encrypt_everything; 879 encrypt_everything_ = encrypt_everything;
(...skipping 20 matching lines...) Expand all
900 DCHECK(data_type_manager_.get()); 900 DCHECK(data_type_manager_.get());
901 901
902 // Migrator must be valid, because we don't sync until it is created and this 902 // Migrator must be valid, because we don't sync until it is created and this
903 // callback originates from a sync cycle. 903 // callback originates from a sync cycle.
904 migrator_->MigrateTypes(types); 904 migrator_->MigrateTypes(types);
905 } 905 }
906 906
907 void ProfileSyncService::OnActionableError(const SyncProtocolError& error) { 907 void ProfileSyncService::OnActionableError(const SyncProtocolError& error) {
908 last_actionable_error_ = error; 908 last_actionable_error_ = error;
909 DCHECK_NE(last_actionable_error_.action, 909 DCHECK_NE(last_actionable_error_.action,
910 csync::UNKNOWN_ACTION); 910 syncer::UNKNOWN_ACTION);
911 switch (error.action) { 911 switch (error.action) {
912 case csync::UPGRADE_CLIENT: 912 case syncer::UPGRADE_CLIENT:
913 case csync::CLEAR_USER_DATA_AND_RESYNC: 913 case syncer::CLEAR_USER_DATA_AND_RESYNC:
914 case csync::ENABLE_SYNC_ON_ACCOUNT: 914 case syncer::ENABLE_SYNC_ON_ACCOUNT:
915 case csync::STOP_AND_RESTART_SYNC: 915 case syncer::STOP_AND_RESTART_SYNC:
916 // TODO(lipalani) : if setup in progress we want to display these 916 // TODO(lipalani) : if setup in progress we want to display these
917 // actions in the popup. The current experience might not be optimal for 917 // actions in the popup. The current experience might not be optimal for
918 // the user. We just dismiss the dialog. 918 // the user. We just dismiss the dialog.
919 if (setup_in_progress_) { 919 if (setup_in_progress_) {
920 OnStopSyncingPermanently(); 920 OnStopSyncingPermanently();
921 expect_sync_configuration_aborted_ = true; 921 expect_sync_configuration_aborted_ = true;
922 } 922 }
923 // Trigger an unrecoverable error to stop syncing. 923 // Trigger an unrecoverable error to stop syncing.
924 OnInternalUnrecoverableError(FROM_HERE, 924 OnInternalUnrecoverableError(FROM_HERE,
925 last_actionable_error_.error_description, 925 last_actionable_error_.error_description,
926 true, 926 true,
927 ERROR_REASON_ACTIONABLE_ERROR); 927 ERROR_REASON_ACTIONABLE_ERROR);
928 break; 928 break;
929 case csync::DISABLE_SYNC_ON_CLIENT: 929 case syncer::DISABLE_SYNC_ON_CLIENT:
930 OnStopSyncingPermanently(); 930 OnStopSyncingPermanently();
931 break; 931 break;
932 default: 932 default:
933 NOTREACHED(); 933 NOTREACHED();
934 } 934 }
935 NotifyObservers(); 935 NotifyObservers();
936 } 936 }
937 937
938 std::string ProfileSyncService::QuerySyncStatusSummary() { 938 std::string ProfileSyncService::QuerySyncStatusSummary() {
939 if (HasUnrecoverableError()) { 939 if (HasUnrecoverableError()) {
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
987 bool ProfileSyncService::waiting_for_auth() const { 987 bool ProfileSyncService::waiting_for_auth() const {
988 return is_auth_in_progress_; 988 return is_auth_in_progress_;
989 } 989 }
990 990
991 bool ProfileSyncService::HasUnrecoverableError() const { 991 bool ProfileSyncService::HasUnrecoverableError() const {
992 return unrecoverable_error_reason_ != ERROR_REASON_UNSET; 992 return unrecoverable_error_reason_ != ERROR_REASON_UNSET;
993 } 993 }
994 994
995 bool ProfileSyncService::IsPassphraseRequired() const { 995 bool ProfileSyncService::IsPassphraseRequired() const {
996 return passphrase_required_reason_ != 996 return passphrase_required_reason_ !=
997 csync::REASON_PASSPHRASE_NOT_REQUIRED; 997 syncer::REASON_PASSPHRASE_NOT_REQUIRED;
998 } 998 }
999 999
1000 // TODO(zea): Rename this IsPassphraseNeededFromUI and ensure it's used 1000 // TODO(zea): Rename this IsPassphraseNeededFromUI and ensure it's used
1001 // appropriately (see http://crbug.com/91379). 1001 // appropriately (see http://crbug.com/91379).
1002 bool ProfileSyncService::IsPassphraseRequiredForDecryption() const { 1002 bool ProfileSyncService::IsPassphraseRequiredForDecryption() const {
1003 // If there is an encrypted datatype enabled and we don't have the proper 1003 // If there is an encrypted datatype enabled and we don't have the proper
1004 // passphrase, we must prompt the user for a passphrase. The only way for the 1004 // passphrase, we must prompt the user for a passphrase. The only way for the
1005 // user to avoid entering their passphrase is to disable the encrypted types. 1005 // user to avoid entering their passphrase is to disable the encrypted types.
1006 return IsEncryptedDatatypeEnabled() && IsPassphraseRequired(); 1006 return IsEncryptedDatatypeEnabled() && IsPassphraseRequired();
1007 } 1007 }
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
1072 browser_sync::user_selectable_type::SELECTABLE_DATATYPE_COUNT + 1); 1072 browser_sync::user_selectable_type::SELECTABLE_DATATYPE_COUNT + 1);
1073 } 1073 }
1074 } 1074 }
1075 } 1075 }
1076 } 1076 }
1077 1077
1078 #if defined(OS_CHROMEOS) 1078 #if defined(OS_CHROMEOS)
1079 void ProfileSyncService::RefreshSpareBootstrapToken( 1079 void ProfileSyncService::RefreshSpareBootstrapToken(
1080 const std::string& passphrase) { 1080 const std::string& passphrase) {
1081 browser_sync::ChromeEncryptor encryptor; 1081 browser_sync::ChromeEncryptor encryptor;
1082 csync::Cryptographer temp_cryptographer(&encryptor); 1082 syncer::Cryptographer temp_cryptographer(&encryptor);
1083 // The first 2 params (hostname and username) doesn't have any effect here. 1083 // The first 2 params (hostname and username) doesn't have any effect here.
1084 csync::KeyParams key_params = {"localhost", "dummy", passphrase}; 1084 syncer::KeyParams key_params = {"localhost", "dummy", passphrase};
1085 1085
1086 std::string bootstrap_token; 1086 std::string bootstrap_token;
1087 if (!temp_cryptographer.AddKey(key_params)) { 1087 if (!temp_cryptographer.AddKey(key_params)) {
1088 NOTREACHED() << "Failed to add key to cryptographer."; 1088 NOTREACHED() << "Failed to add key to cryptographer.";
1089 } 1089 }
1090 temp_cryptographer.GetBootstrapToken(&bootstrap_token); 1090 temp_cryptographer.GetBootstrapToken(&bootstrap_token);
1091 sync_prefs_.SetSpareBootstrapToken(bootstrap_token); 1091 sync_prefs_.SetSpareBootstrapToken(bootstrap_token);
1092 } 1092 }
1093 #endif 1093 #endif
1094 1094
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
1141 registered_types.Put(it->first); 1141 registered_types.Put(it->first);
1142 } 1142 }
1143 return registered_types; 1143 return registered_types;
1144 } 1144 }
1145 1145
1146 bool ProfileSyncService::IsUsingSecondaryPassphrase() const { 1146 bool ProfileSyncService::IsUsingSecondaryPassphrase() const {
1147 return backend_->IsUsingExplicitPassphrase(); 1147 return backend_->IsUsingExplicitPassphrase();
1148 } 1148 }
1149 1149
1150 bool ProfileSyncService::IsCryptographerReady( 1150 bool ProfileSyncService::IsCryptographerReady(
1151 const csync::BaseTransaction* trans) const { 1151 const syncer::BaseTransaction* trans) const {
1152 return backend_.get() && backend_->IsCryptographerReady(trans); 1152 return backend_.get() && backend_->IsCryptographerReady(trans);
1153 } 1153 }
1154 1154
1155 SyncBackendHost* ProfileSyncService::GetBackendForTest() { 1155 SyncBackendHost* ProfileSyncService::GetBackendForTest() {
1156 // We don't check |backend_initialized_|; we assume the test class 1156 // We don't check |backend_initialized_|; we assume the test class
1157 // knows what it's doing. 1157 // knows what it's doing.
1158 return backend_.get(); 1158 return backend_.get();
1159 } 1159 }
1160 1160
1161 void ProfileSyncService::ConfigureDataTypeManager() { 1161 void ProfileSyncService::ConfigureDataTypeManager() {
(...skipping 24 matching lines...) Expand all
1186 1186
1187 const syncable::ModelTypeSet types = GetPreferredDataTypes(); 1187 const syncable::ModelTypeSet types = GetPreferredDataTypes();
1188 if (IsPassphraseRequiredForDecryption()) { 1188 if (IsPassphraseRequiredForDecryption()) {
1189 // We need a passphrase still. We don't bother to attempt to configure 1189 // We need a passphrase still. We don't bother to attempt to configure
1190 // until we receive an OnPassphraseAccepted (which triggers a configure). 1190 // until we receive an OnPassphraseAccepted (which triggers a configure).
1191 DVLOG(1) << "ProfileSyncService::ConfigureDataTypeManager bailing out " 1191 DVLOG(1) << "ProfileSyncService::ConfigureDataTypeManager bailing out "
1192 << "because a passphrase required"; 1192 << "because a passphrase required";
1193 NotifyObservers(); 1193 NotifyObservers();
1194 return; 1194 return;
1195 } 1195 }
1196 csync::ConfigureReason reason = csync::CONFIGURE_REASON_UNKNOWN; 1196 syncer::ConfigureReason reason = syncer::CONFIGURE_REASON_UNKNOWN;
1197 if (!HasSyncSetupCompleted()) { 1197 if (!HasSyncSetupCompleted()) {
1198 reason = csync::CONFIGURE_REASON_NEW_CLIENT; 1198 reason = syncer::CONFIGURE_REASON_NEW_CLIENT;
1199 } else if (restart == false || 1199 } else if (restart == false ||
1200 csync::InitialSyncEndedForTypes(types, GetUserShare())) { 1200 syncer::InitialSyncEndedForTypes(types, GetUserShare())) {
1201 reason = csync::CONFIGURE_REASON_RECONFIGURATION; 1201 reason = syncer::CONFIGURE_REASON_RECONFIGURATION;
1202 } else { 1202 } else {
1203 DCHECK(restart); 1203 DCHECK(restart);
1204 reason = csync::CONFIGURE_REASON_NEWLY_ENABLED_DATA_TYPE; 1204 reason = syncer::CONFIGURE_REASON_NEWLY_ENABLED_DATA_TYPE;
1205 } 1205 }
1206 DCHECK(reason != csync::CONFIGURE_REASON_UNKNOWN); 1206 DCHECK(reason != syncer::CONFIGURE_REASON_UNKNOWN);
1207 1207
1208 data_type_manager_->Configure(types, reason); 1208 data_type_manager_->Configure(types, reason);
1209 } 1209 }
1210 1210
1211 csync::UserShare* ProfileSyncService::GetUserShare() const { 1211 syncer::UserShare* ProfileSyncService::GetUserShare() const {
1212 if (backend_.get() && backend_initialized_) { 1212 if (backend_.get() && backend_initialized_) {
1213 return backend_->GetUserShare(); 1213 return backend_->GetUserShare();
1214 } 1214 }
1215 NOTREACHED(); 1215 NOTREACHED();
1216 return NULL; 1216 return NULL;
1217 } 1217 }
1218 1218
1219 csync::sessions::SyncSessionSnapshot 1219 syncer::sessions::SyncSessionSnapshot
1220 ProfileSyncService::GetLastSessionSnapshot() const { 1220 ProfileSyncService::GetLastSessionSnapshot() const {
1221 if (backend_.get() && backend_initialized_) { 1221 if (backend_.get() && backend_initialized_) {
1222 return backend_->GetLastSessionSnapshot(); 1222 return backend_->GetLastSessionSnapshot();
1223 } 1223 }
1224 NOTREACHED(); 1224 NOTREACHED();
1225 return csync::sessions::SyncSessionSnapshot(); 1225 return syncer::sessions::SyncSessionSnapshot();
1226 } 1226 }
1227 1227
1228 bool ProfileSyncService::HasUnsyncedItems() const { 1228 bool ProfileSyncService::HasUnsyncedItems() const {
1229 if (backend_.get() && backend_initialized_) { 1229 if (backend_.get() && backend_initialized_) {
1230 return backend_->HasUnsyncedItems(); 1230 return backend_->HasUnsyncedItems();
1231 } 1231 }
1232 NOTREACHED(); 1232 NOTREACHED();
1233 return false; 1233 return false;
1234 } 1234 }
1235 1235
1236 browser_sync::BackendMigrator* 1236 browser_sync::BackendMigrator*
1237 ProfileSyncService::GetBackendMigratorForTest() { 1237 ProfileSyncService::GetBackendMigratorForTest() {
1238 return migrator_.get(); 1238 return migrator_.get();
1239 } 1239 }
1240 1240
1241 void ProfileSyncService::GetModelSafeRoutingInfo( 1241 void ProfileSyncService::GetModelSafeRoutingInfo(
1242 csync::ModelSafeRoutingInfo* out) const { 1242 syncer::ModelSafeRoutingInfo* out) const {
1243 if (backend_.get() && backend_initialized_) { 1243 if (backend_.get() && backend_initialized_) {
1244 backend_->GetModelSafeRoutingInfo(out); 1244 backend_->GetModelSafeRoutingInfo(out);
1245 } else { 1245 } else {
1246 NOTREACHED(); 1246 NOTREACHED();
1247 } 1247 }
1248 } 1248 }
1249 1249
1250 Value* ProfileSyncService::GetTypeStatusMap() const { 1250 Value* ProfileSyncService::GetTypeStatusMap() const {
1251 ListValue* result = new ListValue(); 1251 ListValue* result = new ListValue();
1252 1252
1253 if (!backend_.get() || !backend_initialized_) { 1253 if (!backend_.get() || !backend_initialized_) {
1254 return result; 1254 return result;
1255 } 1255 }
1256 1256
1257 std::vector<csync::SyncError> errors = 1257 std::vector<syncer::SyncError> errors =
1258 failed_datatypes_handler_.GetAllErrors(); 1258 failed_datatypes_handler_.GetAllErrors();
1259 std::map<ModelType, csync::SyncError> error_map; 1259 std::map<ModelType, syncer::SyncError> error_map;
1260 for (std::vector<csync::SyncError>::iterator it = errors.begin(); 1260 for (std::vector<syncer::SyncError>::iterator it = errors.begin();
1261 it != errors.end(); ++it) { 1261 it != errors.end(); ++it) {
1262 error_map[it->type()] = *it; 1262 error_map[it->type()] = *it;
1263 } 1263 }
1264 1264
1265 ModelTypeSet active_types; 1265 ModelTypeSet active_types;
1266 ModelTypeSet passive_types; 1266 ModelTypeSet passive_types;
1267 ModelSafeRoutingInfo routing_info; 1267 ModelSafeRoutingInfo routing_info;
1268 backend_->GetModelSafeRoutingInfo(&routing_info); 1268 backend_->GetModelSafeRoutingInfo(&routing_info);
1269 for (ModelSafeRoutingInfo::const_iterator it = routing_info.begin(); 1269 for (ModelSafeRoutingInfo::const_iterator it = routing_info.begin();
1270 it != routing_info.end(); ++it) { 1270 it != routing_info.end(); ++it) {
1271 if (it->second == csync::GROUP_PASSIVE) { 1271 if (it->second == syncer::GROUP_PASSIVE) {
1272 passive_types.Put(it->first); 1272 passive_types.Put(it->first);
1273 } else { 1273 } else {
1274 active_types.Put(it->first); 1274 active_types.Put(it->first);
1275 } 1275 }
1276 } 1276 }
1277 1277
1278 SyncBackendHost::Status detailed_status = backend_->GetDetailedStatus(); 1278 SyncBackendHost::Status detailed_status = backend_->GetDetailedStatus();
1279 ModelTypeSet &throttled_types(detailed_status.throttled_types); 1279 ModelTypeSet &throttled_types(detailed_status.throttled_types);
1280 1280
1281 ModelTypeSet registered = GetRegisteredDataTypes(); 1281 ModelTypeSet registered = GetRegisteredDataTypes();
1282 for (ModelTypeSet::Iterator it = registered.First(); it.Good(); it.Inc()) { 1282 for (ModelTypeSet::Iterator it = registered.First(); it.Good(); it.Inc()) {
1283 ModelType type = it.Get(); 1283 ModelType type = it.Get();
1284 DictionaryValue* type_status = new DictionaryValue(); 1284 DictionaryValue* type_status = new DictionaryValue();
1285 1285
1286 result->Append(type_status); 1286 result->Append(type_status);
1287 type_status->SetString("name", ModelTypeToString(type)); 1287 type_status->SetString("name", ModelTypeToString(type));
1288 1288
1289 if (error_map.find(type) != error_map.end()) { 1289 if (error_map.find(type) != error_map.end()) {
1290 const csync::SyncError &error = error_map.find(type)->second; 1290 const syncer::SyncError &error = error_map.find(type)->second;
1291 DCHECK(error.IsSet()); 1291 DCHECK(error.IsSet());
1292 std::string error_text = "Error: " + error.location().ToString() + 1292 std::string error_text = "Error: " + error.location().ToString() +
1293 ", " + error.message(); 1293 ", " + error.message();
1294 type_status->SetString("status", "error"); 1294 type_status->SetString("status", "error");
1295 type_status->SetString("value", error_text); 1295 type_status->SetString("value", error_text);
1296 } else if (throttled_types.Has(type) && passive_types.Has(type)) { 1296 } else if (throttled_types.Has(type) && passive_types.Has(type)) {
1297 type_status->SetString("status", "warning"); 1297 type_status->SetString("status", "warning");
1298 type_status->SetString("value", "Passive, Throttled"); 1298 type_status->SetString("value", "Passive, Throttled");
1299 } else if (passive_types.Has(type)) { 1299 } else if (passive_types.Has(type)) {
1300 type_status->SetString("status", "warning"); 1300 type_status->SetString("status", "warning");
1301 type_status->SetString("value", "Passive"); 1301 type_status->SetString("value", "Passive");
1302 } else if (throttled_types.Has(type)) { 1302 } else if (throttled_types.Has(type)) {
1303 type_status->SetString("status", "warning"); 1303 type_status->SetString("status", "warning");
1304 type_status->SetString("value", "Throttled"); 1304 type_status->SetString("value", "Throttled");
1305 } else if (active_types.Has(type)) { 1305 } else if (active_types.Has(type)) {
1306 type_status->SetString("status", "ok"); 1306 type_status->SetString("status", "ok");
1307 type_status->SetString("value", "Active: " + 1307 type_status->SetString("value", "Active: " +
1308 ModelSafeGroupToString(routing_info[type])); 1308 ModelSafeGroupToString(routing_info[type]));
1309 } else { 1309 } else {
1310 type_status->SetString("status", "warning"); 1310 type_status->SetString("status", "warning");
1311 type_status->SetString("value", "Disabled by User"); 1311 type_status->SetString("value", "Disabled by User");
1312 } 1312 }
1313 } 1313 }
1314 return result; 1314 return result;
1315 } 1315 }
1316 1316
1317 void ProfileSyncService::ActivateDataType( 1317 void ProfileSyncService::ActivateDataType(
1318 syncable::ModelType type, csync::ModelSafeGroup group, 1318 syncable::ModelType type, syncer::ModelSafeGroup group,
1319 ChangeProcessor* change_processor) { 1319 ChangeProcessor* change_processor) {
1320 if (!backend_.get()) { 1320 if (!backend_.get()) {
1321 NOTREACHED(); 1321 NOTREACHED();
1322 return; 1322 return;
1323 } 1323 }
1324 DCHECK(backend_initialized_); 1324 DCHECK(backend_initialized_);
1325 backend_->ActivateDataType(type, group, change_processor); 1325 backend_->ActivateDataType(type, group, change_processor);
1326 } 1326 }
1327 1327
1328 void ProfileSyncService::DeactivateDataType(syncable::ModelType type) { 1328 void ProfileSyncService::DeactivateDataType(syncable::ModelType type) {
1329 if (!backend_.get()) 1329 if (!backend_.get())
1330 return; 1330 return;
1331 backend_->DeactivateDataType(type); 1331 backend_->DeactivateDataType(type);
1332 } 1332 }
1333 1333
1334 void ProfileSyncService::ConsumeCachedPassphraseIfPossible() { 1334 void ProfileSyncService::ConsumeCachedPassphraseIfPossible() {
1335 // If no cached passphrase, or sync backend hasn't started up yet, just exit. 1335 // If no cached passphrase, or sync backend hasn't started up yet, just exit.
1336 // If the backend isn't running yet, OnBackendInitialized() will call this 1336 // If the backend isn't running yet, OnBackendInitialized() will call this
1337 // method again after the backend starts up. 1337 // method again after the backend starts up.
1338 if (cached_passphrase_.empty() || !sync_initialized()) 1338 if (cached_passphrase_.empty() || !sync_initialized())
1339 return; 1339 return;
1340 1340
1341 // Backend is up and running, so we can consume the cached passphrase. 1341 // Backend is up and running, so we can consume the cached passphrase.
1342 std::string passphrase = cached_passphrase_; 1342 std::string passphrase = cached_passphrase_;
1343 cached_passphrase_.clear(); 1343 cached_passphrase_.clear();
1344 1344
1345 // If we need a passphrase to decrypt data, try the cached passphrase. 1345 // If we need a passphrase to decrypt data, try the cached passphrase.
1346 if (passphrase_required_reason() == csync::REASON_DECRYPTION) { 1346 if (passphrase_required_reason() == syncer::REASON_DECRYPTION) {
1347 if (SetDecryptionPassphrase(passphrase)) { 1347 if (SetDecryptionPassphrase(passphrase)) {
1348 DVLOG(1) << "Cached passphrase successfully decrypted pending keys"; 1348 DVLOG(1) << "Cached passphrase successfully decrypted pending keys";
1349 return; 1349 return;
1350 } 1350 }
1351 } 1351 }
1352 1352
1353 // If we get here, we don't have pending keys (or at least, the passphrase 1353 // If we get here, we don't have pending keys (or at least, the passphrase
1354 // doesn't decrypt them) - just try to re-encrypt using the encryption 1354 // doesn't decrypt them) - just try to re-encrypt using the encryption
1355 // passphrase. 1355 // passphrase.
1356 if (!IsUsingSecondaryPassphrase()) 1356 if (!IsUsingSecondaryPassphrase())
1357 SetEncryptionPassphrase(passphrase, IMPLICIT); 1357 SetEncryptionPassphrase(passphrase, IMPLICIT);
1358 } 1358 }
1359 1359
1360 void ProfileSyncService::SetEncryptionPassphrase(const std::string& passphrase, 1360 void ProfileSyncService::SetEncryptionPassphrase(const std::string& passphrase,
1361 PassphraseType type) { 1361 PassphraseType type) {
1362 // This should only be called when the backend has been initialized. 1362 // This should only be called when the backend has been initialized.
1363 DCHECK(sync_initialized()); 1363 DCHECK(sync_initialized());
1364 DCHECK(!(type == IMPLICIT && IsUsingSecondaryPassphrase())) << 1364 DCHECK(!(type == IMPLICIT && IsUsingSecondaryPassphrase())) <<
1365 "Data is already encrypted using an explicit passphrase"; 1365 "Data is already encrypted using an explicit passphrase";
1366 DCHECK(!(type == EXPLICIT && IsPassphraseRequired())) << 1366 DCHECK(!(type == EXPLICIT && IsPassphraseRequired())) <<
1367 "Cannot switch to an explicit passphrase if a passphrase is required"; 1367 "Cannot switch to an explicit passphrase if a passphrase is required";
1368 1368
1369 if (type == EXPLICIT) 1369 if (type == EXPLICIT)
1370 UMA_HISTOGRAM_BOOLEAN("Sync.CustomPassphrase", true); 1370 UMA_HISTOGRAM_BOOLEAN("Sync.CustomPassphrase", true);
1371 1371
1372 DVLOG(1) << "Setting " << (type == EXPLICIT ? "explicit" : "implicit") 1372 DVLOG(1) << "Setting " << (type == EXPLICIT ? "explicit" : "implicit")
1373 << " passphrase for encryption."; 1373 << " passphrase for encryption.";
1374 if (passphrase_required_reason_ == csync::REASON_ENCRYPTION) { 1374 if (passphrase_required_reason_ == syncer::REASON_ENCRYPTION) {
1375 // REASON_ENCRYPTION implies that the cryptographer does not have pending 1375 // REASON_ENCRYPTION implies that the cryptographer does not have pending
1376 // keys. Hence, as long as we're not trying to do an invalid passphrase 1376 // keys. Hence, as long as we're not trying to do an invalid passphrase
1377 // change (e.g. explicit -> explicit or explicit -> implicit), we know this 1377 // change (e.g. explicit -> explicit or explicit -> implicit), we know this
1378 // will succeed. If for some reason a new encryption key arrives via 1378 // will succeed. If for some reason a new encryption key arrives via
1379 // sync later, the SBH will trigger another OnPassphraseRequired(). 1379 // sync later, the SBH will trigger another OnPassphraseRequired().
1380 passphrase_required_reason_ = csync::REASON_PASSPHRASE_NOT_REQUIRED; 1380 passphrase_required_reason_ = syncer::REASON_PASSPHRASE_NOT_REQUIRED;
1381 NotifyObservers(); 1381 NotifyObservers();
1382 } 1382 }
1383 backend_->SetEncryptionPassphrase(passphrase, type == EXPLICIT); 1383 backend_->SetEncryptionPassphrase(passphrase, type == EXPLICIT);
1384 } 1384 }
1385 1385
1386 bool ProfileSyncService::SetDecryptionPassphrase( 1386 bool ProfileSyncService::SetDecryptionPassphrase(
1387 const std::string& passphrase) { 1387 const std::string& passphrase) {
1388 if (IsPassphraseRequired()) { 1388 if (IsPassphraseRequired()) {
1389 DVLOG(1) << "Setting passphrase for decryption."; 1389 DVLOG(1) << "Setting passphrase for decryption.";
1390 return backend_->SetDecryptionPassphrase(passphrase); 1390 return backend_->SetDecryptionPassphrase(passphrase);
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
1481 return; 1481 return;
1482 } 1482 }
1483 1483
1484 // Handle unrecoverable error. 1484 // Handle unrecoverable error.
1485 if (configure_status_ != DataTypeManager::OK && 1485 if (configure_status_ != DataTypeManager::OK &&
1486 configure_status_ != DataTypeManager::PARTIAL_SUCCESS) { 1486 configure_status_ != DataTypeManager::PARTIAL_SUCCESS) {
1487 // Something catastrophic had happened. We should only have one 1487 // Something catastrophic had happened. We should only have one
1488 // error representing it. 1488 // error representing it.
1489 DCHECK_EQ(result->failed_data_types.size(), 1489 DCHECK_EQ(result->failed_data_types.size(),
1490 static_cast<unsigned int>(1)); 1490 static_cast<unsigned int>(1));
1491 csync::SyncError error = result->failed_data_types.front(); 1491 syncer::SyncError error = result->failed_data_types.front();
1492 DCHECK(error.IsSet()); 1492 DCHECK(error.IsSet());
1493 std::string message = 1493 std::string message =
1494 "Sync configuration failed with status " + 1494 "Sync configuration failed with status " +
1495 DataTypeManager::ConfigureStatusToString(configure_status_) + 1495 DataTypeManager::ConfigureStatusToString(configure_status_) +
1496 " during " + syncable::ModelTypeToString(error.type()) + 1496 " during " + syncable::ModelTypeToString(error.type()) +
1497 ": " + error.message(); 1497 ": " + error.message();
1498 LOG(ERROR) << "ProfileSyncService error: " 1498 LOG(ERROR) << "ProfileSyncService error: "
1499 << message; 1499 << message;
1500 OnInternalUnrecoverableError(error.location(), 1500 OnInternalUnrecoverableError(error.location(),
1501 message, 1501 message,
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
1617 } 1617 }
1618 1618
1619 void ProfileSyncService::RemoveObserver(Observer* observer) { 1619 void ProfileSyncService::RemoveObserver(Observer* observer) {
1620 observers_.RemoveObserver(observer); 1620 observers_.RemoveObserver(observer);
1621 } 1621 }
1622 1622
1623 bool ProfileSyncService::HasObserver(Observer* observer) const { 1623 bool ProfileSyncService::HasObserver(Observer* observer) const {
1624 return observers_.HasObserver(observer); 1624 return observers_.HasObserver(observer);
1625 } 1625 }
1626 1626
1627 base::WeakPtr<csync::JsController> ProfileSyncService::GetJsController() { 1627 base::WeakPtr<syncer::JsController> ProfileSyncService::GetJsController() {
1628 return sync_js_controller_.AsWeakPtr(); 1628 return sync_js_controller_.AsWeakPtr();
1629 } 1629 }
1630 1630
1631 void ProfileSyncService::SyncEvent(SyncEventCodes code) { 1631 void ProfileSyncService::SyncEvent(SyncEventCodes code) {
1632 UMA_HISTOGRAM_ENUMERATION("Sync.EventCodes", code, MAX_SYNC_EVENT_CODE); 1632 UMA_HISTOGRAM_ENUMERATION("Sync.EventCodes", code, MAX_SYNC_EVENT_CODE);
1633 } 1633 }
1634 1634
1635 // static 1635 // static
1636 bool ProfileSyncService::IsSyncEnabled() { 1636 bool ProfileSyncService::IsSyncEnabled() {
1637 // We have switches::kEnableSync just in case we need to change back to 1637 // We have switches::kEnableSync just in case we need to change back to
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
1723 // See http://stackoverflow.com/questions/6224121/is-new-this-myclass-undefine d-behaviour-after-directly-calling-the-destru. 1723 // See http://stackoverflow.com/questions/6224121/is-new-this-myclass-undefine d-behaviour-after-directly-calling-the-destru.
1724 ProfileSyncService* old_this = this; 1724 ProfileSyncService* old_this = this;
1725 this->~ProfileSyncService(); 1725 this->~ProfileSyncService();
1726 new(old_this) ProfileSyncService( 1726 new(old_this) ProfileSyncService(
1727 new ProfileSyncComponentsFactoryImpl(profile, 1727 new ProfileSyncComponentsFactoryImpl(profile,
1728 CommandLine::ForCurrentProcess()), 1728 CommandLine::ForCurrentProcess()),
1729 profile, 1729 profile,
1730 signin, 1730 signin,
1731 behavior); 1731 behavior);
1732 } 1732 }
OLDNEW
« no previous file with comments | « chrome/browser/sync/profile_sync_service.h ('k') | chrome/browser/sync/profile_sync_service_autofill_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698