Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1380)

Side by Side Diff: chrome/browser/sync/test/integration/sync_test.cc

Issue 2750163003: Prevent tabs sync during browser shutdown.
Patch Set: Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/test/integration/sync_test.h" 5 #include "chrome/browser/sync/test/integration/sync_test.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <limits> 10 #include <limits>
(...skipping 680 matching lines...) Expand 10 before | Expand all | Expand 10 after
691 } 691 }
692 692
693 DVLOG(1) << "Done setting up first client for clear."; 693 DVLOG(1) << "Done setting up first client for clear.";
694 if (!ClearServerData(GetClient(index++))) { 694 if (!ClearServerData(GetClient(index++))) {
695 LOG(FATAL) << "ClearServerData failed."; 695 LOG(FATAL) << "ClearServerData failed.";
696 return false; 696 return false;
697 } 697 }
698 return true; 698 return true;
699 } 699 }
700 700
701 void SyncTest::CloseBrowserWindowAtIndex(size_t index) {
702 size_t init_browser_count = chrome::GetTotalBrowserCount();
703 CloseBrowserSynchronously(browsers_[index]);
704 closed_browsers_indicies_.insert(index);
705 CHECK_EQ(chrome::GetTotalBrowserCount(), init_browser_count - 1);
706 }
707
701 void SyncTest::TearDownOnMainThread() { 708 void SyncTest::TearDownOnMainThread() {
702 for (size_t i = 0; i < clients_.size(); ++i) { 709 for (size_t i = 0; i < 1; ++i) {
703 clients_[i]->service()->RequestStop(ProfileSyncService::CLEAR_DATA); 710 clients_[i]->service()->RequestStop(ProfileSyncService::CLEAR_DATA);
704 } 711 }
705 712
706 // Closing all browsers created by this test. The calls here block until 713 // Closing all browsers created by this test. The calls here block until
707 // they are closed. Other browsers created outside SyncTest setup should be 714 // they are closed. Other browsers created outside SyncTest setup should be
708 // closed by the creator of that browser. 715 // closed by the creator of that browser.
709 size_t init_browser_count = chrome::GetTotalBrowserCount(); 716 size_t init_browser_count = chrome::GetTotalBrowserCount();
710 for (size_t i = 0; i < browsers_.size(); ++i) { 717 for (size_t i = 0; i < browsers_.size(); ++i) {
711 CloseBrowserSynchronously(browsers_[i]); 718 if (closed_browsers_indicies_.count(i) == 0)
719 CloseBrowserSynchronously(browsers_[i]);
712 } 720 }
713 CHECK_EQ(chrome::GetTotalBrowserCount(), 721 CHECK_EQ(
714 init_browser_count - browsers_.size()); 722 chrome::GetTotalBrowserCount(),
723 init_browser_count - browsers_.size() + closed_browsers_indicies_.size());
715 724
716 if (fake_server_.get()) { 725 if (fake_server_.get()) {
717 std::vector<fake_server::FakeServerInvalidationService*>::const_iterator it; 726 std::vector<fake_server::FakeServerInvalidationService*>::const_iterator it;
718 for (it = fake_server_invalidation_services_.begin(); 727 for (it = fake_server_invalidation_services_.begin();
719 it != fake_server_invalidation_services_.end(); ++it) { 728 it != fake_server_invalidation_services_.end(); ++it) {
720 fake_server_->RemoveObserver(*it); 729 fake_server_->RemoveObserver(*it);
721 } 730 }
722 } 731 }
723 732
724 invalidation_forwarders_.clear(); 733 invalidation_forwarders_.clear();
(...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after
1181 bool SyncTest::ClearServerData(ProfileSyncServiceHarness* harness) { 1190 bool SyncTest::ClearServerData(ProfileSyncServiceHarness* harness) {
1182 // At this point our birthday is good. 1191 // At this point our birthday is good.
1183 base::RunLoop run_loop; 1192 base::RunLoop run_loop;
1184 harness->service()->ClearServerDataForTest(run_loop.QuitClosure()); 1193 harness->service()->ClearServerDataForTest(run_loop.QuitClosure());
1185 run_loop.Run(); 1194 run_loop.Run();
1186 1195
1187 // Our birthday is invalidated on the server here so restart sync to get 1196 // Our birthday is invalidated on the server here so restart sync to get
1188 // the new birthday from the server. 1197 // the new birthday from the server.
1189 return harness->RestartSyncService(); 1198 return harness->RestartSyncService();
1190 } 1199 }
1200
1201 void SyncTest::TearDownWithSpecificBrowserClose(int index) {
1202 clients_[index]->service()->RequestStop(ProfileSyncService::CLEAR_DATA);
1203 CloseBrowserSynchronously(browsers_[index]);
1204
1205 if (fake_server_.get()) {
1206 std::vector<fake_server::FakeServerInvalidationService*>::const_iterator it;
1207 for (it = fake_server_invalidation_services_.begin();
1208 it != fake_server_invalidation_services_.end(); ++it) {
1209 fake_server_->RemoveObserver(*it);
1210 }
1211 }
1212
1213 invalidation_forwarders_.clear();
1214 sync_refreshers_.clear();
1215 fake_server_invalidation_services_.clear();
1216 clients_.clear();
1217 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698