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

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

Issue 2250183002: New Public IdFromWebContents method on TabManager. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: implemented suggestion Created 4 years, 4 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 | « chrome/browser/extensions/api/tabs/tabs_test.cc ('k') | 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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 // Discards a tab with the given unique ID. The tab still exists in the 105 // Discards a tab with the given unique ID. The tab still exists in the
106 // tab-strip; clicking on it will reload it. Returns null if the tab cannot 106 // tab-strip; clicking on it will reload it. Returns null if the tab cannot
107 // be found or cannot be discarded. Otherwise returns the new web_contents 107 // be found or cannot be discarded. Otherwise returns the new web_contents
108 // of the discarded tab. 108 // of the discarded tab.
109 content::WebContents* DiscardTabById(int64_t target_web_contents_id); 109 content::WebContents* DiscardTabById(int64_t target_web_contents_id);
110 110
111 // Method used by the extensions API to discard tabs. If |contents| is null, 111 // Method used by the extensions API to discard tabs. If |contents| is null,
112 // discards the least important tab using DiscardTab(). Otherwise discards 112 // discards the least important tab using DiscardTab(). Otherwise discards
113 // the given contents. Returns the new web_contents or null if no tab 113 // the given contents. Returns the new web_contents or null if no tab
114 // was discarded. 114 // was discarded.
115 content::WebContents* DiscardTabByExtension(content::WebContents* contents); 115 content::WebContents* DiscardTabByExtension(content::WebContents* contents);
Devlin 2016/08/17 00:02:44 drive-by: It might make sense to rename this metho
116 116
117 // Log memory statistics for the running processes, then discards a tab. 117 // Log memory statistics for the running processes, then discards a tab.
118 // Tab discard happens sometime later, as collecting the statistics touches 118 // Tab discard happens sometime later, as collecting the statistics touches
119 // multiple threads and takes time. 119 // multiple threads and takes time.
120 void LogMemoryAndDiscardTab(); 120 void LogMemoryAndDiscardTab();
121 121
122 // Log memory statistics for the running processes, then call the callback. 122 // Log memory statistics for the running processes, then call the callback.
123 void LogMemory(const std::string& title, const base::Closure& callback); 123 void LogMemory(const std::string& title, const base::Closure& callback);
124 124
125 // Used to set the test TickClock, which then gets used by NowTicks(). See 125 // Used to set the test TickClock, which then gets used by NowTicks(). See
(...skipping 18 matching lines...) Expand all
144 // methods (about:discards for instance). 144 // methods (about:discards for instance).
145 bool IsTabAutoDiscardable(content::WebContents* contents) const; 145 bool IsTabAutoDiscardable(content::WebContents* contents) const;
146 146
147 // Sets/clears the auto-discardable state of the tab. 147 // Sets/clears the auto-discardable state of the tab.
148 void SetTabAutoDiscardableState(content::WebContents* contents, bool state); 148 void SetTabAutoDiscardableState(content::WebContents* contents, bool state);
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
155 // the WebContents could be deleted if the user closed the tab.
156 static int64_t IdFromWebContents(content::WebContents* web_contents);
157
154 private: 158 private:
155 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, AutoDiscardable); 159 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, AutoDiscardable);
156 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, CanOnlyDiscardOnce); 160 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, CanOnlyDiscardOnce);
157 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, ChildProcessNotifications); 161 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, ChildProcessNotifications);
158 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, Comparator); 162 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, Comparator);
159 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, DiscardedTabKeepsLastActiveTime); 163 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, DiscardedTabKeepsLastActiveTime);
160 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, DiscardWebContentsAt); 164 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, DiscardWebContentsAt);
161 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, InvalidOrEmptyURL); 165 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, InvalidOrEmptyURL);
162 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, IsInternalPage); 166 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, IsInternalPage);
163 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, OomPressureListener); 167 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, OomPressureListener);
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
374 378
375 // Weak pointer factory used for posting delayed tasks to task_runner_. 379 // Weak pointer factory used for posting delayed tasks to task_runner_.
376 base::WeakPtrFactory<TabManager> weak_ptr_factory_; 380 base::WeakPtrFactory<TabManager> weak_ptr_factory_;
377 381
378 DISALLOW_COPY_AND_ASSIGN(TabManager); 382 DISALLOW_COPY_AND_ASSIGN(TabManager);
379 }; 383 };
380 384
381 } // namespace memory 385 } // namespace memory
382 386
383 #endif // CHROME_BROWSER_MEMORY_TAB_MANAGER_H_ 387 #endif // CHROME_BROWSER_MEMORY_TAB_MANAGER_H_
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/tabs/tabs_test.cc ('k') | chrome/browser/memory/tab_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698