| 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 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 if (token_service && token_service->TokensLoadedFromDB() && | 224 if (token_service && token_service->TokensLoadedFromDB() && |
| 225 !AreCredentialsAvailable()) { | 225 !AreCredentialsAvailable()) { |
| 226 // The token service has lost sync's tokens. We cannot recover from this | 226 // The token service has lost sync's tokens. We cannot recover from this |
| 227 // without signing back in, which is not yet supported. For now, we | 227 // without signing back in, which is not yet supported. For now, we |
| 228 // trigger an unrecoverable error. | 228 // trigger an unrecoverable error. |
| 229 OnUnrecoverableError(FROM_HERE, "Sync credentials lost."); | 229 OnUnrecoverableError(FROM_HERE, "Sync credentials lost."); |
| 230 } | 230 } |
| 231 } | 231 } |
| 232 } | 232 } |
| 233 | 233 |
| 234 void ProfileSyncService::StartSyncingWithServer() { |
| 235 if (backend_.get()) |
| 236 backend_->StartSyncingWithServer(); |
| 237 } |
| 238 |
| 234 void ProfileSyncService::RegisterAuthNotifications() { | 239 void ProfileSyncService::RegisterAuthNotifications() { |
| 235 TokenService* token_service = TokenServiceFactory::GetForProfile(profile_); | 240 TokenService* token_service = TokenServiceFactory::GetForProfile(profile_); |
| 236 registrar_.Add(this, | 241 registrar_.Add(this, |
| 237 chrome::NOTIFICATION_TOKEN_AVAILABLE, | 242 chrome::NOTIFICATION_TOKEN_AVAILABLE, |
| 238 content::Source<TokenService>(token_service)); | 243 content::Source<TokenService>(token_service)); |
| 239 registrar_.Add(this, | 244 registrar_.Add(this, |
| 240 chrome::NOTIFICATION_TOKEN_LOADING_FINISHED, | 245 chrome::NOTIFICATION_TOKEN_LOADING_FINISHED, |
| 241 content::Source<TokenService>(token_service)); | 246 content::Source<TokenService>(token_service)); |
| 242 registrar_.Add(this, | 247 registrar_.Add(this, |
| 243 chrome::NOTIFICATION_TOKEN_REQUEST_FAILED, | 248 chrome::NOTIFICATION_TOKEN_REQUEST_FAILED, |
| (...skipping 942 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1186 chrome::NOTIFICATION_SYNC_CONFIGURE_START, | 1191 chrome::NOTIFICATION_SYNC_CONFIGURE_START, |
| 1187 content::Source<DataTypeManager>(data_type_manager_.get())); | 1192 content::Source<DataTypeManager>(data_type_manager_.get())); |
| 1188 registrar_.Add(this, | 1193 registrar_.Add(this, |
| 1189 chrome::NOTIFICATION_SYNC_CONFIGURE_DONE, | 1194 chrome::NOTIFICATION_SYNC_CONFIGURE_DONE, |
| 1190 content::Source<DataTypeManager>(data_type_manager_.get())); | 1195 content::Source<DataTypeManager>(data_type_manager_.get())); |
| 1191 | 1196 |
| 1192 // We create the migrator at the same time. | 1197 // We create the migrator at the same time. |
| 1193 migrator_.reset( | 1198 migrator_.reset( |
| 1194 new browser_sync::BackendMigrator( | 1199 new browser_sync::BackendMigrator( |
| 1195 profile_->GetDebugName(), GetUserShare(), | 1200 profile_->GetDebugName(), GetUserShare(), |
| 1196 this, data_type_manager_.get())); | 1201 this, data_type_manager_.get(), |
| 1202 base::Bind(&ProfileSyncService::StartSyncingWithServer, |
| 1203 base::Unretained(this)))); |
| 1197 } | 1204 } |
| 1198 | 1205 |
| 1199 const syncable::ModelTypeSet types = GetPreferredDataTypes(); | 1206 const syncable::ModelTypeSet types = GetPreferredDataTypes(); |
| 1200 if (IsPassphraseRequiredForDecryption()) { | 1207 if (IsPassphraseRequiredForDecryption()) { |
| 1201 // We need a passphrase still. We don't bother to attempt to configure | 1208 // We need a passphrase still. We don't bother to attempt to configure |
| 1202 // until we receive an OnPassphraseAccepted (which triggers a configure). | 1209 // until we receive an OnPassphraseAccepted (which triggers a configure). |
| 1203 DVLOG(1) << "ProfileSyncService::ConfigureDataTypeManager bailing out " | 1210 DVLOG(1) << "ProfileSyncService::ConfigureDataTypeManager bailing out " |
| 1204 << "because a passphrase required"; | 1211 << "because a passphrase required"; |
| 1205 return; | 1212 return; |
| 1206 } | 1213 } |
| (...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1450 // enabled, and yet we still think we require a passphrase for decryption. | 1457 // enabled, and yet we still think we require a passphrase for decryption. |
| 1451 DCHECK(!(IsPassphraseRequiredForDecryption() && | 1458 DCHECK(!(IsPassphraseRequiredForDecryption() && |
| 1452 !IsEncryptedDatatypeEnabled())); | 1459 !IsEncryptedDatatypeEnabled())); |
| 1453 | 1460 |
| 1454 // This must be done before we start syncing with the server to avoid | 1461 // This must be done before we start syncing with the server to avoid |
| 1455 // sending unencrypted data up on a first time sync. | 1462 // sending unencrypted data up on a first time sync. |
| 1456 if (encryption_pending_) | 1463 if (encryption_pending_) |
| 1457 backend_->EnableEncryptEverything(); | 1464 backend_->EnableEncryptEverything(); |
| 1458 NotifyObservers(); | 1465 NotifyObservers(); |
| 1459 | 1466 |
| 1460 // In the old world, this would be a no-op. With new syncer thread, | 1467 if (migrator_.get() && |
| 1461 // this is the point where it is safe to switch from config-mode to | 1468 migrator_->state() != browser_sync::BackendMigrator::IDLE) { |
| 1462 // normal operation. | 1469 // Migration in progress. Let the migrator know we just finished |
| 1463 backend_->StartSyncingWithServer(); | 1470 // configuring something. It will be up to the migrator to call |
| 1471 // StartSyncingWithServer() if migration is now finished. |
| 1472 migrator_->OnConfigureDone(*result); |
| 1473 } else { |
| 1474 StartSyncingWithServer(); |
| 1475 } |
| 1464 | 1476 |
| 1465 break; | 1477 break; |
| 1466 } | 1478 } |
| 1467 case chrome::NOTIFICATION_GOOGLE_SIGNIN_SUCCESSFUL: { | 1479 case chrome::NOTIFICATION_GOOGLE_SIGNIN_SUCCESSFUL: { |
| 1468 const GoogleServiceSigninSuccessDetails* successful = | 1480 const GoogleServiceSigninSuccessDetails* successful = |
| 1469 content::Details<const GoogleServiceSigninSuccessDetails>( | 1481 content::Details<const GoogleServiceSigninSuccessDetails>( |
| 1470 details).ptr(); | 1482 details).ptr(); |
| 1471 DCHECK(!successful->password.empty()); | 1483 DCHECK(!successful->password.empty()); |
| 1472 if (!sync_prefs_.IsStartSuppressed()) { | 1484 if (!sync_prefs_.IsStartSuppressed()) { |
| 1473 cached_passphrase_ = successful->password; | 1485 cached_passphrase_ = successful->password; |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1643 // See http://stackoverflow.com/questions/6224121/is-new-this-myclass-undefine
d-behaviour-after-directly-calling-the-destru. | 1655 // See http://stackoverflow.com/questions/6224121/is-new-this-myclass-undefine
d-behaviour-after-directly-calling-the-destru. |
| 1644 ProfileSyncService* old_this = this; | 1656 ProfileSyncService* old_this = this; |
| 1645 this->~ProfileSyncService(); | 1657 this->~ProfileSyncService(); |
| 1646 new(old_this) ProfileSyncService( | 1658 new(old_this) ProfileSyncService( |
| 1647 new ProfileSyncComponentsFactoryImpl(profile, | 1659 new ProfileSyncComponentsFactoryImpl(profile, |
| 1648 CommandLine::ForCurrentProcess()), | 1660 CommandLine::ForCurrentProcess()), |
| 1649 profile, | 1661 profile, |
| 1650 signin, | 1662 signin, |
| 1651 behavior); | 1663 behavior); |
| 1652 } | 1664 } |
| OLD | NEW |