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

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

Issue 2470073002: Revert of 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);
165 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, AutoDiscardable); 162 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, AutoDiscardable);
166 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, CanOnlyDiscardOnce); 163 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, CanOnlyDiscardOnce);
167 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, ChildProcessNotifications); 164 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, ChildProcessNotifications);
168 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, Comparator); 165 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, Comparator);
169 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, DiscardedTabKeepsLastActiveTime); 166 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, DiscardedTabKeepsLastActiveTime);
170 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, DiscardWebContentsAt); 167 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, DiscardWebContentsAt);
171 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, InvalidOrEmptyURL); 168 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, InvalidOrEmptyURL);
172 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, IsInternalPage); 169 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, IsInternalPage);
173 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, OomPressureListener); 170 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, OomPressureListener);
174 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, ProtectPDFPages); 171 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, ProtectPDFPages);
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 // purge-and-suspend modified time), and 263 // purge-and-suspend modified time), and
267 // - kSuspendedRendererLengthOfResumption time passes since the tab was 264 // - kSuspendedRendererLengthOfResumption time passes since the tab was
268 // resumed. 265 // resumed.
269 // SUSPENDED, RESUMED, RUNNING => RUNNING 266 // SUSPENDED, RESUMED, RUNNING => RUNNING
270 // - When ActiveTabChaged, the newly activated tab's state will be RUNNING. 267 // - When ActiveTabChaged, the newly activated tab's state will be RUNNING.
271 enum PurgeAndSuspendState { 268 enum PurgeAndSuspendState {
272 RUNNING, 269 RUNNING,
273 RESUMED, 270 RESUMED,
274 SUSPENDED, 271 SUSPENDED,
275 }; 272 };
276 // Returns WebContents whose contents id matches the given tab_contents_id.
277 content::WebContents* GetWebContentsById(int64_t tab_contents_id);
278
279 // Returns the next state of the purge and suspend.
280 PurgeAndSuspendState GetNextPurgeAndSuspendState(
281 content::WebContents* content,
282 base::TimeTicks current_time,
283 const base::TimeDelta& time_to_first_suspension) const;
284 273
285 // Purges and suspends renderers in backgrounded tabs. 274 // Purges and suspends renderers in backgrounded tabs.
286 void PurgeAndSuspendBackgroundedTabs(); 275 void PurgeAndSuspendBackgroundedTabs();
287 276
288 // Does the actual discard by destroying the WebContents in |model| at |index| 277 // Does the actual discard by destroying the WebContents in |model| at |index|
289 // and replacing it by an empty one. Returns the new WebContents or NULL if 278 // and replacing it by an empty one. Returns the new WebContents or NULL if
290 // the operation fails (return value used only in testing). 279 // the operation fails (return value used only in testing).
291 content::WebContents* DiscardWebContentsAt(int index, TabStripModel* model); 280 content::WebContents* DiscardWebContentsAt(int index, TabStripModel* model);
292 281
293 // Called by the memory pressure listener when the memory pressure rises. 282 // Called by the memory pressure listener when the memory pressure rises.
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
417 406
418 // Weak pointer factory used for posting delayed tasks to task_runner_. 407 // Weak pointer factory used for posting delayed tasks to task_runner_.
419 base::WeakPtrFactory<TabManager> weak_ptr_factory_; 408 base::WeakPtrFactory<TabManager> weak_ptr_factory_;
420 409
421 DISALLOW_COPY_AND_ASSIGN(TabManager); 410 DISALLOW_COPY_AND_ASSIGN(TabManager);
422 }; 411 };
423 412
424 } // namespace memory 413 } // namespace memory
425 414
426 #endif // CHROME_BROWSER_MEMORY_TAB_MANAGER_H_ 415 #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