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 #include "chrome/browser/oom_priority_manager.h" | 5 #include "chrome/browser/oom_priority_manager.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 case content::NOTIFICATION_RENDERER_PROCESS_TERMINATED: { | 211 case content::NOTIFICATION_RENDERER_PROCESS_TERMINATED: { |
212 handle = content::Source<content::RenderProcessHost>(source)-> | 212 handle = content::Source<content::RenderProcessHost>(source)-> |
213 GetHandle(); | 213 GetHandle(); |
214 pid_to_oom_score_.erase(handle); | 214 pid_to_oom_score_.erase(handle); |
215 break; | 215 break; |
216 } | 216 } |
217 case content::NOTIFICATION_RENDER_WIDGET_VISIBILITY_CHANGED: { | 217 case content::NOTIFICATION_RENDER_WIDGET_VISIBILITY_CHANGED: { |
218 bool visible = *content::Details<bool>(details).ptr(); | 218 bool visible = *content::Details<bool>(details).ptr(); |
219 if (visible) { | 219 if (visible) { |
220 focused_tab_pid_ = content::Source<RenderWidgetHost>(source).ptr()-> | 220 focused_tab_pid_ = content::Source<RenderWidgetHost>(source).ptr()-> |
221 process()->GetHandle(); | 221 GetProcess()->GetHandle(); |
222 | 222 |
223 // If the currently focused tab already has a lower score, do not | 223 // If the currently focused tab already has a lower score, do not |
224 // set it. This can happen in case the newly focused tab is script | 224 // set it. This can happen in case the newly focused tab is script |
225 // connected to the previous tab. | 225 // connected to the previous tab. |
226 ProcessScoreMap::iterator it; | 226 ProcessScoreMap::iterator it; |
227 it = pid_to_oom_score_.find(focused_tab_pid_); | 227 it = pid_to_oom_score_.find(focused_tab_pid_); |
228 if (it == pid_to_oom_score_.end() | 228 if (it == pid_to_oom_score_.end() |
229 || it->second != chrome::kLowestRendererOomScore) { | 229 || it->second != chrome::kLowestRendererOomScore) { |
230 // By starting a timer we guarantee that the tab is focused for | 230 // By starting a timer we guarantee that the tab is focused for |
231 // certain amount of time. Secondly, it also does not add overhead | 231 // certain amount of time. Secondly, it also does not add overhead |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
333 content::ZygoteHost::GetInstance()->AdjustRendererOOMScore( | 333 content::ZygoteHost::GetInstance()->AdjustRendererOOMScore( |
334 iterator->renderer_handle, score); | 334 iterator->renderer_handle, score); |
335 pid_to_oom_score_[iterator->renderer_handle] = score; | 335 pid_to_oom_score_[iterator->renderer_handle] = score; |
336 } | 336 } |
337 priority += priority_increment; | 337 priority += priority_increment; |
338 } | 338 } |
339 } | 339 } |
340 } | 340 } |
341 | 341 |
342 } // namespace browser | 342 } // namespace browser |
OLD | NEW |