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

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

Issue 2727663004: Use TabLoader in TabRestoreService. (Closed)
Patch Set: Fix review notes: comments, namings etc. 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
« no previous file with comments | « no previous file | chrome/browser/sessions/tab_loader.cc » ('j') | 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 #ifndef CHROME_BROWSER_SESSIONS_TAB_LOADER_H_ 5 #ifndef CHROME_BROWSER_SESSIONS_TAB_LOADER_H_
6 #define CHROME_BROWSER_SESSIONS_TAB_LOADER_H_ 6 #define CHROME_BROWSER_SESSIONS_TAB_LOADER_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include <list> 10 #include <list>
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 56
57 // TabLoaderCallback: 57 // TabLoaderCallback:
58 void SetTabLoadingEnabled(bool enable_tab_loading) override; 58 void SetTabLoadingEnabled(bool enable_tab_loading) override;
59 59
60 // Called to start restoring tabs. 60 // Called to start restoring tabs.
61 static void RestoreTabs(const std::vector<RestoredTab>& tabs, 61 static void RestoreTabs(const std::vector<RestoredTab>& tabs,
62 const base::TimeTicks& restore_started); 62 const base::TimeTicks& restore_started);
63 63
64 private: 64 private:
65 FRIEND_TEST_ALL_PREFIXES(TabLoaderTest, OnMemoryStateChange); 65 FRIEND_TEST_ALL_PREFIXES(TabLoaderTest, OnMemoryStateChange);
66 FRIEND_TEST_ALL_PREFIXES(TabRestoreTest,
67 TabsFromRestoredWindowsAreLoadedGradually);
66 68
67 friend class base::RefCounted<TabLoader>; 69 friend class base::RefCounted<TabLoader>;
68 70
69 using TabsLoading = std::set<content::NavigationController*>; 71 using TabsLoading = std::set<content::NavigationController*>;
70 using TabsToLoad = std::list<content::NavigationController*>; 72 using TabsToLoad = std::list<content::NavigationController*>;
71 73
72 explicit TabLoader(base::TimeTicks restore_started); 74 explicit TabLoader(base::TimeTicks restore_started);
73 ~TabLoader() override; 75 ~TabLoader() override;
74 76
75 // This is invoked once by RestoreTabs to start loading. 77 // This is invoked once by RestoreTabs to start loading.
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 // React to memory pressure by stopping to load any more tabs. 118 // React to memory pressure by stopping to load any more tabs.
117 void OnMemoryPressure( 119 void OnMemoryPressure(
118 base::MemoryPressureListener::MemoryPressureLevel memory_pressure_level); 120 base::MemoryPressureListener::MemoryPressureLevel memory_pressure_level);
119 121
120 // base::MemoryCoordinatorClient implementation: 122 // base::MemoryCoordinatorClient implementation:
121 void OnMemoryStateChange(base::MemoryState state) override; 123 void OnMemoryStateChange(base::MemoryState state) override;
122 124
123 // Stops loading tabs to purge memory by stopping to load any more tabs. 125 // Stops loading tabs to purge memory by stopping to load any more tabs.
124 void StopLoadingTabs(); 126 void StopLoadingTabs();
125 127
128 // Limit the number of loaded tabs.
129 // Value of 0 restores default behavior. In test mode command line flags and
130 // free memory size are not taken into account.
131 static void SetMaxLoadedTabCountForTest(size_t value);
132
126 std::unique_ptr<TabLoaderDelegate> delegate_; 133 std::unique_ptr<TabLoaderDelegate> delegate_;
127 134
128 // Listens for system under memory pressure notifications and stops loading 135 // Listens for system under memory pressure notifications and stops loading
129 // of tabs when we start running out of memory. 136 // of tabs when we start running out of memory.
130 base::MemoryPressureListener memory_pressure_listener_; 137 base::MemoryPressureListener memory_pressure_listener_;
131 138
132 content::NotificationRegistrar registrar_; 139 content::NotificationRegistrar registrar_;
133 140
134 // The delay timer multiplier. See class description for details. 141 // The delay timer multiplier. See class description for details.
135 size_t force_load_delay_multiplier_; 142 size_t force_load_delay_multiplier_;
136 143
137 // True if the tab loading is enabled. 144 // True if the tab loading is enabled.
138 bool loading_enabled_; 145 bool loading_enabled_;
139 146
140 // The set of tabs we've initiated loading on. This does NOT include the 147 // The set of tabs we've initiated loading on. This does NOT include the
141 // selected tabs. 148 // selected tabs.
142 TabsLoading tabs_loading_; 149 TabsLoading tabs_loading_;
143 150
144 // The tabs we need to load. 151 // The tabs we need to load.
145 TabsToLoad tabs_to_load_; 152 TabsToLoad tabs_to_load_;
146 153
154 // The number of tabs started to load.
155 // (This value never decreases.)
156 size_t started_to_load_count_;
157
147 base::OneShotTimer force_load_timer_; 158 base::OneShotTimer force_load_timer_;
148 159
149 // The time the restore process started. 160 // The time the restore process started.
150 base::TimeTicks restore_started_; 161 base::TimeTicks restore_started_;
151 162
152 // For keeping TabLoader alive while it's loading even if no 163 // For keeping TabLoader alive while it's loading even if no
153 // SessionRestoreImpls reference it. 164 // SessionRestoreImpls reference it.
154 scoped_refptr<TabLoader> this_retainer_; 165 scoped_refptr<TabLoader> this_retainer_;
155 166
156 // The SessionRestoreStatsCollector associated with this TabLoader. This is 167 // The SessionRestoreStatsCollector associated with this TabLoader. This is
157 // explicitly referenced so that it can be notified of deferred tab loads due 168 // explicitly referenced so that it can be notified of deferred tab loads due
158 // to memory pressure. 169 // to memory pressure.
159 scoped_refptr<SessionRestoreStatsCollector> stats_collector_; 170 scoped_refptr<SessionRestoreStatsCollector> stats_collector_;
160 171
161 static TabLoader* shared_tab_loader_; 172 static TabLoader* shared_tab_loader_;
162 173
163 DISALLOW_COPY_AND_ASSIGN(TabLoader); 174 DISALLOW_COPY_AND_ASSIGN(TabLoader);
164 }; 175 };
165 176
166 #endif // CHROME_BROWSER_SESSIONS_TAB_LOADER_H_ 177 #endif // CHROME_BROWSER_SESSIONS_TAB_LOADER_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/sessions/tab_loader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698