| 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 1439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1450 // enabled, and yet we still think we require a passphrase for decryption. | 1450 // enabled, and yet we still think we require a passphrase for decryption. |
| 1451 DCHECK(!(IsPassphraseRequiredForDecryption() && | 1451 DCHECK(!(IsPassphraseRequiredForDecryption() && |
| 1452 !IsEncryptedDatatypeEnabled())); | 1452 !IsEncryptedDatatypeEnabled())); |
| 1453 | 1453 |
| 1454 // This must be done before we start syncing with the server to avoid | 1454 // This must be done before we start syncing with the server to avoid |
| 1455 // sending unencrypted data up on a first time sync. | 1455 // sending unencrypted data up on a first time sync. |
| 1456 if (encryption_pending_) | 1456 if (encryption_pending_) |
| 1457 backend_->EnableEncryptEverything(); | 1457 backend_->EnableEncryptEverything(); |
| 1458 NotifyObservers(); | 1458 NotifyObservers(); |
| 1459 | 1459 |
| 1460 // In the old world, this would be a no-op. With new syncer thread, | 1460 if (migrator_.get() && |
| 1461 // this is the point where it is safe to switch from config-mode to | 1461 migrator_->state() != browser_sync::BackendMigrator::IDLE) { |
| 1462 // normal operation. | 1462 // Migration in progress. Let the migrator know we just finished |
| 1463 backend_->StartSyncingWithServer(); | 1463 // configuring something. It will be up to the migrator to call |
| 1464 // StartSyncingWithServer() if migration is now finished. |
| 1465 migrator_->OnConfigureDone(*result); |
| 1466 } else { |
| 1467 StartSyncingWithServer(); |
| 1468 } |
| 1464 | 1469 |
| 1465 break; | 1470 break; |
| 1466 } | 1471 } |
| 1467 case chrome::NOTIFICATION_GOOGLE_SIGNIN_SUCCESSFUL: { | 1472 case chrome::NOTIFICATION_GOOGLE_SIGNIN_SUCCESSFUL: { |
| 1468 const GoogleServiceSigninSuccessDetails* successful = | 1473 const GoogleServiceSigninSuccessDetails* successful = |
| 1469 content::Details<const GoogleServiceSigninSuccessDetails>( | 1474 content::Details<const GoogleServiceSigninSuccessDetails>( |
| 1470 details).ptr(); | 1475 details).ptr(); |
| 1471 DCHECK(!successful->password.empty()); | 1476 DCHECK(!successful->password.empty()); |
| 1472 if (!sync_prefs_.IsStartSuppressed()) { | 1477 if (!sync_prefs_.IsStartSuppressed()) { |
| 1473 cached_passphrase_ = successful->password; | 1478 cached_passphrase_ = successful->password; |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1536 OnUnrecoverableError(FROM_HERE, "Sync credentials lost."); | 1541 OnUnrecoverableError(FROM_HERE, "Sync credentials lost."); |
| 1537 } | 1542 } |
| 1538 break; | 1543 break; |
| 1539 } | 1544 } |
| 1540 default: { | 1545 default: { |
| 1541 NOTREACHED(); | 1546 NOTREACHED(); |
| 1542 } | 1547 } |
| 1543 } | 1548 } |
| 1544 } | 1549 } |
| 1545 | 1550 |
| 1551 void ProfileSyncService::StartSyncingWithServer() { |
| 1552 if (backend_.get()) |
| 1553 backend_->StartSyncingWithServer(); |
| 1554 } |
| 1555 |
| 1546 void ProfileSyncService::AddObserver(Observer* observer) { | 1556 void ProfileSyncService::AddObserver(Observer* observer) { |
| 1547 observers_.AddObserver(observer); | 1557 observers_.AddObserver(observer); |
| 1548 } | 1558 } |
| 1549 | 1559 |
| 1550 void ProfileSyncService::RemoveObserver(Observer* observer) { | 1560 void ProfileSyncService::RemoveObserver(Observer* observer) { |
| 1551 observers_.RemoveObserver(observer); | 1561 observers_.RemoveObserver(observer); |
| 1552 } | 1562 } |
| 1553 | 1563 |
| 1554 bool ProfileSyncService::HasObserver(Observer* observer) const { | 1564 bool ProfileSyncService::HasObserver(Observer* observer) const { |
| 1555 return observers_.HasObserver(observer); | 1565 return observers_.HasObserver(observer); |
| (...skipping 87 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. | 1653 // See http://stackoverflow.com/questions/6224121/is-new-this-myclass-undefine
d-behaviour-after-directly-calling-the-destru. |
| 1644 ProfileSyncService* old_this = this; | 1654 ProfileSyncService* old_this = this; |
| 1645 this->~ProfileSyncService(); | 1655 this->~ProfileSyncService(); |
| 1646 new(old_this) ProfileSyncService( | 1656 new(old_this) ProfileSyncService( |
| 1647 new ProfileSyncComponentsFactoryImpl(profile, | 1657 new ProfileSyncComponentsFactoryImpl(profile, |
| 1648 CommandLine::ForCurrentProcess()), | 1658 CommandLine::ForCurrentProcess()), |
| 1649 profile, | 1659 profile, |
| 1650 signin, | 1660 signin, |
| 1651 behavior); | 1661 behavior); |
| 1652 } | 1662 } |
| OLD | NEW |