| 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 494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 505 if (!low_memory_observer_) { | 505 if (!low_memory_observer_) { |
| 506 // Coming here we know that a renderer was just killed and memory should | 506 // Coming here we know that a renderer was just killed and memory should |
| 507 // come back into the pool. However - the memory pressure observer did | 507 // come back into the pool. However - the memory pressure observer did |
| 508 // not yet update its status and therefore we ask it to redo the | 508 // not yet update its status and therefore we ask it to redo the |
| 509 // measurement, calling us again if we have to release more. | 509 // measurement, calling us again if we have to release more. |
| 510 // Note: We do not only accelerate the discarding speed by doing another | 510 // Note: We do not only accelerate the discarding speed by doing another |
| 511 // check in short succession - we also accelerate it because the timer | 511 // check in short succession - we also accelerate it because the timer |
| 512 // driven MemoryPressureMonitor will continue to produce timed events | 512 // driven MemoryPressureMonitor will continue to produce timed events |
| 513 // on top. So the longer the cleanup phase takes, the more tabs will | 513 // on top. So the longer the cleanup phase takes, the more tabs will |
| 514 // get discarded in parallel. | 514 // get discarded in parallel. |
| 515 base::MemoryPressureMonitorChromeOS* monitor = | 515 base::chromeos::MemoryPressureMonitor* monitor = |
| 516 static_cast<base::MemoryPressureMonitorChromeOS*>( | 516 static_cast<base::chromeos::MemoryPressureMonitor*>( |
| 517 base::MemoryPressureMonitor::Get()); | 517 base::MemoryPressureMonitor::Get()); |
| 518 if (monitor) | 518 if (monitor) |
| 519 monitor->ScheduleEarlyCheck(); | 519 monitor->ScheduleEarlyCheck(); |
| 520 } | 520 } |
| 521 break; | 521 break; |
| 522 } | 522 } |
| 523 case content::NOTIFICATION_RENDER_WIDGET_VISIBILITY_CHANGED: { | 523 case content::NOTIFICATION_RENDER_WIDGET_VISIBILITY_CHANGED: { |
| 524 bool visible = *content::Details<bool>(details).ptr(); | 524 bool visible = *content::Details<bool>(details).ptr(); |
| 525 if (visible) { | 525 if (visible) { |
| 526 content::RenderProcessHost* render_host = | 526 content::RenderProcessHost* render_host = |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 700 // For the moment we only do something when we reach a critical state. | 700 // For the moment we only do something when we reach a critical state. |
| 701 if (memory_pressure_level == | 701 if (memory_pressure_level == |
| 702 base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_CRITICAL) { | 702 base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_CRITICAL) { |
| 703 LogMemoryAndDiscardTab(); | 703 LogMemoryAndDiscardTab(); |
| 704 } | 704 } |
| 705 // TODO(skuhne): If more memory pressure levels are introduced, we might | 705 // TODO(skuhne): If more memory pressure levels are introduced, we might |
| 706 // consider to call PurgeBrowserMemory() before CRITICAL is reached. | 706 // consider to call PurgeBrowserMemory() before CRITICAL is reached. |
| 707 } | 707 } |
| 708 | 708 |
| 709 } // namespace chromeos | 709 } // namespace chromeos |
| OLD | NEW |