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

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: Resolve comments on #6 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
« no previous file with comments | « no previous file | chrome/browser/memory/oom_priority_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_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. Must be called on the UI
60 // to least interesting (OK to kill). 60 // thread.
61 std::vector<base::string16> GetTabTitles(); 61 TabStatsList GetTabStats();
62 62
63 // Discards a tab to free the memory occupied by its renderer. 63 // Discards a tab to free the memory occupied by its renderer. The tab still
64 // Tab still exists in the tab-strip; clicking on it will reload it. 64 // exists in the tab-strip; clicking on it will reload it. Returns true if it
65 // Returns true if it successfully found a tab and discarded it. 65 // successfully found a tab and discarded it.
66 bool DiscardTab(); 66 bool DiscardTab();
67 67
68 // Discards a tab with the given unique ID. The tab still exists in the
69 // tab-strip; clicking on it will reload it. Returns true if it successfully
70 // found a tab and discarded it.
71 bool DiscardTabById(int64 target_web_contents_id);
72
68 // Log memory statistics for the running processes, then discards a tab. 73 // Log memory statistics for the running processes, then discards a tab.
69 // Tab discard happens sometime later, as collecting the statistics touches 74 // Tab discard happens sometime later, as collecting the statistics touches
70 // multiple threads and takes time. 75 // multiple threads and takes time.
71 void LogMemoryAndDiscardTab(); 76 void LogMemoryAndDiscardTab();
72 77
73 // Log memory statistics for the running processes, then call the callback. 78 // Log memory statistics for the running processes, then call the callback.
74 void LogMemory(const std::string& title, const base::Closure& callback); 79 void LogMemory(const std::string& title, const base::Closure& callback);
75 80
76 private: 81 private:
77 FRIEND_TEST_ALL_PREFIXES(OomPriorityManagerTest, Comparator); 82 FRIEND_TEST_ALL_PREFIXES(OomPriorityManagerTest, Comparator);
78 FRIEND_TEST_ALL_PREFIXES(OomPriorityManagerTest, IsInternalPage); 83 FRIEND_TEST_ALL_PREFIXES(OomPriorityManagerTest, IsInternalPage);
79 84
80 static void PurgeMemoryAndDiscardTab(); 85 static void PurgeMemoryAndDiscardTab();
81 86
82 // Returns true if the |url| represents an internal Chrome web UI page that 87 // 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. 88 // can be easily reloaded and hence makes a good choice to discard.
84 static bool IsInternalPage(const GURL& url); 89 static bool IsInternalPage(const GURL& url);
85 90
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 91 // Records UMA histogram statistics for a tab discard. We record statistics
90 // for user triggered discards via chrome://discards/ because that allows us 92 // for user triggered discards via chrome://discards/ because that allows us
91 // to manually test the system. 93 // to manually test the system.
92 void RecordDiscardStatistics(); 94 void RecordDiscardStatistics();
93 95
94 // Record whether we ran out of memory during a recent time interval. 96 // Record whether we ran out of memory during a recent time interval.
95 // This allows us to normalize low memory statistics versus usage. 97 // This allows us to normalize low memory statistics versus usage.
96 void RecordRecentTabDiscard(); 98 void RecordRecentTabDiscard();
97 99
98 // Purges data structures in the browser that can be easily recomputed. 100 // Purges data structures in the browser that can be easily recomputed.
99 void PurgeBrowserMemory(); 101 void PurgeBrowserMemory();
100 102
101 // Returns the number of tabs open in all browser instances. 103 // Returns the number of tabs open in all browser instances.
102 int GetTabCount() const; 104 int GetTabCount() const;
103 105
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 106 // 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. 107 // |active_desktop| is true, we consider its first window as being active.
109 void AddTabStats(BrowserList* browser_list, 108 void AddTabStats(BrowserList* browser_list,
110 bool active_desktop, 109 bool active_desktop,
111 TabStatsList* stats_list); 110 TabStatsList* stats_list);
112 111
113 // Callback for when |update_timer_| fires. Takes care of executing the tasks 112 // Callback for when |update_timer_| fires. Takes care of executing the tasks
114 // that need to be run periodically (see comment in implementation). 113 // that need to be run periodically (see comment in implementation).
115 void UpdateTimerCallback(); 114 void UpdateTimerCallback();
116 115
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 #if defined(OS_CHROMEOS) 150 #if defined(OS_CHROMEOS)
152 scoped_ptr<OomPriorityManagerDelegate> delegate_; 151 scoped_ptr<OomPriorityManagerDelegate> delegate_;
153 #endif 152 #endif
154 153
155 DISALLOW_COPY_AND_ASSIGN(OomPriorityManager); 154 DISALLOW_COPY_AND_ASSIGN(OomPriorityManager);
156 }; 155 };
157 156
158 } // namespace memory 157 } // namespace memory
159 158
160 #endif // CHROME_BROWSER_MEMORY_OOM_PRIORITY_MANAGER_H_ 159 #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') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698