OLD | NEW |
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> |
| 9 |
8 #include <utility> | 10 #include <utility> |
9 #include <vector> | 11 #include <vector> |
10 | 12 |
11 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
12 #include "base/gtest_prod_util.h" | 14 #include "base/gtest_prod_util.h" |
| 15 #include "base/macros.h" |
13 #include "base/memory/memory_pressure_listener.h" | 16 #include "base/memory/memory_pressure_listener.h" |
14 #include "base/memory/scoped_ptr.h" | 17 #include "base/memory/scoped_ptr.h" |
15 #include "base/strings/string16.h" | 18 #include "base/strings/string16.h" |
16 #include "base/timer/timer.h" | 19 #include "base/timer/timer.h" |
| 20 #include "build/build_config.h" |
17 #include "chrome/browser/memory/tab_stats.h" | 21 #include "chrome/browser/memory/tab_stats.h" |
18 #include "chrome/browser/ui/browser_tab_strip_tracker.h" | 22 #include "chrome/browser/ui/browser_tab_strip_tracker.h" |
19 #include "chrome/browser/ui/tabs/tab_strip_model_observer.h" | 23 #include "chrome/browser/ui/tabs/tab_strip_model_observer.h" |
20 | 24 |
21 class BrowserList; | 25 class BrowserList; |
22 class GURL; | 26 class GURL; |
23 | 27 |
24 namespace content { | 28 namespace content { |
25 class WebContents; | 29 class WebContents; |
26 } | 30 } |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 bool IsTabDiscarded(content::WebContents* contents) const; | 79 bool IsTabDiscarded(content::WebContents* contents) const; |
76 | 80 |
77 // Discards a tab to free the memory occupied by its renderer. The tab still | 81 // Discards a tab to free the memory occupied by its renderer. The tab still |
78 // exists in the tab-strip; clicking on it will reload it. Returns true if it | 82 // exists in the tab-strip; clicking on it will reload it. Returns true if it |
79 // successfully found a tab and discarded it. | 83 // successfully found a tab and discarded it. |
80 bool DiscardTab(); | 84 bool DiscardTab(); |
81 | 85 |
82 // Discards a tab with the given unique ID. The tab still exists in the | 86 // Discards a tab with the given unique ID. The tab still exists in the |
83 // tab-strip; clicking on it will reload it. Returns true if it successfully | 87 // tab-strip; clicking on it will reload it. Returns true if it successfully |
84 // found a tab and discarded it. | 88 // found a tab and discarded it. |
85 content::WebContents* DiscardTabById(int64 target_web_contents_id); | 89 content::WebContents* DiscardTabById(int64_t target_web_contents_id); |
86 | 90 |
87 // Log memory statistics for the running processes, then discards a tab. | 91 // Log memory statistics for the running processes, then discards a tab. |
88 // Tab discard happens sometime later, as collecting the statistics touches | 92 // Tab discard happens sometime later, as collecting the statistics touches |
89 // multiple threads and takes time. | 93 // multiple threads and takes time. |
90 void LogMemoryAndDiscardTab(); | 94 void LogMemoryAndDiscardTab(); |
91 | 95 |
92 // Log memory statistics for the running processes, then call the callback. | 96 // Log memory statistics for the running processes, then call the callback. |
93 void LogMemory(const std::string& title, const base::Closure& callback); | 97 void LogMemory(const std::string& title, const base::Closure& callback); |
94 | 98 |
95 private: | 99 private: |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 bool active_desktop, | 131 bool active_desktop, |
128 TabStatsList* stats_list); | 132 TabStatsList* stats_list); |
129 | 133 |
130 // Callback for when |update_timer_| fires. Takes care of executing the tasks | 134 // Callback for when |update_timer_| fires. Takes care of executing the tasks |
131 // that need to be run periodically (see comment in implementation). | 135 // that need to be run periodically (see comment in implementation). |
132 void UpdateTimerCallback(); | 136 void UpdateTimerCallback(); |
133 | 137 |
134 // Goes through a list of checks to see if a tab is allowed to be discarded by | 138 // Goes through a list of checks to see if a tab is allowed to be discarded by |
135 // the automatic tab discarding mechanism. Note that this is not used when | 139 // the automatic tab discarding mechanism. Note that this is not used when |
136 // discarding a particular tab from about:discards. | 140 // discarding a particular tab from about:discards. |
137 bool CanDiscardTab(int64 target_web_contents_id) const; | 141 bool CanDiscardTab(int64_t target_web_contents_id) const; |
138 | 142 |
139 // Does the actual discard by destroying the WebContents in |model| at |index| | 143 // Does the actual discard by destroying the WebContents in |model| at |index| |
140 // and replacing it by an empty one. Returns the new WebContents or NULL if | 144 // and replacing it by an empty one. Returns the new WebContents or NULL if |
141 // the operation fails (return value used only in testing). | 145 // the operation fails (return value used only in testing). |
142 content::WebContents* DiscardWebContentsAt(int index, TabStripModel* model); | 146 content::WebContents* DiscardWebContentsAt(int index, TabStripModel* model); |
143 | 147 |
144 // Called by the memory pressure listener when the memory pressure rises. | 148 // Called by the memory pressure listener when the memory pressure rises. |
145 void OnMemoryPressure( | 149 void OnMemoryPressure( |
146 base::MemoryPressureListener::MemoryPressureLevel memory_pressure_level); | 150 base::MemoryPressureListener::MemoryPressureLevel memory_pressure_level); |
147 | 151 |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 #endif | 206 #endif |
203 | 207 |
204 BrowserTabStripTracker browser_tab_strip_tracker_; | 208 BrowserTabStripTracker browser_tab_strip_tracker_; |
205 | 209 |
206 DISALLOW_COPY_AND_ASSIGN(TabManager); | 210 DISALLOW_COPY_AND_ASSIGN(TabManager); |
207 }; | 211 }; |
208 | 212 |
209 } // namespace memory | 213 } // namespace memory |
210 | 214 |
211 #endif // CHROME_BROWSER_MEMORY_TAB_MANAGER_H_ | 215 #endif // CHROME_BROWSER_MEMORY_TAB_MANAGER_H_ |
OLD | NEW |