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/chromeos/memory/oom_priority_manager.h" | 5 #include "chrome/browser/chromeos/memory/oom_priority_manager.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <set> | 8 #include <set> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 16 matching lines...) Expand all Loading... |
27 #include "chrome/browser/browser_process_platform_part_chromeos.h" | 27 #include "chrome/browser/browser_process_platform_part_chromeos.h" |
28 #include "chrome/browser/memory_details.h" | 28 #include "chrome/browser/memory_details.h" |
29 #include "chrome/browser/ui/browser.h" | 29 #include "chrome/browser/ui/browser.h" |
30 #include "chrome/browser/ui/browser_iterator.h" | 30 #include "chrome/browser/ui/browser_iterator.h" |
31 #include "chrome/browser/ui/browser_list.h" | 31 #include "chrome/browser/ui/browser_list.h" |
32 #include "chrome/browser/ui/host_desktop.h" | 32 #include "chrome/browser/ui/host_desktop.h" |
33 #include "chrome/browser/ui/tab_contents/tab_contents_iterator.h" | 33 #include "chrome/browser/ui/tab_contents/tab_contents_iterator.h" |
34 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 34 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
35 #include "chrome/browser/ui/tabs/tab_utils.h" | 35 #include "chrome/browser/ui/tabs/tab_utils.h" |
36 #include "chrome/common/chrome_constants.h" | 36 #include "chrome/common/chrome_constants.h" |
37 #include "chrome/common/chrome_switches.h" | |
38 #include "chrome/common/url_constants.h" | 37 #include "chrome/common/url_constants.h" |
| 38 #include "chromeos/chromeos_switches.h" |
39 #include "chromeos/memory/low_memory_listener.h" | 39 #include "chromeos/memory/low_memory_listener.h" |
40 #include "content/public/browser/browser_thread.h" | 40 #include "content/public/browser/browser_thread.h" |
41 #include "content/public/browser/notification_service.h" | 41 #include "content/public/browser/notification_service.h" |
42 #include "content/public/browser/notification_types.h" | 42 #include "content/public/browser/notification_types.h" |
43 #include "content/public/browser/render_process_host.h" | 43 #include "content/public/browser/render_process_host.h" |
44 #include "content/public/browser/render_widget_host.h" | 44 #include "content/public/browser/render_widget_host.h" |
45 #include "content/public/browser/web_contents.h" | 45 #include "content/public/browser/web_contents.h" |
46 #include "content/public/browser/zygote_host_linux.h" | 46 #include "content/public/browser/zygote_host_linux.h" |
47 #include "ui/base/text/bytes_formatting.h" | 47 #include "ui/base/text/bytes_formatting.h" |
48 | 48 |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 } | 166 } |
167 | 167 |
168 OomPriorityManager::TabStats::~TabStats() { | 168 OomPriorityManager::TabStats::~TabStats() { |
169 } | 169 } |
170 | 170 |
171 OomPriorityManager::OomPriorityManager() | 171 OomPriorityManager::OomPriorityManager() |
172 : focused_tab_pid_(0), | 172 : focused_tab_pid_(0), |
173 discard_count_(0), | 173 discard_count_(0), |
174 recent_tab_discard_(false) { | 174 recent_tab_discard_(false) { |
175 // We only need the low memory observer if we want to discard tabs. | 175 // We only need the low memory observer if we want to discard tabs. |
176 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kNoDiscardTabs)) | 176 if (!CommandLine::ForCurrentProcess()->HasSwitch( |
| 177 chromeos::switches::kNoDiscardTabs)) |
177 low_memory_listener_.reset(new LowMemoryListener(this)); | 178 low_memory_listener_.reset(new LowMemoryListener(this)); |
178 | 179 |
179 registrar_.Add(this, | 180 registrar_.Add(this, |
180 content::NOTIFICATION_RENDERER_PROCESS_CLOSED, | 181 content::NOTIFICATION_RENDERER_PROCESS_CLOSED, |
181 content::NotificationService::AllBrowserContextsAndSources()); | 182 content::NotificationService::AllBrowserContextsAndSources()); |
182 registrar_.Add(this, | 183 registrar_.Add(this, |
183 content::NOTIFICATION_RENDERER_PROCESS_TERMINATED, | 184 content::NOTIFICATION_RENDERER_PROCESS_TERMINATED, |
184 content::NotificationService::AllBrowserContextsAndSources()); | 185 content::NotificationService::AllBrowserContextsAndSources()); |
185 registrar_.Add(this, | 186 registrar_.Add(this, |
186 content::NOTIFICATION_RENDER_WIDGET_VISIBILITY_CHANGED, | 187 content::NOTIFICATION_RENDER_WIDGET_VISIBILITY_CHANGED, |
(...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
637 } | 638 } |
638 } | 639 } |
639 } | 640 } |
640 | 641 |
641 void OomPriorityManager::OnMemoryLow() { | 642 void OomPriorityManager::OnMemoryLow() { |
642 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 643 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
643 LogMemoryAndDiscardTab(); | 644 LogMemoryAndDiscardTab(); |
644 } | 645 } |
645 | 646 |
646 } // namespace chromeos | 647 } // namespace chromeos |
OLD | NEW |