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 14 matching lines...) Expand all Loading... | |
25 #include "base/threading/thread_restrictions.h" | 25 #include "base/threading/thread_restrictions.h" |
26 #include "build/build_config.h" | 26 #include "build/build_config.h" |
27 #include "chrome/browser/bookmarks/enhanced_bookmarks_features.h" | 27 #include "chrome/browser/bookmarks/enhanced_bookmarks_features.h" |
28 #include "chrome/browser/browser_process.h" | 28 #include "chrome/browser/browser_process.h" |
29 #include "chrome/browser/browsing_data/browsing_data_helper.h" | 29 #include "chrome/browser/browsing_data/browsing_data_helper.h" |
30 #include "chrome/browser/browsing_data/browsing_data_remover.h" | 30 #include "chrome/browser/browsing_data/browsing_data_remover.h" |
31 #include "chrome/browser/chrome_notification_types.h" | 31 #include "chrome/browser/chrome_notification_types.h" |
32 #include "chrome/browser/defaults.h" | 32 #include "chrome/browser/defaults.h" |
33 #include "chrome/browser/invalidation/profile_invalidation_provider_factory.h" | 33 #include "chrome/browser/invalidation/profile_invalidation_provider_factory.h" |
34 #include "chrome/browser/net/chrome_cookie_notification_details.h" | 34 #include "chrome/browser/net/chrome_cookie_notification_details.h" |
35 #include "chrome/browser/prefs/pref_hash_filter.h" | |
35 #include "chrome/browser/prefs/pref_service_syncable.h" | 36 #include "chrome/browser/prefs/pref_service_syncable.h" |
36 #include "chrome/browser/profiles/profile.h" | 37 #include "chrome/browser/profiles/profile.h" |
37 #include "chrome/browser/services/gcm/gcm_profile_service.h" | 38 #include "chrome/browser/services/gcm/gcm_profile_service.h" |
38 #include "chrome/browser/services/gcm/gcm_profile_service_factory.h" | 39 #include "chrome/browser/services/gcm/gcm_profile_service_factory.h" |
39 #include "chrome/browser/signin/about_signin_internals_factory.h" | 40 #include "chrome/browser/signin/about_signin_internals_factory.h" |
40 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" | 41 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" |
41 #include "chrome/browser/signin/signin_manager_factory.h" | 42 #include "chrome/browser/signin/signin_manager_factory.h" |
42 #include "chrome/browser/sync/backend_migrator.h" | 43 #include "chrome/browser/sync/backend_migrator.h" |
43 #include "chrome/browser/sync/glue/chrome_report_unrecoverable_error.h" | 44 #include "chrome/browser/sync/glue/chrome_report_unrecoverable_error.h" |
44 #include "chrome/browser/sync/glue/device_info.h" | 45 #include "chrome/browser/sync/glue/device_info.h" |
(...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
511 if (credentials.sync_token.empty()) | 512 if (credentials.sync_token.empty()) |
512 credentials.sync_token = "credentials_lost"; | 513 credentials.sync_token = "credentials_lost"; |
513 | 514 |
514 credentials.scope_set.insert(signin_->GetSyncScopeToUse()); | 515 credentials.scope_set.insert(signin_->GetSyncScopeToUse()); |
515 } | 516 } |
516 | 517 |
517 return credentials; | 518 return credentials; |
518 } | 519 } |
519 | 520 |
520 bool ProfileSyncService::ShouldDeleteSyncFolder() { | 521 bool ProfileSyncService::ShouldDeleteSyncFolder() { |
522 DVLOG(1) << "start time: " << profile_->GetStartTime().ToInternalValue() | |
523 << ", reset time: " | |
524 << PrefHashFilter::GetResetTime(profile_->GetPrefs()).ToInternalValue(); | |
gab
2014/07/03 13:08:53
Please use chrome_prefs::GetResetTime(Profile*) fr
haitaol1
2014/07/07 20:43:19
Done.
| |
525 | |
521 if (backend_mode_ == SYNC) | 526 if (backend_mode_ == SYNC) |
522 return !HasSyncSetupCompleted(); | 527 return !HasSyncSetupCompleted(); |
523 | 528 |
524 // Start fresh if it's the first time backup after user stopped syncing. | 529 if (backend_mode_ == BACKUP) { |
525 // This is needed because backup DB may contain items deleted by user during | 530 // Start fresh if: |
526 // sync period and can cause back-from-dead issues. | 531 // * It's the first time backup after user stopped syncing because backup |
527 if (backend_mode_ == BACKUP && !sync_prefs_.GetFirstSyncTime().is_null()) | 532 // DB may contain items deleted by user during sync period and can cause |
528 return true; | 533 // back-from-dead issues if user didn't choose rollback. |
534 // * Settings are tampered and reset during startup to avoid undo reset. | |
535 if (!sync_prefs_.GetFirstSyncTime().is_null() || | |
536 profile_->GetStartTime() <= | |
537 PrefHashFilter::GetResetTime(profile_->GetPrefs())) { | |
538 return true; | |
539 } | |
540 } | |
529 | 541 |
530 return false; | 542 return false; |
531 } | 543 } |
532 | 544 |
533 void ProfileSyncService::InitializeBackend(bool delete_stale_data) { | 545 void ProfileSyncService::InitializeBackend(bool delete_stale_data) { |
534 if (!backend_) { | 546 if (!backend_) { |
535 NOTREACHED(); | 547 NOTREACHED(); |
536 return; | 548 return; |
537 } | 549 } |
538 | 550 |
(...skipping 2041 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2580 } | 2592 } |
2581 return result; | 2593 return result; |
2582 } | 2594 } |
2583 | 2595 |
2584 void ProfileSyncService::StartStopBackupForTesting() { | 2596 void ProfileSyncService::StartStopBackupForTesting() { |
2585 if (backend_mode_ == BACKUP) | 2597 if (backend_mode_ == BACKUP) |
2586 ShutdownImpl(browser_sync::SyncBackendHost::STOP_AND_CLAIM_THREAD); | 2598 ShutdownImpl(browser_sync::SyncBackendHost::STOP_AND_CLAIM_THREAD); |
2587 else | 2599 else |
2588 backup_rollback_controller_.Start(base::TimeDelta()); | 2600 backup_rollback_controller_.Start(base::TimeDelta()); |
2589 } | 2601 } |
OLD | NEW |