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

Side by Side Diff: chrome/browser/sessions/tab_loader.cc

Issue 1134783002: Place SessionRestore/MemoryPressure interactions behind a field trial on Mac/Win platforms. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix wrong include. Created 5 years, 7 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/sessions/tab_loader.h" 5 #include "chrome/browser/sessions/tab_loader.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 9
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
11 #include "base/strings/stringprintf.h" 11 #include "base/strings/stringprintf.h"
12 #include "chrome/browser/ui/browser.h" 12 #include "chrome/browser/ui/browser.h"
13 #include "chrome/browser/ui/browser_finder.h" 13 #include "chrome/browser/ui/browser_finder.h"
14 #include "chrome/browser/ui/tabs/tab_strip_model.h" 14 #include "chrome/browser/ui/tabs/tab_strip_model.h"
15 #include "components/favicon/content/content_favicon_driver.h" 15 #include "components/favicon/content/content_favicon_driver.h"
16 #include "components/variations/variations_associated_data.h"
16 #include "content/public/browser/navigation_controller.h" 17 #include "content/public/browser/navigation_controller.h"
17 #include "content/public/browser/notification_service.h" 18 #include "content/public/browser/notification_service.h"
18 #include "content/public/browser/notification_types.h" 19 #include "content/public/browser/notification_types.h"
19 #include "content/public/browser/render_widget_host.h" 20 #include "content/public/browser/render_widget_host.h"
20 #include "content/public/browser/render_widget_host_view.h" 21 #include "content/public/browser/render_widget_host_view.h"
21 #include "content/public/browser/web_contents.h" 22 #include "content/public/browser/web_contents.h"
22 23
23 using content::NavigationController; 24 using content::NavigationController;
24 using content::RenderWidgetHost; 25 using content::RenderWidgetHost;
25 using content::WebContents; 26 using content::WebContents;
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 } 189 }
189 190
190 void TabLoader::HandleTabClosedOrLoaded(NavigationController* controller) { 191 void TabLoader::HandleTabClosedOrLoaded(NavigationController* controller) {
191 RemoveTab(controller); 192 RemoveTab(controller);
192 if (delegate_ && loading_enabled_) 193 if (delegate_ && loading_enabled_)
193 LoadNextTab(); 194 LoadNextTab();
194 } 195 }
195 196
196 void TabLoader::OnMemoryPressure( 197 void TabLoader::OnMemoryPressure(
197 base::MemoryPressureListener::MemoryPressureLevel memory_pressure_level) { 198 base::MemoryPressureListener::MemoryPressureLevel memory_pressure_level) {
199 // On Windows and Mac this mechanism is only experimentally enabled.
200 #if defined(OS_WIN) || (defined(OS_MACOSX) && !defined(OS_IOS))
201 // If memory pressure integration isn't explicitly enabled then ignore these
202 // calls.
203 std::string react_to_memory_pressure = variations::GetVariationParamValue(
204 "IntelligentSessionRestore", "ReactToMemoryPressure");
205 if (react_to_memory_pressure != "true")
206 return;
207 #endif
208
198 // When receiving a resource pressure level warning, we stop pre-loading more 209 // When receiving a resource pressure level warning, we stop pre-loading more
199 // tabs since we are running in danger of loading more tabs by throwing out 210 // tabs since we are running in danger of loading more tabs by throwing out
200 // old ones. 211 // old ones.
201 if (tabs_to_load_.empty()) 212 if (tabs_to_load_.empty())
202 return; 213 return;
203 // Stop the timer and suppress any tab loads while we clean the list. 214 // Stop the timer and suppress any tab loads while we clean the list.
204 SetTabLoadingEnabled(false); 215 SetTabLoadingEnabled(false);
205 while (!tabs_to_load_.empty()) { 216 while (!tabs_to_load_.empty()) {
206 NavigationController* controller = tabs_to_load_.front(); 217 NavigationController* controller = tabs_to_load_.front();
207 tabs_to_load_.pop_front(); 218 tabs_to_load_.pop_front();
208 RemoveTab(controller); 219 RemoveTab(controller);
209 } 220 }
210 // By calling |LoadNextTab| explicitly, we make sure that the 221 // By calling |LoadNextTab| explicitly, we make sure that the
211 // |NOTIFICATION_SESSION_RESTORE_DONE| event gets sent. 222 // |NOTIFICATION_SESSION_RESTORE_DONE| event gets sent.
212 LoadNextTab(); 223 LoadNextTab();
213 } 224 }
214 225
215 // static 226 // static
216 TabLoader* TabLoader::shared_tab_loader_ = nullptr; 227 TabLoader* TabLoader::shared_tab_loader_ = nullptr;
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698