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 #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/process.h" | 10 #include "base/process.h" |
11 #include "base/process_util.h" | 11 #include "base/process_util.h" |
12 #include "base/string_number_conversions.h" | 12 #include "base/string_number_conversions.h" |
13 #include "base/string16.h" | 13 #include "base/string16.h" |
14 #include "base/synchronization/lock.h" | 14 #include "base/synchronization/lock.h" |
15 #include "base/threading/thread.h" | 15 #include "base/threading/thread.h" |
16 #include "base/timer.h" | 16 #include "base/timer.h" |
17 #include "base/utf_string_conversions.h" | 17 #include "base/utf_string_conversions.h" |
18 #include "build/build_config.h" | 18 #include "build/build_config.h" |
19 #include "chrome/browser/tabs/tab_strip_model.h" | 19 #include "chrome/browser/tabs/tab_strip_model.h" |
20 #include "chrome/browser/ui/browser_list.h" | 20 #include "chrome/browser/ui/browser_list.h" |
21 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 21 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
22 #include "chrome/common/chrome_constants.h" | 22 #include "chrome/common/chrome_constants.h" |
23 #include "content/browser/browser_thread.h" | 23 #include "content/browser/browser_thread.h" |
24 #include "content/browser/renderer_host/render_process_host.h" | 24 #include "content/browser/renderer_host/render_process_host.h" |
25 #include "content/browser/renderer_host/render_widget_host.h" | 25 #include "content/browser/renderer_host/render_widget_host.h" |
26 #include "content/browser/tab_contents/tab_contents.h" | 26 #include "content/browser/tab_contents/tab_contents.h" |
27 #include "content/browser/zygote_host_linux.h" | 27 #include "content/browser/zygote_host_linux.h" |
28 #include "content/common/notification_service.h" | 28 #include "content/public/browser/notification_service.h" |
29 #include "content/public/browser/notification_types.h" | 29 #include "content/public/browser/notification_types.h" |
30 | 30 |
31 #if !defined(OS_CHROMEOS) | 31 #if !defined(OS_CHROMEOS) |
32 #error This file only meant to be compiled on ChromeOS | 32 #error This file only meant to be compiled on ChromeOS |
33 #endif | 33 #endif |
34 | 34 |
35 using base::TimeDelta; | 35 using base::TimeDelta; |
36 using base::TimeTicks; | 36 using base::TimeTicks; |
37 using base::ProcessHandle; | 37 using base::ProcessHandle; |
38 using base::ProcessMetrics; | 38 using base::ProcessMetrics; |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 tab_contents_id(0) { | 85 tab_contents_id(0) { |
86 } | 86 } |
87 | 87 |
88 OomPriorityManager::TabStats::~TabStats() { | 88 OomPriorityManager::TabStats::~TabStats() { |
89 } | 89 } |
90 | 90 |
91 OomPriorityManager::OomPriorityManager() | 91 OomPriorityManager::OomPriorityManager() |
92 : focused_tab_pid_(0) { | 92 : focused_tab_pid_(0) { |
93 registrar_.Add(this, | 93 registrar_.Add(this, |
94 content::NOTIFICATION_RENDERER_PROCESS_CLOSED, | 94 content::NOTIFICATION_RENDERER_PROCESS_CLOSED, |
95 NotificationService::AllBrowserContextsAndSources()); | 95 content::NotificationService::AllBrowserContextsAndSources()); |
96 registrar_.Add(this, | 96 registrar_.Add(this, |
97 content::NOTIFICATION_RENDERER_PROCESS_TERMINATED, | 97 content::NOTIFICATION_RENDERER_PROCESS_TERMINATED, |
98 NotificationService::AllBrowserContextsAndSources()); | 98 content::NotificationService::AllBrowserContextsAndSources()); |
99 registrar_.Add(this, | 99 registrar_.Add(this, |
100 content::NOTIFICATION_RENDER_WIDGET_VISIBILITY_CHANGED, | 100 content::NOTIFICATION_RENDER_WIDGET_VISIBILITY_CHANGED, |
101 NotificationService::AllBrowserContextsAndSources()); | 101 content::NotificationService::AllBrowserContextsAndSources()); |
102 } | 102 } |
103 | 103 |
104 OomPriorityManager::~OomPriorityManager() { | 104 OomPriorityManager::~OomPriorityManager() { |
105 Stop(); | 105 Stop(); |
106 } | 106 } |
107 | 107 |
108 void OomPriorityManager::Start() { | 108 void OomPriorityManager::Start() { |
109 if (!timer_.IsRunning()) { | 109 if (!timer_.IsRunning()) { |
110 timer_.Start(FROM_HERE, | 110 timer_.Start(FROM_HERE, |
111 TimeDelta::FromSeconds(ADJUSTMENT_INTERVAL_SECONDS), | 111 TimeDelta::FromSeconds(ADJUSTMENT_INTERVAL_SECONDS), |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
316 ZygoteHost::GetInstance()->AdjustRendererOOMScore( | 316 ZygoteHost::GetInstance()->AdjustRendererOOMScore( |
317 iterator->renderer_handle, score); | 317 iterator->renderer_handle, score); |
318 pid_to_oom_score_[iterator->renderer_handle] = score; | 318 pid_to_oom_score_[iterator->renderer_handle] = score; |
319 } | 319 } |
320 priority += priority_increment; | 320 priority += priority_increment; |
321 } | 321 } |
322 } | 322 } |
323 } | 323 } |
324 | 324 |
325 } // namespace browser | 325 } // namespace browser |
OLD | NEW |