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

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

Issue 1249693002: Improve the about/discards UI, allowing each tab to be individually closed. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 5 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
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_OOM_PRIORITY_MANAGER_H_ 5 #ifndef CHROME_BROWSER_MEMORY_OOM_PRIORITY_MANAGER_H_
6 #define CHROME_BROWSER_MEMORY_OOM_PRIORITY_MANAGER_H_ 6 #define CHROME_BROWSER_MEMORY_OOM_PRIORITY_MANAGER_H_
7 7
8 #include <utility> 8 #include <utility>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 49
50 // Number of discard events since Chrome started. 50 // Number of discard events since Chrome started.
51 int discard_count() const { return discard_count_; } 51 int discard_count() const { return discard_count_; }
52 52
53 // See member comment. 53 // See member comment.
54 bool recent_tab_discard() const { return recent_tab_discard_; } 54 bool recent_tab_discard() const { return recent_tab_discard_; }
55 55
56 void Start(); 56 void Start();
57 void Stop(); 57 void Stop();
58 58
59 // Returns list of tab titles sorted from most interesting (don't kill) 59 // Returns the list of the stats for all renderers.
Georges Khalil 2015/07/21 18:13:37 nit: Add "Must be called on UI thread." (not impli
proberge 2015/07/21 18:29:06 Done.
60 // to least interesting (OK to kill). 60 TabStatsList GetTabStats();
61 std::vector<base::string16> GetTabTitles();
62 61
63 // Discards a tab to free the memory occupied by its renderer. 62 // Discards a tab to free the memory occupied by its renderer.
64 // Tab still exists in the tab-strip; clicking on it will reload it. 63 // Tab still exists in the tab-strip; clicking on it will reload it.
65 // Returns true if it successfully found a tab and discarded it. 64 // Returns true if it successfully found a tab and discarded it.
66 bool DiscardTab(); 65 bool DiscardTab();
67 66
67 // Discards a tab with the given unique ID.
Georges Khalil 2015/07/21 18:13:37 nit: Fix wrap.
proberge 2015/07/21 18:29:06 Done.
68 // The tab still exists in the tab-strip; clicking on it will reload it.
69 // Returns true if it successfully found a tab and discarded it.
Georges Khalil 2015/07/21 18:13:37 Better comments, good! :)
proberge 2015/07/21 18:29:06 Acknowledged.
70 bool DiscardTabById(int64 target_web_contents_id);
71
68 // Log memory statistics for the running processes, then discards a tab. 72 // Log memory statistics for the running processes, then discards a tab.
69 // Tab discard happens sometime later, as collecting the statistics touches 73 // Tab discard happens sometime later, as collecting the statistics touches
70 // multiple threads and takes time. 74 // multiple threads and takes time.
71 void LogMemoryAndDiscardTab(); 75 void LogMemoryAndDiscardTab();
72 76
73 // Log memory statistics for the running processes, then call the callback. 77 // Log memory statistics for the running processes, then call the callback.
74 void LogMemory(const std::string& title, const base::Closure& callback); 78 void LogMemory(const std::string& title, const base::Closure& callback);
75 79
76 private: 80 private:
77 FRIEND_TEST_ALL_PREFIXES(OomPriorityManagerTest, Comparator); 81 FRIEND_TEST_ALL_PREFIXES(OomPriorityManagerTest, Comparator);
78 FRIEND_TEST_ALL_PREFIXES(OomPriorityManagerTest, IsInternalPage); 82 FRIEND_TEST_ALL_PREFIXES(OomPriorityManagerTest, IsInternalPage);
79 83
80 static void PurgeMemoryAndDiscardTab(); 84 static void PurgeMemoryAndDiscardTab();
81 85
82 // Returns true if the |url| represents an internal Chrome web UI page that 86 // Returns true if the |url| represents an internal Chrome web UI page that
83 // can be easily reloaded and hence makes a good choice to discard. 87 // can be easily reloaded and hence makes a good choice to discard.
84 static bool IsInternalPage(const GURL& url); 88 static bool IsInternalPage(const GURL& url);
85 89
86 // Discards a tab with the given unique ID. Returns true if discard occurred.
87 bool DiscardTabById(int64 target_web_contents_id);
88
89 // Records UMA histogram statistics for a tab discard. We record statistics 90 // Records UMA histogram statistics for a tab discard. We record statistics
90 // for user triggered discards via chrome://discards/ because that allows us 91 // for user triggered discards via chrome://discards/ because that allows us
91 // to manually test the system. 92 // to manually test the system.
92 void RecordDiscardStatistics(); 93 void RecordDiscardStatistics();
93 94
94 // Record whether we ran out of memory during a recent time interval. 95 // Record whether we ran out of memory during a recent time interval.
95 // This allows us to normalize low memory statistics versus usage. 96 // This allows us to normalize low memory statistics versus usage.
96 void RecordRecentTabDiscard(); 97 void RecordRecentTabDiscard();
97 98
98 // Purges data structures in the browser that can be easily recomputed. 99 // Purges data structures in the browser that can be easily recomputed.
99 void PurgeBrowserMemory(); 100 void PurgeBrowserMemory();
100 101
101 // Returns the number of tabs open in all browser instances. 102 // Returns the number of tabs open in all browser instances.
102 int GetTabCount() const; 103 int GetTabCount() const;
103 104
104 // Returns the list of the stats for all renderers.
105 TabStatsList GetTabStatsOnUIThread();
106
107 // Adds all the stats of the tabs in |browser_list| into |stats_list|. If 105 // Adds all the stats of the tabs in |browser_list| into |stats_list|. If
108 // |active_desktop| is true, we consider its first window as being active. 106 // |active_desktop| is true, we consider its first window as being active.
109 void AddTabStats(BrowserList* browser_list, 107 void AddTabStats(BrowserList* browser_list,
110 bool active_desktop, 108 bool active_desktop,
111 TabStatsList* stats_list); 109 TabStatsList* stats_list);
112 110
113 // Callback for when |update_timer_| fires. Takes care of executing the tasks 111 // Callback for when |update_timer_| fires. Takes care of executing the tasks
114 // that need to be run periodically (see comment in implementation). 112 // that need to be run periodically (see comment in implementation).
115 void UpdateTimerCallback(); 113 void UpdateTimerCallback();
116 114
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 #if defined(OS_CHROMEOS) 149 #if defined(OS_CHROMEOS)
152 scoped_ptr<OomPriorityManagerDelegate> delegate_; 150 scoped_ptr<OomPriorityManagerDelegate> delegate_;
153 #endif 151 #endif
154 152
155 DISALLOW_COPY_AND_ASSIGN(OomPriorityManager); 153 DISALLOW_COPY_AND_ASSIGN(OomPriorityManager);
156 }; 154 };
157 155
158 } // namespace memory 156 } // namespace memory
159 157
160 #endif // CHROME_BROWSER_MEMORY_OOM_PRIORITY_MANAGER_H_ 158 #endif // CHROME_BROWSER_MEMORY_OOM_PRIORITY_MANAGER_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/memory/oom_priority_manager.cc » ('j') | chrome/browser/ui/webui/about_ui.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698