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

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

Issue 681733003: Removed the ProcessHandle from the RendererClosedDetails payload (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Updated child_process_id to child_process_host_id Created 6 years, 1 month 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/chromeos/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_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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 TabStats(); 72 TabStats();
73 ~TabStats(); 73 ~TabStats();
74 bool is_app; // browser window is an app 74 bool is_app; // browser window is an app
75 bool is_reloadable_ui; // Reloadable web UI page, like NTP or Settings. 75 bool is_reloadable_ui; // Reloadable web UI page, like NTP or Settings.
76 bool is_playing_audio; 76 bool is_playing_audio;
77 bool is_pinned; 77 bool is_pinned;
78 bool is_selected; // selected in the currently active browser window 78 bool is_selected; // selected in the currently active browser window
79 bool is_discarded; 79 bool is_discarded;
80 base::TimeTicks last_active; 80 base::TimeTicks last_active;
81 base::ProcessHandle renderer_handle; 81 base::ProcessHandle renderer_handle;
82 int child_process_host_id;
82 base::string16 title; 83 base::string16 title;
83 int64 tab_contents_id; // unique ID per WebContents 84 int64 tab_contents_id; // unique ID per WebContents
84 }; 85 };
85 typedef std::vector<TabStats> TabStatsList; 86 typedef std::vector<TabStats> TabStatsList;
86 87
87 // 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
88 // 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.
89 static bool IsReloadableUI(const GURL& url); 90 static bool IsReloadableUI(const GURL& url);
90 91
91 // 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.
(...skipping 12 matching lines...) Expand all
104 void PurgeBrowserMemory(); 105 void PurgeBrowserMemory();
105 106
106 // Returns the number of tabs open in all browser instances. 107 // Returns the number of tabs open in all browser instances.
107 int GetTabCount() const; 108 int GetTabCount() const;
108 109
109 TabStatsList GetTabStatsOnUIThread(); 110 TabStatsList GetTabStatsOnUIThread();
110 111
111 // Called when the timer fires, sets oom_adjust_score for all renderers. 112 // Called when the timer fires, sets oom_adjust_score for all renderers.
112 void AdjustOomPriorities(); 113 void AdjustOomPriorities();
113 114
114 // Returns a list of unique process handles from |stats_list|. If multiple 115 // Returns a list of child process host ids from |stats_list| with unique
115 // tabs use the same process, returns the first process handle. This implies 116 // pids. If multiple tabs use the same process, returns the first child
116 // that the processes are selected based on their "most important" tab. 117 // process host id. This implies that the processes are selected based on
117 static std::vector<base::ProcessHandle> GetProcessHandles( 118 // their "most important" tab.
119 static std::vector<int> GetChildProcessHostIds(
118 const TabStatsList& stats_list); 120 const TabStatsList& stats_list);
119 121
120 // Called by AdjustOomPriorities. 122 // Called by AdjustOomPriorities.
121 void AdjustOomPrioritiesOnFileThread(TabStatsList stats_list); 123 void AdjustOomPrioritiesOnFileThread(TabStatsList stats_list);
122 124
123 // Posts AdjustFocusedTabScore task to the file thread. 125 // Posts AdjustFocusedTabScore task to the file thread.
124 void OnFocusTabScoreAdjustmentTimeout(); 126 void OnFocusTabScoreAdjustmentTimeout();
125 127
126 // Sets the score of the focused tab to the least value. 128 // Sets the score of the focused tab to the least value.
127 void AdjustFocusedTabScoreOnFileThread(); 129 void AdjustFocusedTabScoreOnFileThread();
128 130
129 static bool CompareTabStats(TabStats first, TabStats second); 131 static bool CompareTabStats(TabStats first, TabStats second);
130 132
131 virtual void Observe(int type, 133 virtual void Observe(int type,
132 const content::NotificationSource& source, 134 const content::NotificationSource& source,
133 const content::NotificationDetails& details) override; 135 const content::NotificationDetails& details) override;
134 136
135 base::RepeatingTimer<OomPriorityManager> timer_; 137 base::RepeatingTimer<OomPriorityManager> timer_;
136 base::OneShotTimer<OomPriorityManager> focus_tab_score_adjust_timer_; 138 base::OneShotTimer<OomPriorityManager> focus_tab_score_adjust_timer_;
137 base::RepeatingTimer<OomPriorityManager> recent_tab_discard_timer_; 139 base::RepeatingTimer<OomPriorityManager> recent_tab_discard_timer_;
138 content::NotificationRegistrar registrar_; 140 content::NotificationRegistrar registrar_;
139 141
140 // This lock is for pid_to_oom_score_ and focus_tab_pid_. 142 // This lock is for |oom_score_map_| and |focused_tab_process_host_id_|.
141 base::Lock pid_to_oom_score_lock_; 143 base::Lock oom_score_lock_;
142 // map maintaining the process - oom_score mapping. 144 // Map maintaining the child process host id - oom_score mapping.
143 typedef base::hash_map<base::ProcessHandle, int> ProcessScoreMap; 145 typedef base::hash_map<int, int> ProcessScoreMap;
144 ProcessScoreMap pid_to_oom_score_; 146 ProcessScoreMap oom_score_map_;
145 base::ProcessHandle focused_tab_pid_; 147 // Holds the focussed tab's child process host id.
James Cook 2014/11/22 00:38:46 nit: focussed -> focused
sramajay 2014/11/24 12:00:07 Done.
148 int focused_tab_process_host_id_;
146 149
147 // Observer for the kernel low memory signal. NULL if tab discarding is 150 // Observer for the kernel low memory signal. NULL if tab discarding is
148 // disabled. 151 // disabled.
149 scoped_ptr<LowMemoryObserver> low_memory_observer_; 152 scoped_ptr<LowMemoryObserver> low_memory_observer_;
150 153
151 // Wall-clock time when the priority manager started running. 154 // Wall-clock time when the priority manager started running.
152 base::TimeTicks start_time_; 155 base::TimeTicks start_time_;
153 156
154 // Wall-clock time of last tab discard during this browsing session, or 0 if 157 // Wall-clock time of last tab discard during this browsing session, or 0 if
155 // no discard has happened yet. 158 // no discard has happened yet.
156 base::TimeTicks last_discard_time_; 159 base::TimeTicks last_discard_time_;
157 160
158 // Wall-clock time of last priority adjustment, used to correct the above 161 // Wall-clock time of last priority adjustment, used to correct the above
159 // times for discontinuities caused by suspend/resume. 162 // times for discontinuities caused by suspend/resume.
160 base::TimeTicks last_adjust_time_; 163 base::TimeTicks last_adjust_time_;
161 164
162 // Number of times we have discarded a tab, for statistics. 165 // Number of times we have discarded a tab, for statistics.
163 int discard_count_; 166 int discard_count_;
164 167
165 // Whether a tab discard event has occurred during the last time interval, 168 // Whether a tab discard event has occurred during the last time interval,
166 // used for statistics normalized by usage. 169 // used for statistics normalized by usage.
167 bool recent_tab_discard_; 170 bool recent_tab_discard_;
168 171
169 DISALLOW_COPY_AND_ASSIGN(OomPriorityManager); 172 DISALLOW_COPY_AND_ASSIGN(OomPriorityManager);
170 }; 173 };
171 174
172 } // namespace chromeos 175 } // namespace chromeos
173 176
174 #endif // CHROME_BROWSER_CHROMEOS_MEMORY_OOM_PRIORITY_MANAGER_H_ 177 #endif // CHROME_BROWSER_CHROMEOS_MEMORY_OOM_PRIORITY_MANAGER_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/chromeos/memory/oom_priority_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698