OLD | NEW |
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 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 | 194 |
195 RegisterAuthNotifications(); | 195 RegisterAuthNotifications(); |
196 | 196 |
197 if (!HasSyncSetupCompleted()) | 197 if (!HasSyncSetupCompleted()) |
198 DisableForUser(); // Clean up in case of previous crash / setup abort. | 198 DisableForUser(); // Clean up in case of previous crash / setup abort. |
199 | 199 |
200 TryStart(); | 200 TryStart(); |
201 } | 201 } |
202 | 202 |
203 void ProfileSyncService::TryStart() { | 203 void ProfileSyncService::TryStart() { |
| 204 LOG(WARNING) << "TryStart"; |
204 if (!sync_prefs_.IsStartSuppressed() && AreCredentialsAvailable()) { | 205 if (!sync_prefs_.IsStartSuppressed() && AreCredentialsAvailable()) { |
205 if (HasSyncSetupCompleted() || auto_start_enabled_) { | 206 if (HasSyncSetupCompleted() || auto_start_enabled_) { |
206 // If sync setup has completed we always start the backend. | 207 // If sync setup has completed we always start the backend. |
207 // If autostart is enabled, but we haven't completed sync setup, we try to | 208 // If autostart is enabled, but we haven't completed sync setup, we try to |
208 // start sync anyway, since it's possible we crashed/shutdown after | 209 // start sync anyway, since it's possible we crashed/shutdown after |
209 // logging in but before the backend finished initializing the last time. | 210 // logging in but before the backend finished initializing the last time. |
210 // Note that if we haven't finished setting up sync, backend bring up will | 211 // Note that if we haven't finished setting up sync, backend bring up will |
211 // be done by the wizard. | 212 // be done by the wizard. |
212 StartUp(); | 213 StartUp(); |
213 } | 214 } |
214 } else if (HasSyncSetupCompleted()) { | 215 } else if (HasSyncSetupCompleted()) { |
215 TokenService* token_service = TokenServiceFactory::GetForProfile(profile_); | 216 TokenService* token_service = TokenServiceFactory::GetForProfile(profile_); |
216 if (token_service && token_service->TokensLoadedFromDB() && | 217 if (token_service && token_service->TokensLoadedFromDB() && |
217 !AreCredentialsAvailable()) { | 218 !AreCredentialsAvailable()) { |
218 // The token service has lost sync's tokens. We cannot recover from this | 219 // The token service has lost sync's tokens. We cannot recover from this |
219 // without signing back in, which is not yet supported. For now, we | 220 // without signing back in, which is not yet supported. For now, we |
220 // trigger an unrecoverable error. | 221 // trigger an unrecoverable error. |
221 OnUnrecoverableError(FROM_HERE, "Sync credentials lost."); | 222 OnUnrecoverableError(FROM_HERE, "Sync credentials lost."); |
222 } | 223 } |
| 224 } else { |
| 225 LOG(WARNING) << "TryStart: did nothing."; |
223 } | 226 } |
224 } | 227 } |
225 | 228 |
226 void ProfileSyncService::RegisterAuthNotifications() { | 229 void ProfileSyncService::RegisterAuthNotifications() { |
227 TokenService* token_service = TokenServiceFactory::GetForProfile(profile_); | 230 TokenService* token_service = TokenServiceFactory::GetForProfile(profile_); |
228 registrar_.Add(this, | 231 registrar_.Add(this, |
229 chrome::NOTIFICATION_TOKEN_AVAILABLE, | 232 chrome::NOTIFICATION_TOKEN_AVAILABLE, |
230 content::Source<TokenService>(token_service)); | 233 content::Source<TokenService>(token_service)); |
231 registrar_.Add(this, | 234 registrar_.Add(this, |
232 chrome::NOTIFICATION_TOKEN_LOADING_FINISHED, | 235 chrome::NOTIFICATION_TOKEN_LOADING_FINISHED, |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
325 scoped_refptr<net::URLRequestContextGetter> request_context_getter( | 328 scoped_refptr<net::URLRequestContextGetter> request_context_getter( |
326 profile_->GetRequestContext()); | 329 profile_->GetRequestContext()); |
327 | 330 |
328 if (delete_stale_data) | 331 if (delete_stale_data) |
329 ClearStaleErrors(); | 332 ClearStaleErrors(); |
330 | 333 |
331 backend_unrecoverable_error_handler_.reset( | 334 backend_unrecoverable_error_handler_.reset( |
332 new browser_sync::BackendUnrecoverableErrorHandler( | 335 new browser_sync::BackendUnrecoverableErrorHandler( |
333 MakeWeakHandle(AsWeakPtr()))); | 336 MakeWeakHandle(AsWeakPtr()))); |
334 | 337 |
| 338 LOG(WARNING) << "Initializing backend"; |
335 backend_->Initialize( | 339 backend_->Initialize( |
336 this, | 340 this, |
337 MakeWeakHandle(sync_js_controller_.AsWeakPtr()), | 341 MakeWeakHandle(sync_js_controller_.AsWeakPtr()), |
338 sync_service_url_, | 342 sync_service_url_, |
339 initial_types, | 343 initial_types, |
340 credentials, | 344 credentials, |
341 delete_stale_data, | 345 delete_stale_data, |
342 backend_unrecoverable_error_handler_.get(), | 346 backend_unrecoverable_error_handler_.get(), |
343 &browser_sync::ChromeReportUnrecoverableError); | 347 &browser_sync::ChromeReportUnrecoverableError); |
344 } | 348 } |
345 | 349 |
346 void ProfileSyncService::CreateBackend() { | 350 void ProfileSyncService::CreateBackend() { |
| 351 LOG(WARNING) << "CreateBackend"; |
347 backend_.reset( | 352 backend_.reset( |
348 new SyncBackendHost(profile_->GetDebugName(), | 353 new SyncBackendHost(profile_->GetDebugName(), |
349 profile_, sync_prefs_.AsWeakPtr())); | 354 profile_, sync_prefs_.AsWeakPtr())); |
350 } | 355 } |
351 | 356 |
352 bool ProfileSyncService::IsEncryptedDatatypeEnabled() const { | 357 bool ProfileSyncService::IsEncryptedDatatypeEnabled() const { |
353 if (encryption_pending()) | 358 if (encryption_pending()) |
354 return true; | 359 return true; |
355 const syncable::ModelTypeSet preferred_types = GetPreferredDataTypes(); | 360 const syncable::ModelTypeSet preferred_types = GetPreferredDataTypes(); |
356 const syncable::ModelTypeSet encrypted_types = GetEncryptedDataTypes(); | 361 const syncable::ModelTypeSet encrypted_types = GetEncryptedDataTypes(); |
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
612 failed_datatypes_handler_.UpdateFailedDatatypes(errors, | 617 failed_datatypes_handler_.UpdateFailedDatatypes(errors, |
613 FailedDatatypesHandler::RUNTIME); | 618 FailedDatatypesHandler::RUNTIME); |
614 | 619 |
615 MessageLoop::current()->PostTask(FROM_HERE, | 620 MessageLoop::current()->PostTask(FROM_HERE, |
616 base::Bind(&ProfileSyncService::ReconfigureDatatypeManager, | 621 base::Bind(&ProfileSyncService::ReconfigureDatatypeManager, |
617 weak_factory_.GetWeakPtr())); | 622 weak_factory_.GetWeakPtr())); |
618 } | 623 } |
619 | 624 |
620 void ProfileSyncService::OnBackendInitialized( | 625 void ProfileSyncService::OnBackendInitialized( |
621 const WeakHandle<JsBackend>& js_backend, bool success) { | 626 const WeakHandle<JsBackend>& js_backend, bool success) { |
| 627 LOG(WARNING) << "OnBackendInitialized() : " << success; |
622 if (!HasSyncSetupCompleted()) { | 628 if (!HasSyncSetupCompleted()) { |
623 UMA_HISTOGRAM_BOOLEAN("Sync.BackendInitializeFirstTimeSuccess", success); | 629 UMA_HISTOGRAM_BOOLEAN("Sync.BackendInitializeFirstTimeSuccess", success); |
624 } else { | 630 } else { |
625 UMA_HISTOGRAM_BOOLEAN("Sync.BackendInitializeRestoreSuccess", success); | 631 UMA_HISTOGRAM_BOOLEAN("Sync.BackendInitializeRestoreSuccess", success); |
626 } | 632 } |
627 | 633 |
628 if (!success) { | 634 if (!success) { |
629 // Something went unexpectedly wrong. Play it safe: nuke our current state | 635 // Something went unexpectedly wrong. Play it safe: nuke our current state |
630 // and prepare ourselves to try again later. | 636 // and prepare ourselves to try again later. |
631 DisableForUser(); | 637 DisableForUser(); |
(...skipping 26 matching lines...) Expand all Loading... |
658 } | 664 } |
659 | 665 |
660 if (HasSyncSetupCompleted()) { | 666 if (HasSyncSetupCompleted()) { |
661 ConfigureDataTypeManager(); | 667 ConfigureDataTypeManager(); |
662 } else { | 668 } else { |
663 DCHECK(FirstSetupInProgress()); | 669 DCHECK(FirstSetupInProgress()); |
664 } | 670 } |
665 } | 671 } |
666 | 672 |
667 void ProfileSyncService::OnSyncCycleCompleted() { | 673 void ProfileSyncService::OnSyncCycleCompleted() { |
| 674 LOG(WARNING) << "OnSyncCycleCompleted"; |
668 UpdateLastSyncedTime(); | 675 UpdateLastSyncedTime(); |
669 if (GetSessionModelAssociator()) { | 676 if (GetSessionModelAssociator()) { |
670 // Trigger garbage collection of old sessions now that we've downloaded | 677 // Trigger garbage collection of old sessions now that we've downloaded |
671 // any new session data. TODO(zea): Have this be a notification the session | 678 // any new session data. TODO(zea): Have this be a notification the session |
672 // model associator listens too. Also consider somehow plumbing the current | 679 // model associator listens too. Also consider somehow plumbing the current |
673 // server time as last reported by CheckServerReachable, so we don't have to | 680 // server time as last reported by CheckServerReachable, so we don't have to |
674 // rely on the local clock, which may be off significantly. | 681 // rely on the local clock, which may be off significantly. |
675 MessageLoop::current()->PostTask(FROM_HERE, | 682 MessageLoop::current()->PostTask(FROM_HERE, |
676 base::Bind(&browser_sync::SessionModelAssociator::DeleteStaleSessions, | 683 base::Bind(&browser_sync::SessionModelAssociator::DeleteStaleSessions, |
677 GetSessionModelAssociator()->AsWeakPtr())); | 684 GetSessionModelAssociator()->AsWeakPtr())); |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
770 default: | 777 default: |
771 NOTREACHED(); | 778 NOTREACHED(); |
772 return GoogleServiceAuthError(GoogleServiceAuthError::CONNECTION_FAILED); | 779 return GoogleServiceAuthError(GoogleServiceAuthError::CONNECTION_FAILED); |
773 } | 780 } |
774 } | 781 } |
775 | 782 |
776 } // namespace | 783 } // namespace |
777 | 784 |
778 void ProfileSyncService::OnConnectionStatusChange( | 785 void ProfileSyncService::OnConnectionStatusChange( |
779 sync_api::ConnectionStatus status) { | 786 sync_api::ConnectionStatus status) { |
| 787 LOG(WARNING) << "OnConnectionStatusChange"; |
780 UpdateAuthErrorState(ConnectionStatusToAuthError(status)); | 788 UpdateAuthErrorState(ConnectionStatusToAuthError(status)); |
781 } | 789 } |
782 | 790 |
783 void ProfileSyncService::OnStopSyncingPermanently() { | 791 void ProfileSyncService::OnStopSyncingPermanently() { |
| 792 LOG(WARNING) << "OnStopSyncingPermanently"; |
784 UpdateAuthErrorState( | 793 UpdateAuthErrorState( |
785 GoogleServiceAuthError(GoogleServiceAuthError::SERVICE_UNAVAILABLE)); | 794 GoogleServiceAuthError(GoogleServiceAuthError::SERVICE_UNAVAILABLE)); |
786 sync_prefs_.SetStartSuppressed(true); | 795 sync_prefs_.SetStartSuppressed(true); |
787 DisableForUser(); | 796 DisableForUser(); |
788 } | 797 } |
789 | 798 |
790 void ProfileSyncService::OnClearServerDataTimeout() { | 799 void ProfileSyncService::OnClearServerDataTimeout() { |
| 800 LOG(WARNING) << "OnClearServerDataTimeout"; |
791 if (clear_server_data_state_ != CLEAR_SUCCEEDED && | 801 if (clear_server_data_state_ != CLEAR_SUCCEEDED && |
792 clear_server_data_state_ != CLEAR_FAILED) { | 802 clear_server_data_state_ != CLEAR_FAILED) { |
793 clear_server_data_state_ = CLEAR_FAILED; | 803 clear_server_data_state_ = CLEAR_FAILED; |
794 NotifyObservers(); | 804 NotifyObservers(); |
795 } | 805 } |
796 } | 806 } |
797 | 807 |
798 void ProfileSyncService::OnClearServerDataFailed() { | 808 void ProfileSyncService::OnClearServerDataFailed() { |
| 809 LOG(WARNING) << "OnClearServerDataFailed"; |
799 clear_server_data_timer_.Stop(); | 810 clear_server_data_timer_.Stop(); |
800 | 811 |
801 // Only once clear has succeeded there is no longer a need to transition to | 812 // Only once clear has succeeded there is no longer a need to transition to |
802 // a failed state as sync is disabled locally. Also, no need to fire off | 813 // a failed state as sync is disabled locally. Also, no need to fire off |
803 // the observers if the state didn't change (i.e. it was FAILED before). | 814 // the observers if the state didn't change (i.e. it was FAILED before). |
804 if (clear_server_data_state_ != CLEAR_SUCCEEDED && | 815 if (clear_server_data_state_ != CLEAR_SUCCEEDED && |
805 clear_server_data_state_ != CLEAR_FAILED) { | 816 clear_server_data_state_ != CLEAR_FAILED) { |
806 clear_server_data_state_ = CLEAR_FAILED; | 817 clear_server_data_state_ = CLEAR_FAILED; |
807 NotifyObservers(); | 818 NotifyObservers(); |
808 } | 819 } |
809 } | 820 } |
810 | 821 |
811 void ProfileSyncService::OnClearServerDataSucceeded() { | 822 void ProfileSyncService::OnClearServerDataSucceeded() { |
| 823 LOG(WARNING) << "OnClearServerDataSucceeded"; |
812 clear_server_data_timer_.Stop(); | 824 clear_server_data_timer_.Stop(); |
813 | 825 |
814 // Even if the timout fired, we still transition to the succeeded state as | 826 // Even if the timout fired, we still transition to the succeeded state as |
815 // we want UI to update itself and no longer allow the user to press "clear" | 827 // we want UI to update itself and no longer allow the user to press "clear" |
816 if (clear_server_data_state_ != CLEAR_SUCCEEDED) { | 828 if (clear_server_data_state_ != CLEAR_SUCCEEDED) { |
817 clear_server_data_state_ = CLEAR_SUCCEEDED; | 829 clear_server_data_state_ = CLEAR_SUCCEEDED; |
818 NotifyObservers(); | 830 NotifyObservers(); |
819 } | 831 } |
820 } | 832 } |
821 | 833 |
822 void ProfileSyncService::OnPassphraseRequired( | 834 void ProfileSyncService::OnPassphraseRequired( |
823 sync_api::PassphraseRequiredReason reason, | 835 sync_api::PassphraseRequiredReason reason, |
824 const sync_pb::EncryptedData& pending_keys) { | 836 const sync_pb::EncryptedData& pending_keys) { |
| 837 LOG(WARNING) << "OnPassphraseRequired"; |
825 DCHECK(backend_.get()); | 838 DCHECK(backend_.get()); |
826 DCHECK(backend_->IsNigoriEnabled()); | 839 DCHECK(backend_->IsNigoriEnabled()); |
827 | 840 |
828 // TODO(lipalani) : add this check to other locations as well. | 841 // TODO(lipalani) : add this check to other locations as well. |
829 if (unrecoverable_error_detected_) { | 842 if (unrecoverable_error_detected_) { |
830 // When unrecoverable error is detected we post a task to shutdown the | 843 // When unrecoverable error is detected we post a task to shutdown the |
831 // backend. The task might not have executed yet. | 844 // backend. The task might not have executed yet. |
832 return; | 845 return; |
833 } | 846 } |
834 | 847 |
835 DVLOG(1) << "Passphrase required with reason: " | 848 DVLOG(1) << "Passphrase required with reason: " |
836 << sync_api::PassphraseRequiredReasonToString(reason); | 849 << sync_api::PassphraseRequiredReasonToString(reason); |
837 passphrase_required_reason_ = reason; | 850 passphrase_required_reason_ = reason; |
838 | 851 |
839 // Notify observers that the passphrase status may have changed. | 852 // Notify observers that the passphrase status may have changed. |
840 NotifyObservers(); | 853 NotifyObservers(); |
841 } | 854 } |
842 | 855 |
843 void ProfileSyncService::OnPassphraseAccepted() { | 856 void ProfileSyncService::OnPassphraseAccepted() { |
| 857 LOG(WARNING) << "OnPassphraseAccepted"; |
844 DVLOG(1) << "Received OnPassphraseAccepted."; | 858 DVLOG(1) << "Received OnPassphraseAccepted."; |
845 // If we are not using an explicit passphrase, and we have a cache of the gaia | 859 // If we are not using an explicit passphrase, and we have a cache of the gaia |
846 // password, use it for encryption at this point. | 860 // password, use it for encryption at this point. |
847 DCHECK(cached_passphrase_.empty()) << | 861 DCHECK(cached_passphrase_.empty()) << |
848 "Passphrase no longer required but there is still a cached passphrase"; | 862 "Passphrase no longer required but there is still a cached passphrase"; |
849 | 863 |
850 // Reset passphrase_required_reason_ since we know we no longer require the | 864 // Reset passphrase_required_reason_ since we know we no longer require the |
851 // passphrase. We do this here rather than down in ResolvePassphraseRequired() | 865 // passphrase. We do this here rather than down in ResolvePassphraseRequired() |
852 // because that can be called by OnPassphraseRequired() if no encrypted data | 866 // because that can be called by OnPassphraseRequired() if no encrypted data |
853 // types are enabled, and we don't want to clobber the true passphrase error. | 867 // types are enabled, and we don't want to clobber the true passphrase error. |
(...skipping 18 matching lines...) Expand all Loading... |
872 encrypted_types_ = encrypted_types; | 886 encrypted_types_ = encrypted_types; |
873 encrypt_everything_ = encrypt_everything; | 887 encrypt_everything_ = encrypt_everything; |
874 DVLOG(1) << "Encrypted types changed to " | 888 DVLOG(1) << "Encrypted types changed to " |
875 << syncable::ModelTypeSetToString(encrypted_types_) | 889 << syncable::ModelTypeSetToString(encrypted_types_) |
876 << " (encrypt everything is set to " | 890 << " (encrypt everything is set to " |
877 << (encrypt_everything_ ? "true" : "false") << ")"; | 891 << (encrypt_everything_ ? "true" : "false") << ")"; |
878 DCHECK(encrypted_types_.Has(syncable::PASSWORDS)); | 892 DCHECK(encrypted_types_.Has(syncable::PASSWORDS)); |
879 } | 893 } |
880 | 894 |
881 void ProfileSyncService::OnEncryptionComplete() { | 895 void ProfileSyncService::OnEncryptionComplete() { |
| 896 LOG(WARNING) << "OnEncryptionComplete"; |
882 DVLOG(1) << "Encryption complete"; | 897 DVLOG(1) << "Encryption complete"; |
883 if (encryption_pending_ && encrypt_everything_) { | 898 if (encryption_pending_ && encrypt_everything_) { |
884 encryption_pending_ = false; | 899 encryption_pending_ = false; |
885 // This is to nudge the integration tests when encryption is | 900 // This is to nudge the integration tests when encryption is |
886 // finished. | 901 // finished. |
887 NotifyObservers(); | 902 NotifyObservers(); |
888 } | 903 } |
889 } | 904 } |
890 | 905 |
891 void ProfileSyncService::OnMigrationNeededForTypes( | 906 void ProfileSyncService::OnMigrationNeededForTypes( |
892 syncable::ModelTypeSet types) { | 907 syncable::ModelTypeSet types) { |
893 DCHECK(backend_initialized_); | 908 DCHECK(backend_initialized_); |
894 DCHECK(data_type_manager_.get()); | 909 DCHECK(data_type_manager_.get()); |
895 | 910 |
896 // Migrator must be valid, because we don't sync until it is created and this | 911 // Migrator must be valid, because we don't sync until it is created and this |
897 // callback originates from a sync cycle. | 912 // callback originates from a sync cycle. |
898 migrator_->MigrateTypes(types); | 913 migrator_->MigrateTypes(types); |
899 } | 914 } |
900 | 915 |
901 void ProfileSyncService::OnActionableError(const SyncProtocolError& error) { | 916 void ProfileSyncService::OnActionableError(const SyncProtocolError& error) { |
| 917 LOG(WARNING) << "OnActionableError"; |
902 last_actionable_error_ = error; | 918 last_actionable_error_ = error; |
903 DCHECK_NE(last_actionable_error_.action, | 919 DCHECK_NE(last_actionable_error_.action, |
904 browser_sync::UNKNOWN_ACTION); | 920 browser_sync::UNKNOWN_ACTION); |
905 switch (error.action) { | 921 switch (error.action) { |
906 case browser_sync::UPGRADE_CLIENT: | 922 case browser_sync::UPGRADE_CLIENT: |
907 case browser_sync::CLEAR_USER_DATA_AND_RESYNC: | 923 case browser_sync::CLEAR_USER_DATA_AND_RESYNC: |
908 case browser_sync::ENABLE_SYNC_ON_ACCOUNT: | 924 case browser_sync::ENABLE_SYNC_ON_ACCOUNT: |
909 case browser_sync::STOP_AND_RESTART_SYNC: | 925 case browser_sync::STOP_AND_RESTART_SYNC: |
910 // TODO(lipalani) : if setup in progress we want to display these | 926 // TODO(lipalani) : if setup in progress we want to display these |
911 // actions in the popup. The current experience might not be optimal for | 927 // actions in the popup. The current experience might not be optimal for |
(...skipping 518 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1430 ConsumeCachedPassphraseIfPossible(); | 1446 ConsumeCachedPassphraseIfPossible(); |
1431 } | 1447 } |
1432 if (!sync_initialized() || | 1448 if (!sync_initialized() || |
1433 GetAuthError().state() != GoogleServiceAuthError::NONE) { | 1449 GetAuthError().state() != GoogleServiceAuthError::NONE) { |
1434 // Track the fact that we're still waiting for auth to complete. | 1450 // Track the fact that we're still waiting for auth to complete. |
1435 is_auth_in_progress_ = true; | 1451 is_auth_in_progress_ = true; |
1436 } | 1452 } |
1437 break; | 1453 break; |
1438 } | 1454 } |
1439 case chrome::NOTIFICATION_TOKEN_REQUEST_FAILED: { | 1455 case chrome::NOTIFICATION_TOKEN_REQUEST_FAILED: { |
| 1456 LOG(WARNING) << "Got NOTIFICATION_TOKEN_REQUEST_FAILED"; |
1440 const TokenService::TokenRequestFailedDetails& token_details = | 1457 const TokenService::TokenRequestFailedDetails& token_details = |
1441 *(content::Details<const TokenService::TokenRequestFailedDetails>( | 1458 *(content::Details<const TokenService::TokenRequestFailedDetails>( |
1442 details).ptr()); | 1459 details).ptr()); |
1443 if (IsTokenServiceRelevant(token_details.service())) { | 1460 if (IsTokenServiceRelevant(token_details.service())) { |
1444 GoogleServiceAuthError error( | 1461 GoogleServiceAuthError error( |
1445 GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS); | 1462 GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS); |
1446 UpdateAuthErrorState(error); | 1463 UpdateAuthErrorState(error); |
1447 } | 1464 } |
1448 break; | 1465 break; |
1449 } | 1466 } |
1450 case chrome::NOTIFICATION_TOKEN_AVAILABLE: { | 1467 case chrome::NOTIFICATION_TOKEN_AVAILABLE: { |
| 1468 LOG(WARNING) << "Got NOTIFICATION_TOKEN_AVAILABLE"; |
1451 const TokenService::TokenAvailableDetails& token_details = | 1469 const TokenService::TokenAvailableDetails& token_details = |
1452 *(content::Details<const TokenService::TokenAvailableDetails>( | 1470 *(content::Details<const TokenService::TokenAvailableDetails>( |
1453 details).ptr()); | 1471 details).ptr()); |
1454 if (IsTokenServiceRelevant(token_details.service()) && | 1472 if (IsTokenServiceRelevant(token_details.service()) && |
1455 AreCredentialsAvailable()) { | 1473 AreCredentialsAvailable()) { |
1456 if (backend_initialized_) | 1474 if (backend_initialized_) |
1457 backend_->UpdateCredentials(GetCredentials()); | 1475 backend_->UpdateCredentials(GetCredentials()); |
1458 else if (!sync_prefs_.IsStartSuppressed()) | 1476 else if (!sync_prefs_.IsStartSuppressed()) |
1459 StartUp(); | 1477 StartUp(); |
1460 } | 1478 } |
1461 break; | 1479 break; |
1462 } | 1480 } |
1463 case chrome::NOTIFICATION_TOKEN_LOADING_FINISHED: { | 1481 case chrome::NOTIFICATION_TOKEN_LOADING_FINISHED: { |
| 1482 LOG(WARNING) << "Got NOTIFICATION_TOKEN_LOADING_FINISHED"; |
1464 // This notification gets fired when TokenService loads the tokens | 1483 // This notification gets fired when TokenService loads the tokens |
1465 // from storage. | 1484 // from storage. |
1466 if (AreCredentialsAvailable()) { | 1485 if (AreCredentialsAvailable()) { |
1467 // Initialize the backend if sync token was loaded. | 1486 // Initialize the backend if sync token was loaded. |
1468 if (backend_initialized_) { | 1487 if (backend_initialized_) { |
1469 backend_->UpdateCredentials(GetCredentials()); | 1488 backend_->UpdateCredentials(GetCredentials()); |
1470 } | 1489 } |
1471 if (!sync_prefs_.IsStartSuppressed()) | 1490 if (!sync_prefs_.IsStartSuppressed()) |
1472 StartUp(); | 1491 StartUp(); |
1473 } else if (!auto_start_enabled_ && | 1492 } else if (!auto_start_enabled_ && |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1528 return false; | 1547 return false; |
1529 | 1548 |
1530 return data_type_manager_->state() == DataTypeManager::CONFIGURED; | 1549 return data_type_manager_->state() == DataTypeManager::CONFIGURED; |
1531 } | 1550 } |
1532 | 1551 |
1533 void ProfileSyncService::StopAndSuppress() { | 1552 void ProfileSyncService::StopAndSuppress() { |
1534 sync_prefs_.SetStartSuppressed(true); | 1553 sync_prefs_.SetStartSuppressed(true); |
1535 ShutdownImpl(false); | 1554 ShutdownImpl(false); |
1536 } | 1555 } |
1537 | 1556 |
1538 void ProfileSyncService::UnsuppressAndStart() { | 1557 void ProfileSyncService::Unsuppress() { |
| 1558 LOG(WARNING) << "Unsuppress()"; |
1539 DCHECK(profile_); | 1559 DCHECK(profile_); |
1540 sync_prefs_.SetStartSuppressed(false); | 1560 sync_prefs_.SetStartSuppressed(false); |
| 1561 } |
| 1562 |
| 1563 void ProfileSyncService::UnsuppressAndStart() { |
| 1564 LOG(WARNING) << "UnsuppressAndStart()"; |
| 1565 Unsuppress(); |
1541 // Set username in SigninManager, as SigninManager::OnGetUserInfoSuccess | 1566 // Set username in SigninManager, as SigninManager::OnGetUserInfoSuccess |
1542 // is never called for some clients. | 1567 // is never called for some clients. |
1543 if (signin_ && signin_->GetAuthenticatedUsername().empty()) { | 1568 if (signin_ && signin_->GetAuthenticatedUsername().empty()) { |
1544 signin_->SetAuthenticatedUsername(sync_prefs_.GetGoogleServicesUsername()); | 1569 signin_->SetAuthenticatedUsername(sync_prefs_.GetGoogleServicesUsername()); |
1545 } | 1570 } |
1546 TryStart(); | 1571 TryStart(); |
1547 } | 1572 } |
1548 | 1573 |
1549 void ProfileSyncService::AcknowledgeSyncedTypes() { | 1574 void ProfileSyncService::AcknowledgeSyncedTypes() { |
1550 sync_prefs_.AcknowledgeSyncedTypes(GetRegisteredDataTypes()); | 1575 sync_prefs_.AcknowledgeSyncedTypes(GetRegisteredDataTypes()); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1586 // See http://stackoverflow.com/questions/6224121/is-new-this-myclass-undefine
d-behaviour-after-directly-calling-the-destru. | 1611 // See http://stackoverflow.com/questions/6224121/is-new-this-myclass-undefine
d-behaviour-after-directly-calling-the-destru. |
1587 ProfileSyncService* old_this = this; | 1612 ProfileSyncService* old_this = this; |
1588 this->~ProfileSyncService(); | 1613 this->~ProfileSyncService(); |
1589 new(old_this) ProfileSyncService( | 1614 new(old_this) ProfileSyncService( |
1590 new ProfileSyncComponentsFactoryImpl(profile, | 1615 new ProfileSyncComponentsFactoryImpl(profile, |
1591 CommandLine::ForCurrentProcess()), | 1616 CommandLine::ForCurrentProcess()), |
1592 profile, | 1617 profile, |
1593 signin, | 1618 signin, |
1594 behavior); | 1619 behavior); |
1595 } | 1620 } |
OLD | NEW |