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

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

Issue 2389683002: Modify PurgeAndSuspend to see WebContents (Closed)
Patch Set: Add unittest Created 4 years, 2 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/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 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 149
150 // Returns true if |first| is considered less desirable to be killed than 150 // Returns true if |first| is considered less desirable to be killed than
151 // |second|. 151 // |second|.
152 static bool CompareTabStats(const TabStats& first, const TabStats& second); 152 static bool CompareTabStats(const TabStats& first, const TabStats& second);
153 153
154 // Returns a unique ID for a WebContents. Do not cast back to a pointer, as 154 // Returns a unique ID for a WebContents. Do not cast back to a pointer, as
155 // the WebContents could be deleted if the user closed the tab. 155 // the WebContents could be deleted if the user closed the tab.
156 static int64_t IdFromWebContents(content::WebContents* web_contents); 156 static int64_t IdFromWebContents(content::WebContents* web_contents);
157 157
158 private: 158 private:
159 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, CannotSuspendTabWithMedia);
160 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, CanSuspendBasics);
159 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, AutoDiscardable); 161 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, AutoDiscardable);
160 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, CanOnlyDiscardOnce); 162 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, CanOnlyDiscardOnce);
161 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, ChildProcessNotifications); 163 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, ChildProcessNotifications);
162 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, Comparator); 164 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, Comparator);
163 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, DiscardedTabKeepsLastActiveTime); 165 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, DiscardedTabKeepsLastActiveTime);
164 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, DiscardWebContentsAt); 166 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, DiscardWebContentsAt);
165 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, InvalidOrEmptyURL); 167 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, InvalidOrEmptyURL);
166 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, IsInternalPage); 168 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, IsInternalPage);
167 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, OomPressureListener); 169 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, OomPressureListener);
168 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, ProtectPDFPages); 170 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, ProtectPDFPages);
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 // If |active_model| is true, consider its first tab as being active. 239 // If |active_model| is true, consider its first tab as being active.
238 void AddTabStats(const TabStripModel* model, 240 void AddTabStats(const TabStripModel* model,
239 bool is_app, 241 bool is_app,
240 bool active_model, 242 bool active_model,
241 TabStatsList* stats_list); 243 TabStatsList* stats_list);
242 244
243 // Callback for when |update_timer_| fires. Takes care of executing the tasks 245 // Callback for when |update_timer_| fires. Takes care of executing the tasks
244 // that need to be run periodically (see comment in implementation). 246 // that need to be run periodically (see comment in implementation).
245 void UpdateTimerCallback(); 247 void UpdateTimerCallback();
246 248
249 // Goes through a list of checks to see if a tab is allowed to be purged and
250 // suspended by purge+susend backgrounded tab mechanism.
251 bool CanPurgeAndSuspendBackgroundedTab(int64_t target_web_contents_id) const;
252
247 // Purges and suspends renderers in backgrounded tabs. 253 // Purges and suspends renderers in backgrounded tabs.
248 void PurgeAndSuspendBackgroundedTabs(); 254 void PurgeAndSuspendBackgroundedTabs();
249 255
250 // Does the actual discard by destroying the WebContents in |model| at |index| 256 // Does the actual discard by destroying the WebContents in |model| at |index|
251 // and replacing it by an empty one. Returns the new WebContents or NULL if 257 // and replacing it by an empty one. Returns the new WebContents or NULL if
252 // the operation fails (return value used only in testing). 258 // the operation fails (return value used only in testing).
253 content::WebContents* DiscardWebContentsAt(int index, TabStripModel* model); 259 content::WebContents* DiscardWebContentsAt(int index, TabStripModel* model);
254 260
255 // Called by the memory pressure listener when the memory pressure rises. 261 // Called by the memory pressure listener when the memory pressure rises.
256 void OnMemoryPressure( 262 void OnMemoryPressure(
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 385
380 // Weak pointer factory used for posting delayed tasks to task_runner_. 386 // Weak pointer factory used for posting delayed tasks to task_runner_.
381 base::WeakPtrFactory<TabManager> weak_ptr_factory_; 387 base::WeakPtrFactory<TabManager> weak_ptr_factory_;
382 388
383 DISALLOW_COPY_AND_ASSIGN(TabManager); 389 DISALLOW_COPY_AND_ASSIGN(TabManager);
384 }; 390 };
385 391
386 } // namespace memory 392 } // namespace memory
387 393
388 #endif // CHROME_BROWSER_MEMORY_TAB_MANAGER_H_ 394 #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