| 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_CHROMEOS_MEMORY_OOM_PRIORITY_MANAGER_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_MEMORY_OOM_PRIORITY_MANAGER_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_MEMORY_OOM_PRIORITY_MANAGER_H_ | 6 #define CHROME_BROWSER_CHROMEOS_MEMORY_OOM_PRIORITY_MANAGER_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 int discard_count() const { return discard_count_; } | 45 int discard_count() const { return discard_count_; } |
| 46 | 46 |
| 47 // See member comment. | 47 // See member comment. |
| 48 bool recent_tab_discard() const { return recent_tab_discard_; } | 48 bool recent_tab_discard() const { return recent_tab_discard_; } |
| 49 | 49 |
| 50 void Start(); | 50 void Start(); |
| 51 void Stop(); | 51 void Stop(); |
| 52 | 52 |
| 53 // Returns list of tab titles sorted from most interesting (don't kill) | 53 // Returns list of tab titles sorted from most interesting (don't kill) |
| 54 // to least interesting (OK to kill). | 54 // to least interesting (OK to kill). |
| 55 std::vector<string16> GetTabTitles(); | 55 std::vector<base::string16> GetTabTitles(); |
| 56 | 56 |
| 57 // Discards a tab to free the memory occupied by its renderer. | 57 // Discards a tab to free the memory occupied by its renderer. |
| 58 // Tab still exists in the tab-strip; clicking on it will reload it. | 58 // Tab still exists in the tab-strip; clicking on it will reload it. |
| 59 // Returns true if it successfully found a tab and discarded it. | 59 // Returns true if it successfully found a tab and discarded it. |
| 60 bool DiscardTab(); | 60 bool DiscardTab(); |
| 61 | 61 |
| 62 // Log memory statistics for the running processes, then discards a tab. | 62 // Log memory statistics for the running processes, then discards a tab. |
| 63 // Tab discard happens sometime later, as collecting the statistics touches | 63 // Tab discard happens sometime later, as collecting the statistics touches |
| 64 // multiple threads and takes time. | 64 // multiple threads and takes time. |
| 65 void LogMemoryAndDiscardTab(); | 65 void LogMemoryAndDiscardTab(); |
| 66 | 66 |
| 67 private: | 67 private: |
| 68 friend class OomMemoryDetails; | 68 friend class OomMemoryDetails; |
| 69 FRIEND_TEST_ALL_PREFIXES(OomPriorityManagerTest, Comparator); | 69 FRIEND_TEST_ALL_PREFIXES(OomPriorityManagerTest, Comparator); |
| 70 FRIEND_TEST_ALL_PREFIXES(OomPriorityManagerTest, IsReloadableUI); | 70 FRIEND_TEST_ALL_PREFIXES(OomPriorityManagerTest, IsReloadableUI); |
| 71 | 71 |
| 72 struct TabStats { | 72 struct TabStats { |
| 73 TabStats(); | 73 TabStats(); |
| 74 ~TabStats(); | 74 ~TabStats(); |
| 75 bool is_app; // browser window is an app | 75 bool is_app; // browser window is an app |
| 76 bool is_reloadable_ui; // Reloadable web UI page, like NTP or Settings. | 76 bool is_reloadable_ui; // Reloadable web UI page, like NTP or Settings. |
| 77 bool is_playing_audio; | 77 bool is_playing_audio; |
| 78 bool is_pinned; | 78 bool is_pinned; |
| 79 bool is_selected; // selected in the currently active browser window | 79 bool is_selected; // selected in the currently active browser window |
| 80 bool is_discarded; | 80 bool is_discarded; |
| 81 base::TimeTicks last_selected; | 81 base::TimeTicks last_selected; |
| 82 base::ProcessHandle renderer_handle; | 82 base::ProcessHandle renderer_handle; |
| 83 string16 title; | 83 base::string16 title; |
| 84 int64 tab_contents_id; // unique ID per WebContents | 84 int64 tab_contents_id; // unique ID per WebContents |
| 85 }; | 85 }; |
| 86 typedef std::vector<TabStats> TabStatsList; | 86 typedef std::vector<TabStats> TabStatsList; |
| 87 | 87 |
| 88 // Returns true if the |url| represents an internal Chrome web UI page that | 88 // Returns true if the |url| represents an internal Chrome web UI page that |
| 89 // can be easily reloaded and hence makes a good choice to discard. | 89 // can be easily reloaded and hence makes a good choice to discard. |
| 90 static bool IsReloadableUI(const GURL& url); | 90 static bool IsReloadableUI(const GURL& url); |
| 91 | 91 |
| 92 // Discards a tab with the given unique ID. Returns true if discard occurred. | 92 // Discards a tab with the given unique ID. Returns true if discard occurred. |
| 93 bool DiscardTabById(int64 target_web_contents_id); | 93 bool DiscardTabById(int64 target_web_contents_id); |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 // Whether a tab discard event has occurred during the last time interval, | 163 // Whether a tab discard event has occurred during the last time interval, |
| 164 // used for statistics normalized by usage. | 164 // used for statistics normalized by usage. |
| 165 bool recent_tab_discard_; | 165 bool recent_tab_discard_; |
| 166 | 166 |
| 167 DISALLOW_COPY_AND_ASSIGN(OomPriorityManager); | 167 DISALLOW_COPY_AND_ASSIGN(OomPriorityManager); |
| 168 }; | 168 }; |
| 169 | 169 |
| 170 } // namespace chromeos | 170 } // namespace chromeos |
| 171 | 171 |
| 172 #endif // CHROME_BROWSER_CHROMEOS_MEMORY_OOM_PRIORITY_MANAGER_H_ | 172 #endif // CHROME_BROWSER_CHROMEOS_MEMORY_OOM_PRIORITY_MANAGER_H_ |
| OLD | NEW |