| 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/memory/tab_manager.h" | 5 #include "chrome/browser/memory/tab_manager.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <set> | 10 #include <set> |
| (...skipping 653 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 664 LogMemoryAndDiscardTab(); | 664 LogMemoryAndDiscardTab(); |
| 665 } | 665 } |
| 666 // TODO(skuhne): If more memory pressure levels are introduced, consider | 666 // TODO(skuhne): If more memory pressure levels are introduced, consider |
| 667 // calling PurgeBrowserMemory() before CRITICAL is reached. | 667 // calling PurgeBrowserMemory() before CRITICAL is reached. |
| 668 | 668 |
| 669 // If this is the beginning of a period of memory pressure then kick off | 669 // If this is the beginning of a period of memory pressure then kick off |
| 670 // notification of child processes. | 670 // notification of child processes. |
| 671 // NOTE: This mechanism relies on having a MemoryPressureMonitor | 671 // NOTE: This mechanism relies on having a MemoryPressureMonitor |
| 672 // implementation that supports "CurrentPressureLevel". This is true on all | 672 // implementation that supports "CurrentPressureLevel". This is true on all |
| 673 // platforms on which TabManager is used. | 673 // platforms on which TabManager is used. |
| 674 #if !defined(OS_CHROMEOS) |
| 675 // Running GC under memory pressure can cause thrashing. Disable it on |
| 676 // ChromeOS until the thrashing is fixed. crbug.com/588172. |
| 674 if (!under_memory_pressure_) | 677 if (!under_memory_pressure_) |
| 675 DoChildProcessDispatch(); | 678 DoChildProcessDispatch(); |
| 679 #endif |
| 676 } | 680 } |
| 677 | 681 |
| 678 bool TabManager::IsMediaTab(WebContents* contents) const { | 682 bool TabManager::IsMediaTab(WebContents* contents) const { |
| 679 if (contents->WasRecentlyAudible()) | 683 if (contents->WasRecentlyAudible()) |
| 680 return true; | 684 return true; |
| 681 | 685 |
| 682 scoped_refptr<MediaStreamCaptureIndicator> media_indicator = | 686 scoped_refptr<MediaStreamCaptureIndicator> media_indicator = |
| 683 MediaCaptureDevicesDispatcher::GetInstance() | 687 MediaCaptureDevicesDispatcher::GetInstance() |
| 684 ->GetMediaStreamCaptureIndicator(); | 688 ->GetMediaStreamCaptureIndicator(); |
| 685 if (media_indicator->IsCapturingUserMedia(contents) || | 689 if (media_indicator->IsCapturingUserMedia(contents) || |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 800 // Schedule another notification. Use a weak pointer so this doesn't explode | 804 // Schedule another notification. Use a weak pointer so this doesn't explode |
| 801 // during tear down. | 805 // during tear down. |
| 802 task_runner_->PostDelayedTask( | 806 task_runner_->PostDelayedTask( |
| 803 FROM_HERE, | 807 FROM_HERE, |
| 804 base::Bind(&TabManager::DoChildProcessDispatch, | 808 base::Bind(&TabManager::DoChildProcessDispatch, |
| 805 weak_ptr_factory_.GetWeakPtr()), | 809 weak_ptr_factory_.GetWeakPtr()), |
| 806 base::TimeDelta::FromSeconds(kRendererNotificationDelayInSeconds)); | 810 base::TimeDelta::FromSeconds(kRendererNotificationDelayInSeconds)); |
| 807 } | 811 } |
| 808 | 812 |
| 809 } // namespace memory | 813 } // namespace memory |
| OLD | NEW |