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

Unified Diff: chrome/browser/sync/test/integration/sessions_helper.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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/sync/test/integration/sessions_helper.cc
diff --git a/chrome/browser/sync/test/integration/sessions_helper.cc b/chrome/browser/sync/test/integration/sessions_helper.cc
index 84a843a6cb158548faada77eba53021283a0ce51..81128bdb3f89babbbd0ad542ce5fd8e0163b6aa1 100644
--- a/chrome/browser/sync/test/integration/sessions_helper.cc
+++ b/chrome/browser/sync/test/integration/sessions_helper.cc
@@ -115,6 +115,13 @@ bool OpenMultipleTabs(int index, const std::vector<GURL>& urls) {
return WaitForTabsToLoad(index, urls);
}
+bool CloseTabAtIndex(int index, int tab_index, const GURL& url) {
+ auto* tab_strip = test()->GetBrowser(index)->tab_strip_model();
+ tab_strip->CloseWebContentsAt(tab_index, TabStripModel::CLOSE_NONE);
+
+ return WaitForTabsToClose(index, {url});
+}
+
void MoveTab(int from_index, int to_index, int tab_index) {
content::WebContents* detached_contents =
test()
@@ -181,23 +188,25 @@ class TabEventHandler : public sync_sessions::LocalSessionEventHandler {
base::Bind(&TabEventHandler::QuitLoop, weak_factory_.GetWeakPtr()));
}
+ void SetAllBrowsersClosing(bool /*browsers_closing*/) override {}
+
private:
void QuitLoop() { base::MessageLoop::current()->QuitWhenIdle(); }
base::WeakPtrFactory<TabEventHandler> weak_factory_;
};
-} // namespace
-
-bool WaitForTabsToLoad(int index, const std::vector<GURL>& urls) {
+bool WaitForTabsToLoadOrClose(int index,
+ const std::vector<GURL>& urls,
+ bool wait_load) {
DVLOG(1) << "Waiting for session to propagate to associator.";
base::TimeTicks start_time = base::TimeTicks::Now();
base::TimeTicks end_time = start_time + TestTimeouts::action_max_timeout();
bool found;
- for (std::vector<GURL>::const_iterator it = urls.begin();
- it != urls.end(); ++it) {
- found = false;
- while (!found) {
+ for (std::vector<GURL>::const_iterator it = urls.begin(); it != urls.end();
+ ++it) {
+ found = !wait_load;
+ while (found != wait_load) {
found = ModelAssociatorHasTabWithUrl(index, *it);
if (base::TimeTicks::Now() >= end_time) {
LOG(ERROR) << "Failed to find all tabs after "
@@ -205,7 +214,7 @@ bool WaitForTabsToLoad(int index, const std::vector<GURL>& urls) {
<< " seconds.";
return false;
}
- if (!found) {
+ if (found != wait_load) {
TabEventHandler handler;
sync_sessions::NotificationServiceSessionsRouter router(
test()->GetProfile(index),
@@ -222,6 +231,16 @@ bool WaitForTabsToLoad(int index, const std::vector<GURL>& urls) {
return true;
}
+} // namespace
+
+bool WaitForTabsToLoad(int index, const std::vector<GURL>& urls) {
+ return WaitForTabsToLoadOrClose(index, urls, true);
+}
+
+bool WaitForTabsToClose(int index, const std::vector<GURL>& urls) {
+ return WaitForTabsToLoadOrClose(index, urls, false);
+}
+
bool GetLocalWindows(int index, ScopedWindowMap* local_windows) {
// The local session provided by GetLocalSession is owned, and has lifetime
// controlled, by the model associator, so we must make our own copy.

Powered by Google App Engine
This is Rietveld 408576698