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 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
285 if (DiscardTabById(least_important_tab_id)) | 285 if (DiscardTabById(least_important_tab_id)) |
286 return true; | 286 return true; |
287 } | 287 } |
288 return false; | 288 return false; |
289 } | 289 } |
290 | 290 |
291 void OomPriorityManager::LogMemoryAndDiscardTab() { | 291 void OomPriorityManager::LogMemoryAndDiscardTab() { |
292 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 292 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
293 // Deletes itself upon completion. | 293 // Deletes itself upon completion. |
294 OomMemoryDetails* details = new OomMemoryDetails(); | 294 OomMemoryDetails* details = new OomMemoryDetails(); |
295 details->StartFetch(MemoryDetails::SKIP_USER_METRICS); | 295 details->StartFetch(); |
296 } | 296 } |
297 | 297 |
298 /////////////////////////////////////////////////////////////////////////////// | 298 /////////////////////////////////////////////////////////////////////////////// |
299 // OomPriorityManager, private: | 299 // OomPriorityManager, private: |
300 | 300 |
301 // static | 301 // static |
302 bool OomPriorityManager::IsReloadableUI(const GURL& url) { | 302 bool OomPriorityManager::IsReloadableUI(const GURL& url) { |
303 // There are many chrome:// UI URLs, but only look for the ones that users | 303 // There are many chrome:// UI URLs, but only look for the ones that users |
304 // are likely to have open. Most of the benefit is the from NTP URL. | 304 // are likely to have open. Most of the benefit is the from NTP URL. |
305 const char* const kReloadableUrlPrefixes[] = { | 305 const char* const kReloadableUrlPrefixes[] = { |
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
709 // For the moment we only do something when we reach a critical state. | 709 // For the moment we only do something when we reach a critical state. |
710 if (memory_pressure_level == | 710 if (memory_pressure_level == |
711 base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_CRITICAL) { | 711 base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_CRITICAL) { |
712 LogMemoryAndDiscardTab(); | 712 LogMemoryAndDiscardTab(); |
713 } | 713 } |
714 // TODO(skuhne): If more memory pressure levels are introduced, we might | 714 // TODO(skuhne): If more memory pressure levels are introduced, we might |
715 // consider to call PurgeBrowserMemory() before CRITICAL is reached. | 715 // consider to call PurgeBrowserMemory() before CRITICAL is reached. |
716 } | 716 } |
717 | 717 |
718 } // namespace chromeos | 718 } // namespace chromeos |
OLD | NEW |