Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 <vector> | 5 #include <vector> |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
| 9 #include "base/memory/memory_pressure_listener.h" | 9 #include "base/memory/memory_pressure_listener.h" |
| 10 #include "base/process/launch.h" | 10 #include "base/process/launch.h" |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 149 ui::PAGE_TRANSITION_LINK); | 149 ui::PAGE_TRANSITION_LINK); |
| 150 chrome::Navigate(¶ms); | 150 chrome::Navigate(¶ms); |
| 151 } | 151 } |
| 152 Browser* new_browser = window_observer.WaitForSingleNewBrowser(); | 152 Browser* new_browser = window_observer.WaitForSingleNewBrowser(); |
| 153 // Stop loading anything more if we are running out of space. | 153 // Stop loading anything more if we are running out of space. |
| 154 if (!no_memory_pressure) { | 154 if (!no_memory_pressure) { |
| 155 base::MemoryPressureListener::NotifyMemoryPressure( | 155 base::MemoryPressureListener::NotifyMemoryPressure( |
| 156 base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_CRITICAL); | 156 base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_CRITICAL); |
| 157 } | 157 } |
| 158 restore_observer.Wait(); | 158 restore_observer.Wait(); |
| 159 | |
| 160 if (no_memory_pressure) | |
|
Simon Que
2015/03/19 18:56:48
Can you explain what you're doing here? I'm not fa
sky
2015/03/19 19:15:32
This is necessitated by the change in behavior. Th
| |
| 161 WaitForTabsToLoad(new_browser); | |
| 162 | |
| 159 g_browser_process->ReleaseModule(); | 163 g_browser_process->ReleaseModule(); |
| 160 | 164 |
| 161 return new_browser; | 165 return new_browser; |
| 162 } | 166 } |
| 163 | 167 |
| 164 void GoBack(Browser* browser) { | 168 void GoBack(Browser* browser) { |
| 165 content::TestNavigationObserver observer( | 169 content::TestNavigationObserver observer( |
| 166 browser->tab_strip_model()->GetActiveWebContents()); | 170 browser->tab_strip_model()->GetActiveWebContents()); |
| 167 chrome::GoBack(browser, CURRENT_TAB); | 171 chrome::GoBack(browser, CURRENT_TAB); |
| 168 observer.Wait(); | 172 observer.Wait(); |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 185 content::RenderProcessHost::AllHostsIterator(); | 189 content::RenderProcessHost::AllHostsIterator(); |
| 186 int count = 0; | 190 int count = 0; |
| 187 while (!hosts.IsAtEnd()) { | 191 while (!hosts.IsAtEnd()) { |
| 188 if (hosts.GetCurrentValue()->HasConnection()) | 192 if (hosts.GetCurrentValue()->HasConnection()) |
| 189 count++; | 193 count++; |
| 190 hosts.Advance(); | 194 hosts.Advance(); |
| 191 } | 195 } |
| 192 return count; | 196 return count; |
| 193 } | 197 } |
| 194 | 198 |
| 199 void WaitForTabsToLoad(Browser* browser) { | |
| 200 for (int i = 0; i < browser->tab_strip_model()->count(); ++i) { | |
| 201 content::WebContents* contents = | |
| 202 browser->tab_strip_model()->GetWebContentsAt(i); | |
| 203 contents->GetController().LoadIfNecessary(); | |
| 204 content::WaitForLoadStop(contents); | |
| 205 } | |
| 206 } | |
| 207 | |
| 195 GURL url1_; | 208 GURL url1_; |
| 196 GURL url2_; | 209 GURL url2_; |
| 197 GURL url3_; | 210 GURL url3_; |
| 198 | 211 |
| 199 const BrowserList* active_browser_list_; | 212 const BrowserList* active_browser_list_; |
| 200 }; | 213 }; |
| 201 | 214 |
| 202 // Verifies that restored tabs have a root window. This is important | 215 // Verifies that restored tabs have a root window. This is important |
| 203 // otherwise the wrong information is communicated to the renderer. | 216 // otherwise the wrong information is communicated to the renderer. |
| 204 // (http://crbug.com/342672). | 217 // (http://crbug.com/342672). |
| (...skipping 1055 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1260 content::NavigationController* controller = | 1273 content::NavigationController* controller = |
| 1261 &browser()->tab_strip_model()->GetActiveWebContents()->GetController(); | 1274 &browser()->tab_strip_model()->GetActiveWebContents()->GetController(); |
| 1262 EXPECT_TRUE( | 1275 EXPECT_TRUE( |
| 1263 controller->GetDefaultSessionStorageNamespace()->should_persist()); | 1276 controller->GetDefaultSessionStorageNamespace()->should_persist()); |
| 1264 | 1277 |
| 1265 // Quit and restore. Check that no extra tabs were created. | 1278 // Quit and restore. Check that no extra tabs were created. |
| 1266 Browser* new_browser = QuitBrowserAndRestore(browser(), 1); | 1279 Browser* new_browser = QuitBrowserAndRestore(browser(), 1); |
| 1267 ASSERT_EQ(1u, active_browser_list_->size()); | 1280 ASSERT_EQ(1u, active_browser_list_->size()); |
| 1268 EXPECT_EQ(1, new_browser->tab_strip_model()->count()); | 1281 EXPECT_EQ(1, new_browser->tab_strip_model()->count()); |
| 1269 } | 1282 } |
| OLD | NEW |