Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_OOM_PRIORITY_MANAGER_H_ | 5 #ifndef CHROME_BROWSER_OOM_PRIORITY_MANAGER_H_ |
| 6 #define CHROME_BROWSER_OOM_PRIORITY_MANAGER_H_ | 6 #define CHROME_BROWSER_OOM_PRIORITY_MANAGER_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/hash_tables.h" | 10 #include "base/hash_tables.h" |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 58 base::ProcessHandle renderer_handle; | 58 base::ProcessHandle renderer_handle; |
| 59 string16 title; | 59 string16 title; |
| 60 }; | 60 }; |
| 61 typedef std::vector<RendererStats> StatsList; | 61 typedef std::vector<RendererStats> StatsList; |
| 62 typedef base::hash_map<base::ProcessHandle, int> ProcessScoreMap; | 62 typedef base::hash_map<base::ProcessHandle, int> ProcessScoreMap; |
| 63 | 63 |
| 64 // Posts DoAdjustOomPriorities task to the file thread. Called when | 64 // Posts DoAdjustOomPriorities task to the file thread. Called when |
| 65 // the timer fires. | 65 // the timer fires. |
| 66 void AdjustOomPriorities(); | 66 void AdjustOomPriorities(); |
| 67 | 67 |
| 68 // Posts AdjustFocusedTabScore task to the file thread. | |
| 69 void FocusTabScoreAdjustmentTimeout(); | |
|
James Cook
2011/09/20 17:08:03
nit: Maybe call this PostAdjustFocusedTabScore() o
amruthraj
2011/09/21 04:25:01
Done.
| |
| 70 | |
| 68 // Called by AdjustOomPriorities. Runs on the file thread. | 71 // Called by AdjustOomPriorities. Runs on the file thread. |
| 69 void DoAdjustOomPriorities(); | 72 void DoAdjustOomPriorities(); |
| 70 | 73 |
| 74 // Called when a tab comes into focus. Runs on the file thread. | |
| 75 // Sets the score of only the currently focused tab to the least value. | |
| 76 void AdjustFocusedTabScore(); | |
| 77 | |
| 71 static bool CompareRendererStats(RendererStats first, RendererStats second); | 78 static bool CompareRendererStats(RendererStats first, RendererStats second); |
| 72 | 79 |
| 73 virtual void Observe(int type, | 80 virtual void Observe(int type, |
| 74 const NotificationSource& source, | 81 const NotificationSource& source, |
| 75 const NotificationDetails& details); | 82 const NotificationDetails& details); |
| 76 | 83 |
| 77 base::RepeatingTimer<OomPriorityManager> timer_; | 84 base::RepeatingTimer<OomPriorityManager> timer_; |
| 85 base::OneShotTimer<OomPriorityManager> focus_tab_score_adjust_timer_; | |
| 78 // renderer_stats_ is used on both UI and file threads. | 86 // renderer_stats_ is used on both UI and file threads. |
| 79 base::Lock renderer_stats_lock_; | 87 base::Lock renderer_stats_lock_; |
| 80 StatsList renderer_stats_; | 88 StatsList renderer_stats_; |
| 81 // map maintaining the process - oom_score map. | 89 // This lock is for pid_to_oom_score_ and focus_tab_pid_. |
| 82 base::Lock pid_to_oom_score_lock_; | 90 base::Lock pid_to_oom_score_lock_; |
| 91 // map maintaining the process - oom_score mapping. | |
| 83 ProcessScoreMap pid_to_oom_score_; | 92 ProcessScoreMap pid_to_oom_score_; |
| 84 NotificationRegistrar registrar_; | 93 NotificationRegistrar registrar_; |
| 94 base::ProcessHandle focused_tab_pid_; | |
| 85 | 95 |
| 86 DISALLOW_COPY_AND_ASSIGN(OomPriorityManager); | 96 DISALLOW_COPY_AND_ASSIGN(OomPriorityManager); |
| 87 }; | 97 }; |
| 88 | 98 |
| 89 } // namespace browser | 99 } // namespace browser |
| 90 | 100 |
| 91 DISABLE_RUNNABLE_METHOD_REFCOUNT(browser::OomPriorityManager); | 101 DISABLE_RUNNABLE_METHOD_REFCOUNT(browser::OomPriorityManager); |
| 92 | 102 |
| 93 #endif // CHROME_BROWSER_OOM_PRIORITY_MANAGER_H_ | 103 #endif // CHROME_BROWSER_OOM_PRIORITY_MANAGER_H_ |
| OLD | NEW |