| 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..7540b23da66d0f2ae8c33ad3238068b0716b461c 100644
|
| --- a/chrome/browser/sync/profile_sync_service.cc
|
| +++ b/chrome/browser/sync/profile_sync_service.cc
|
| @@ -33,6 +33,7 @@
|
| #include "chrome/browser/sync/api/sync_error.h"
|
| #include "chrome/browser/sync/backend_migrator.h"
|
| #include "chrome/browser/sync/glue/change_processor.h"
|
| +#include "chrome/browser/sync/glue/chrome_encryptor.h"
|
| #include "chrome/browser/sync/glue/chrome_report_unrecoverable_error.h"
|
| #include "chrome/browser/sync/glue/data_type_controller.h"
|
| #include "chrome/browser/sync/glue/session_data_type_controller.h"
|
| @@ -201,6 +202,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 +222,8 @@ void ProfileSyncService::TryStart() {
|
| // trigger an unrecoverable error.
|
| OnUnrecoverableError(FROM_HERE, "Sync credentials lost.");
|
| }
|
| + } else {
|
| + LOG(WARNING) << "TryStart: did nothing.";
|
| }
|
| }
|
|
|
| @@ -332,6 +336,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 +349,7 @@ void ProfileSyncService::InitializeBackend(bool delete_stale_data) {
|
| }
|
|
|
| void ProfileSyncService::CreateBackend() {
|
| + LOG(WARNING) << "CreateBackend";
|
| backend_.reset(
|
| new SyncBackendHost(profile_->GetDebugName(),
|
| profile_, sync_prefs_.AsWeakPtr()));
|
| @@ -397,6 +403,10 @@ void ProfileSyncService::StartUp() {
|
|
|
| last_synced_time_ = sync_prefs_.GetLastSyncedTime();
|
|
|
| + std::string bootstrap_token = sync_prefs_.GetEncryptionBootstrapToken();
|
| + if (bootstrap_token.empty())
|
| + sync_prefs_.SetEncryptionBootstrapToken(
|
| + sync_prefs_.GetSpareBootstrapToken());
|
| CreateBackend();
|
|
|
| // Initialize the backend. Every time we start up a new SyncBackendHost,
|
| @@ -619,6 +629,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 +676,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 +789,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 +802,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 +811,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 +825,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 +839,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 +859,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 +898,7 @@ void ProfileSyncService::OnEncryptedTypesChanged(
|
| }
|
|
|
| void ProfileSyncService::OnEncryptionComplete() {
|
| + LOG(WARNING) << "OnEncryptionComplete";
|
| DVLOG(1) << "Encryption complete";
|
| if (encryption_pending_ && encrypt_everything_) {
|
| encryption_pending_ = false;
|
| @@ -899,6 +919,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 +1092,20 @@ void ProfileSyncService::UpdateSelectedTypesHistogram(
|
| }
|
| }
|
|
|
| +void ProfileSyncService::RefreshSpareBootstrapToken(
|
| + const std::string& passphrase) {
|
| + browser_sync::ChromeEncryptor encryptor;
|
| + browser_sync::Cryptographer temp_cryptographer(&encryptor);
|
| + browser_sync::KeyParams key_params = {"localhost", "dummy", passphrase};
|
| +
|
| + std::string bootstrap_token;
|
| + if (!temp_cryptographer.AddKey(key_params)) {
|
| + NOTREACHED() << "Failed to add key to cryptographer.";
|
| + }
|
| + temp_cryptographer.GetBootstrapToken(&bootstrap_token);
|
| + sync_prefs_.SetSpareBootstrapToken(bootstrap_token);
|
| +}
|
| +
|
| void ProfileSyncService::OnUserChoseDatatypes(bool sync_everything,
|
| syncable::ModelTypeSet chosen_types) {
|
| if (!backend_.get() &&
|
| @@ -1429,6 +1464,9 @@ void ProfileSyncService::Observe(int type,
|
| // backend starts up.
|
| ConsumeCachedPassphraseIfPossible();
|
| }
|
| +#if defined(OS_CHROMEOS)
|
| + RefreshSpareBootstrapToken(successful->password);
|
| +#endif
|
| 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()) {
|
| @@ -1536,6 +1577,7 @@ void ProfileSyncService::StopAndSuppress() {
|
| }
|
|
|
| void ProfileSyncService::UnsuppressAndStart() {
|
| + LOG(WARNING) << "UnsuppressAndStart()";
|
| DCHECK(profile_);
|
| sync_prefs_.SetStartSuppressed(false);
|
| // Set username in SigninManager, as SigninManager::OnGetUserInfoSuccess
|
|
|