| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "base/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "base/files/file_util.h" | 6 #include "base/files/file_util.h" |
| 7 #include "base/message_loop/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
| 8 #include "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
| 9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
| 10 #include "base/test/test_timeouts.h" | 10 #include "base/test/test_timeouts.h" |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 }; | 75 }; |
| 76 | 76 |
| 77 // Waits until the ProfileSyncService's backend is in IDLE mode. | 77 // Waits until the ProfileSyncService's backend is in IDLE mode. |
| 78 class SyncBackendStoppedChecker : public ProfileSyncServiceBase::Observer { | 78 class SyncBackendStoppedChecker : public ProfileSyncServiceBase::Observer { |
| 79 public: | 79 public: |
| 80 explicit SyncBackendStoppedChecker(ProfileSyncService* service) | 80 explicit SyncBackendStoppedChecker(ProfileSyncService* service) |
| 81 : pss_(service), | 81 : pss_(service), |
| 82 timeout_(TestTimeouts::action_max_timeout()), | 82 timeout_(TestTimeouts::action_max_timeout()), |
| 83 done_(false) {} | 83 done_(false) {} |
| 84 | 84 |
| 85 virtual void OnStateChanged() override { | 85 void OnStateChanged() override { |
| 86 if (ProfileSyncService::IDLE == pss_->backend_mode()) { | 86 if (ProfileSyncService::IDLE == pss_->backend_mode()) { |
| 87 done_ = true; | 87 done_ = true; |
| 88 run_loop_.Quit(); | 88 run_loop_.Quit(); |
| 89 } | 89 } |
| 90 } | 90 } |
| 91 | 91 |
| 92 bool Wait() { | 92 bool Wait() { |
| 93 pss_->AddObserver(this); | 93 pss_->AddObserver(this); |
| 94 if (ProfileSyncService::IDLE == pss_->backend_mode()) | 94 if (ProfileSyncService::IDLE == pss_->backend_mode()) |
| 95 return true; | 95 return true; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 114 class SyncRollbackChecker : public ProfileSyncServiceBase::Observer, | 114 class SyncRollbackChecker : public ProfileSyncServiceBase::Observer, |
| 115 public BrowsingDataRemover::Observer { | 115 public BrowsingDataRemover::Observer { |
| 116 public: | 116 public: |
| 117 explicit SyncRollbackChecker(ProfileSyncService* service) | 117 explicit SyncRollbackChecker(ProfileSyncService* service) |
| 118 : pss_(service), | 118 : pss_(service), |
| 119 timeout_(TestTimeouts::action_max_timeout()), | 119 timeout_(TestTimeouts::action_max_timeout()), |
| 120 rollback_started_(false), | 120 rollback_started_(false), |
| 121 clear_done_(false) {} | 121 clear_done_(false) {} |
| 122 | 122 |
| 123 // ProfileSyncServiceBase::Observer implementation. | 123 // ProfileSyncServiceBase::Observer implementation. |
| 124 virtual void OnStateChanged() override { | 124 void OnStateChanged() override { |
| 125 if (ProfileSyncService::ROLLBACK == pss_->backend_mode()) { | 125 if (ProfileSyncService::ROLLBACK == pss_->backend_mode()) { |
| 126 rollback_started_ = true; | 126 rollback_started_ = true; |
| 127 if (clear_done_) | 127 if (clear_done_) |
| 128 run_loop_.Quit(); | 128 run_loop_.Quit(); |
| 129 } | 129 } |
| 130 } | 130 } |
| 131 | 131 |
| 132 // BrowsingDataRemoverObserver::Observer implementation. | 132 // BrowsingDataRemoverObserver::Observer implementation. |
| 133 virtual void OnBrowsingDataRemoverDone() override { | 133 void OnBrowsingDataRemoverDone() override { |
| 134 clear_done_ = true; | 134 clear_done_ = true; |
| 135 if (rollback_started_) { | 135 if (rollback_started_) { |
| 136 run_loop_.Quit(); | 136 run_loop_.Quit(); |
| 137 } | 137 } |
| 138 } | 138 } |
| 139 | 139 |
| 140 bool Wait() { | 140 bool Wait() { |
| 141 pss_->AddObserver(this); | 141 pss_->AddObserver(this); |
| 142 pss_->SetBrowsingDataRemoverObserverForTesting(this); | 142 pss_->SetBrowsingDataRemoverObserverForTesting(this); |
| 143 base::MessageLoop::current()->PostDelayedTask( | 143 base::MessageLoop::current()->PostDelayedTask( |
| (...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 433 ASSERT_TRUE(rollback_checker.Wait()); | 433 ASSERT_TRUE(rollback_checker.Wait()); |
| 434 SyncBackendStoppedChecker shutdown_checker(GetSyncService(0)); | 434 SyncBackendStoppedChecker shutdown_checker(GetSyncService(0)); |
| 435 ASSERT_TRUE(shutdown_checker.Wait()); | 435 ASSERT_TRUE(shutdown_checker.Wait()); |
| 436 | 436 |
| 437 // Verify bookmarks are unchanged. | 437 // Verify bookmarks are unchanged. |
| 438 ASSERT_EQ(3, sub_folder->child_count()); | 438 ASSERT_EQ(3, sub_folder->child_count()); |
| 439 ASSERT_EQ(GURL(kUrl1), sub_folder->GetChild(0)->url()); | 439 ASSERT_EQ(GURL(kUrl1), sub_folder->GetChild(0)->url()); |
| 440 ASSERT_EQ(GURL(kUrl2), sub_folder->GetChild(1)->url()); | 440 ASSERT_EQ(GURL(kUrl2), sub_folder->GetChild(1)->url()); |
| 441 ASSERT_EQ(GURL(kUrl3), sub_folder->GetChild(2)->url()); | 441 ASSERT_EQ(GURL(kUrl3), sub_folder->GetChild(2)->url()); |
| 442 } | 442 } |
| OLD | NEW |