Chromium Code Reviews| Index: chrome/browser/sync/profile_sync_service.cc |
| diff --git a/chrome/browser/sync/profile_sync_service.cc b/chrome/browser/sync/profile_sync_service.cc |
| index 5257b6a8d80ae2b68c6bda3994bf83895148dcf1..b614b39880555a37c16aa9d0ca21a1179c4d6b35 100644 |
| --- a/chrome/browser/sync/profile_sync_service.cc |
| +++ b/chrome/browser/sync/profile_sync_service.cc |
| @@ -40,6 +40,8 @@ |
| #include "chrome/browser/sync/glue/typed_url_data_type_controller.h" |
| #include "chrome/browser/sync/internal_api/configure_reason.h" |
| #include "chrome/browser/sync/internal_api/sync_manager.h" |
| +#include "chrome/browser/sync/internal_api/write_node.h" |
| +#include "chrome/browser/sync/internal_api/write_transaction.h" |
| #include "chrome/browser/sync/profile_sync_components_factory_impl.h" |
| #include "chrome/browser/sync/sync_global_error.h" |
| #include "chrome/browser/sync/user_selectable_sync_type.h" |
| @@ -201,6 +203,7 @@ void ProfileSyncService::Initialize() { |
| } |
| void ProfileSyncService::TryStart() { |
| + LOG(WARNING) << "TryStart"; |
| if (!sync_prefs_.IsStartSuppressed() && AreCredentialsAvailable()) { |
| if (HasSyncSetupCompleted() || auto_start_enabled_) { |
| // If sync setup has completed we always start the backend. |
| @@ -220,6 +223,8 @@ void ProfileSyncService::TryStart() { |
| // trigger an unrecoverable error. |
| OnUnrecoverableError(FROM_HERE, "Sync credentials lost."); |
| } |
| + } else { |
| + LOG(WARNING) << "TryStart: did nothing."; |
| } |
| } |
| @@ -332,6 +337,7 @@ void ProfileSyncService::InitializeBackend(bool delete_stale_data) { |
| new browser_sync::BackendUnrecoverableErrorHandler( |
| MakeWeakHandle(AsWeakPtr()))); |
| + LOG(WARNING) << "Initializing backend"; |
| backend_->Initialize( |
| this, |
| MakeWeakHandle(sync_js_controller_.AsWeakPtr()), |
| @@ -344,6 +350,7 @@ void ProfileSyncService::InitializeBackend(bool delete_stale_data) { |
| } |
| void ProfileSyncService::CreateBackend() { |
| + LOG(WARNING) << "CreateBackend"; |
| backend_.reset( |
| new SyncBackendHost(profile_->GetDebugName(), |
| profile_, sync_prefs_.AsWeakPtr())); |
| @@ -619,6 +626,7 @@ void ProfileSyncService::OnDisableDatatype( |
| void ProfileSyncService::OnBackendInitialized( |
| const WeakHandle<JsBackend>& js_backend, bool success) { |
| + LOG(WARNING) << "OnBackendInitialized() : " << success; |
| if (!HasSyncSetupCompleted()) { |
| UMA_HISTOGRAM_BOOLEAN("Sync.BackendInitializeFirstTimeSuccess", success); |
| } else { |
| @@ -665,6 +673,7 @@ void ProfileSyncService::OnBackendInitialized( |
| } |
| void ProfileSyncService::OnSyncCycleCompleted() { |
| + LOG(WARNING) << "OnSyncCycleCompleted"; |
| UpdateLastSyncedTime(); |
| if (GetSessionModelAssociator()) { |
| // Trigger garbage collection of old sessions now that we've downloaded |
| @@ -777,10 +786,12 @@ GoogleServiceAuthError ConnectionStatusToAuthError( |
| void ProfileSyncService::OnConnectionStatusChange( |
| sync_api::ConnectionStatus status) { |
| + LOG(WARNING) << "OnConnectionStatusChange"; |
| UpdateAuthErrorState(ConnectionStatusToAuthError(status)); |
| } |
| void ProfileSyncService::OnStopSyncingPermanently() { |
| + LOG(WARNING) << "OnStopSyncingPermanently"; |
| UpdateAuthErrorState( |
| GoogleServiceAuthError(GoogleServiceAuthError::SERVICE_UNAVAILABLE)); |
| sync_prefs_.SetStartSuppressed(true); |
| @@ -788,6 +799,7 @@ void ProfileSyncService::OnStopSyncingPermanently() { |
| } |
| void ProfileSyncService::OnClearServerDataTimeout() { |
| + LOG(WARNING) << "OnClearServerDataTimeout"; |
| if (clear_server_data_state_ != CLEAR_SUCCEEDED && |
| clear_server_data_state_ != CLEAR_FAILED) { |
| clear_server_data_state_ = CLEAR_FAILED; |
| @@ -796,6 +808,7 @@ void ProfileSyncService::OnClearServerDataTimeout() { |
| } |
| void ProfileSyncService::OnClearServerDataFailed() { |
| + LOG(WARNING) << "OnClearServerDataFailed"; |
| clear_server_data_timer_.Stop(); |
| // Only once clear has succeeded there is no longer a need to transition to |
| @@ -809,6 +822,7 @@ void ProfileSyncService::OnClearServerDataFailed() { |
| } |
| void ProfileSyncService::OnClearServerDataSucceeded() { |
| + LOG(WARNING) << "OnClearServerDataSucceeded"; |
| clear_server_data_timer_.Stop(); |
| // Even if the timout fired, we still transition to the succeeded state as |
| @@ -822,6 +836,7 @@ void ProfileSyncService::OnClearServerDataSucceeded() { |
| void ProfileSyncService::OnPassphraseRequired( |
| sync_api::PassphraseRequiredReason reason, |
| const sync_pb::EncryptedData& pending_keys) { |
| + LOG(WARNING) << "OnPassphraseRequired"; |
| DCHECK(backend_.get()); |
| DCHECK(backend_->IsNigoriEnabled()); |
| @@ -841,6 +856,7 @@ void ProfileSyncService::OnPassphraseRequired( |
| } |
| void ProfileSyncService::OnPassphraseAccepted() { |
| + LOG(WARNING) << "OnPassphraseAccepted"; |
| DVLOG(1) << "Received OnPassphraseAccepted."; |
| // If we are not using an explicit passphrase, and we have a cache of the gaia |
| // password, use it for encryption at this point. |
| @@ -879,6 +895,7 @@ void ProfileSyncService::OnEncryptedTypesChanged( |
| } |
| void ProfileSyncService::OnEncryptionComplete() { |
| + LOG(WARNING) << "OnEncryptionComplete"; |
| DVLOG(1) << "Encryption complete"; |
| if (encryption_pending_ && encrypt_everything_) { |
| encryption_pending_ = false; |
| @@ -899,6 +916,7 @@ void ProfileSyncService::OnMigrationNeededForTypes( |
| } |
| void ProfileSyncService::OnActionableError(const SyncProtocolError& error) { |
| + LOG(WARNING) << "OnActionableError"; |
| last_actionable_error_ = error; |
| DCHECK_NE(last_actionable_error_.action, |
| browser_sync::UNKNOWN_ACTION); |
| @@ -1071,6 +1089,25 @@ void ProfileSyncService::UpdateSelectedTypesHistogram( |
| } |
| } |
| +void ProfileSyncService::RefreshSpareBootstrapToken(const std::string& passphrase) { |
| + // All accesses to the cryptographer are protected by a transaction. |
| + sync_api::WriteTransaction trans(FROM_HERE, GetUserShare()); |
| + browser_sync::Cryptographer* cryptographer = trans.GetCryptographer(); |
|
Nicolas Zea
2012/04/03 21:00:33
This is using the sync's internal cryptographer. I
kochi
2012/04/03 22:45:43
Thanks! This code snippet was very cryptic and I
|
| + browser_sync::KeyParams key_params = {"localhost", "dummy", passphrase}; |
| + sync_api::WriteNode node(&trans); |
| + if (!node.InitByTagLookup(browser_sync::kNigoriTag)) { |
| + NOTREACHED(); |
| + return; |
| + } |
| + |
| + std::string bootstrap_token; |
| + if (!cryptographer->AddKey(key_params)) { |
| + NOTREACHED() << "Failed to add key to cryptographer."; |
| + } |
| + cryptographer->GetBootstrapToken(&bootstrap_token); |
| + sync_prefs_.SetSpareBootstrapToken(bootstrap_token); |
| +} |
| + |
| void ProfileSyncService::OnUserChoseDatatypes(bool sync_everything, |
| syncable::ModelTypeSet chosen_types) { |
| if (!backend_.get() && |
| @@ -1429,6 +1466,7 @@ void ProfileSyncService::Observe(int type, |
| // backend starts up. |
| ConsumeCachedPassphraseIfPossible(); |
| } |
| + RefreshSpareBootstrapToken(successful->password); |
|
Nicolas Zea
2012/04/03 21:00:33
Condition this on OS_CHROMEOS
kochi
2012/04/03 22:45:43
Done.
|
| if (!sync_initialized() || |
| GetAuthError().state() != GoogleServiceAuthError::NONE) { |
| // Track the fact that we're still waiting for auth to complete. |
| @@ -1437,6 +1475,7 @@ void ProfileSyncService::Observe(int type, |
| break; |
| } |
| case chrome::NOTIFICATION_TOKEN_REQUEST_FAILED: { |
| + LOG(WARNING) << "Got NOTIFICATION_TOKEN_REQUEST_FAILED"; |
| const TokenService::TokenRequestFailedDetails& token_details = |
| *(content::Details<const TokenService::TokenRequestFailedDetails>( |
| details).ptr()); |
| @@ -1448,6 +1487,7 @@ void ProfileSyncService::Observe(int type, |
| break; |
| } |
| case chrome::NOTIFICATION_TOKEN_AVAILABLE: { |
| + LOG(WARNING) << "Got NOTIFICATION_TOKEN_AVAILABLE"; |
| const TokenService::TokenAvailableDetails& token_details = |
| *(content::Details<const TokenService::TokenAvailableDetails>( |
| details).ptr()); |
| @@ -1461,6 +1501,7 @@ void ProfileSyncService::Observe(int type, |
| break; |
| } |
| case chrome::NOTIFICATION_TOKEN_LOADING_FINISHED: { |
| + LOG(WARNING) << "Got NOTIFICATION_TOKEN_LOADING_FINISHED"; |
| // This notification gets fired when TokenService loads the tokens |
| // from storage. |
| if (AreCredentialsAvailable()) { |
| @@ -1535,9 +1576,15 @@ void ProfileSyncService::StopAndSuppress() { |
| ShutdownImpl(false); |
| } |
| -void ProfileSyncService::UnsuppressAndStart() { |
| +void ProfileSyncService::Unsuppress() { |
| + LOG(WARNING) << "Unsuppress()"; |
| DCHECK(profile_); |
| sync_prefs_.SetStartSuppressed(false); |
| +} |
| + |
| +void ProfileSyncService::UnsuppressAndStart() { |
| + LOG(WARNING) << "UnsuppressAndStart()"; |
| + Unsuppress(); |
| // Set username in SigninManager, as SigninManager::OnGetUserInfoSuccess |
| // is never called for some clients. |
| if (signin_ && signin_->GetAuthenticatedUsername().empty()) { |