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

Side by Side Diff: chrome/browser/memory/tab_manager.h

Issue 2462513002: Add Resume logic of Purge+Suspend to TabManager. (Closed)
Patch Set: Created 4 years, 1 month 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/memory/tab_manager.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 (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 #ifndef CHROME_BROWSER_MEMORY_TAB_MANAGER_H_ 5 #ifndef CHROME_BROWSER_MEMORY_TAB_MANAGER_H_
6 #define CHROME_BROWSER_MEMORY_TAB_MANAGER_H_ 6 #define CHROME_BROWSER_MEMORY_TAB_MANAGER_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <memory> 10 #include <memory>
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 152
153 // Returns true if |first| is considered less desirable to be killed than 153 // Returns true if |first| is considered less desirable to be killed than
154 // |second|. 154 // |second|.
155 static bool CompareTabStats(const TabStats& first, const TabStats& second); 155 static bool CompareTabStats(const TabStats& first, const TabStats& second);
156 156
157 // Returns a unique ID for a WebContents. Do not cast back to a pointer, as 157 // Returns a unique ID for a WebContents. Do not cast back to a pointer, as
158 // the WebContents could be deleted if the user closed the tab. 158 // the WebContents could be deleted if the user closed the tab.
159 static int64_t IdFromWebContents(content::WebContents* web_contents); 159 static int64_t IdFromWebContents(content::WebContents* web_contents);
160 160
161 private: 161 private:
162 FRIEND_TEST_ALL_PREFIXES(TabManagerTest,
163 ActivateTabResetPurgeAndSuspendState);
164 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, NextPurgeAndSuspendState);
162 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, AutoDiscardable); 165 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, AutoDiscardable);
163 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, CanOnlyDiscardOnce); 166 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, CanOnlyDiscardOnce);
164 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, ChildProcessNotifications); 167 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, ChildProcessNotifications);
165 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, Comparator); 168 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, Comparator);
166 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, DiscardedTabKeepsLastActiveTime); 169 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, DiscardedTabKeepsLastActiveTime);
167 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, DiscardWebContentsAt); 170 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, DiscardWebContentsAt);
168 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, InvalidOrEmptyURL); 171 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, InvalidOrEmptyURL);
169 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, IsInternalPage); 172 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, IsInternalPage);
170 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, OomPressureListener); 173 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, OomPressureListener);
171 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, ProtectPDFPages); 174 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, ProtectPDFPages);
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 // purge-and-suspend modified time), and 266 // purge-and-suspend modified time), and
264 // - kSuspendedRendererLengthOfResumption time passes since the tab was 267 // - kSuspendedRendererLengthOfResumption time passes since the tab was
265 // resumed. 268 // resumed.
266 // SUSPENDED, RESUMED, RUNNING => RUNNING 269 // SUSPENDED, RESUMED, RUNNING => RUNNING
267 // - When ActiveTabChaged, the newly activated tab's state will be RUNNING. 270 // - When ActiveTabChaged, the newly activated tab's state will be RUNNING.
268 enum PurgeAndSuspendState { 271 enum PurgeAndSuspendState {
269 RUNNING, 272 RUNNING,
270 RESUMED, 273 RESUMED,
271 SUSPENDED, 274 SUSPENDED,
272 }; 275 };
276 // Returns WebContents whose contents id matches the given tab-contents-id.
277 content::WebContents* GetWebContentsByContentsId(int64_t tab_contents_id);
haraken 2016/10/28 06:25:48 GetWebContentsById ?
tasak 2016/10/28 06:53:43 Done.
278
279 // Determines whether to update purge-and-suspend state and returns the
280 // next state.
haraken 2016/10/28 06:25:48 Returns the next state of the purge and suspend.
tasak 2016/10/28 06:53:43 Done.
281 PurgeAndSuspendState NextPurgeAndSuspendState(
haraken 2016/10/28 06:25:48 GetNextStateOfPurgeAndSuspend ?
tasak 2016/10/28 06:53:43 Done.
282 content::WebContents* content,
283 const base::TimeTicks& current_time,
284 const base::TimeDelta& purge_and_suspend_threshold) const;
273 285
274 // Purges and suspends renderers in backgrounded tabs. 286 // Purges and suspends renderers in backgrounded tabs.
275 void PurgeAndSuspendBackgroundedTabs(); 287 void PurgeAndSuspendBackgroundedTabs();
276 288
277 // Does the actual discard by destroying the WebContents in |model| at |index| 289 // Does the actual discard by destroying the WebContents in |model| at |index|
278 // and replacing it by an empty one. Returns the new WebContents or NULL if 290 // and replacing it by an empty one. Returns the new WebContents or NULL if
279 // the operation fails (return value used only in testing). 291 // the operation fails (return value used only in testing).
280 content::WebContents* DiscardWebContentsAt(int index, TabStripModel* model); 292 content::WebContents* DiscardWebContentsAt(int index, TabStripModel* model);
281 293
282 // Called by the memory pressure listener when the memory pressure rises. 294 // Called by the memory pressure listener when the memory pressure rises.
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
406 418
407 // Weak pointer factory used for posting delayed tasks to task_runner_. 419 // Weak pointer factory used for posting delayed tasks to task_runner_.
408 base::WeakPtrFactory<TabManager> weak_ptr_factory_; 420 base::WeakPtrFactory<TabManager> weak_ptr_factory_;
409 421
410 DISALLOW_COPY_AND_ASSIGN(TabManager); 422 DISALLOW_COPY_AND_ASSIGN(TabManager);
411 }; 423 };
412 424
413 } // namespace memory 425 } // namespace memory
414 426
415 #endif // CHROME_BROWSER_MEMORY_TAB_MANAGER_H_ 427 #endif // CHROME_BROWSER_MEMORY_TAB_MANAGER_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/memory/tab_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698