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

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

Issue 7930022: chromeos: Set a least score to the currently focused tab so that it is not selected (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 9 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/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) 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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 base::ProcessHandle renderer_handle; 54 base::ProcessHandle renderer_handle;
55 string16 title; 55 string16 title;
56 }; 56 };
57 typedef std::vector<RendererStats> StatsList; 57 typedef std::vector<RendererStats> StatsList;
58 typedef base::hash_map<base::ProcessHandle, int> ProcessScoreMap; 58 typedef base::hash_map<base::ProcessHandle, int> ProcessScoreMap;
59 59
60 // Posts DoAdjustOomPriorities task to the file thread. Called when 60 // Posts DoAdjustOomPriorities task to the file thread. Called when
61 // the timer fires. 61 // the timer fires.
62 void AdjustOomPriorities(); 62 void AdjustOomPriorities();
63 63
64 // Posts AdjustFocusedTabScore task to the file thread.
65 void OnFocusTabScoreAdjustmentTimeout();
66
64 // Called by AdjustOomPriorities. Runs on the file thread. 67 // Called by AdjustOomPriorities. Runs on the file thread.
65 void DoAdjustOomPriorities(); 68 void DoAdjustOomPriorities();
66 69
70 // Called when a tab comes into focus. Runs on the file thread.
71 // Sets the score of only the currently focused tab to the least value.
72 void AdjustFocusedTabScore();
73
67 static bool CompareRendererStats(RendererStats first, RendererStats second); 74 static bool CompareRendererStats(RendererStats first, RendererStats second);
68 75
69 virtual void Observe(int type, 76 virtual void Observe(int type,
70 const NotificationSource& source, 77 const NotificationSource& source,
71 const NotificationDetails& details); 78 const NotificationDetails& details);
72 79
73 base::RepeatingTimer<OomPriorityManager> timer_; 80 base::RepeatingTimer<OomPriorityManager> timer_;
81 base::OneShotTimer<OomPriorityManager> focus_tab_score_adjust_timer_;
74 // renderer_stats_ is used on both UI and file threads. 82 // renderer_stats_ is used on both UI and file threads.
75 base::Lock renderer_stats_lock_; 83 base::Lock renderer_stats_lock_;
76 StatsList renderer_stats_; 84 StatsList renderer_stats_;
77 // map maintaining the process - oom_score map. 85 // This lock is for pid_to_oom_score_ and focus_tab_pid_.
78 base::Lock pid_to_oom_score_lock_; 86 base::Lock pid_to_oom_score_lock_;
87 // map maintaining the process - oom_score mapping.
79 ProcessScoreMap pid_to_oom_score_; 88 ProcessScoreMap pid_to_oom_score_;
80 NotificationRegistrar registrar_; 89 NotificationRegistrar registrar_;
90 base::ProcessHandle focused_tab_pid_;
81 91
82 DISALLOW_COPY_AND_ASSIGN(OomPriorityManager); 92 DISALLOW_COPY_AND_ASSIGN(OomPriorityManager);
83 }; 93 };
84 94
85 } // namespace browser 95 } // namespace browser
86 96
87 DISABLE_RUNNABLE_METHOD_REFCOUNT(browser::OomPriorityManager); 97 DISABLE_RUNNABLE_METHOD_REFCOUNT(browser::OomPriorityManager);
88 98
89 #endif // CHROME_BROWSER_OOM_PRIORITY_MANAGER_H_ 99 #endif // CHROME_BROWSER_OOM_PRIORITY_MANAGER_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/oom_priority_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698