| 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 694 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 705 auto tab_stats = GetUnsortedTabStats(); | 705 auto tab_stats = GetUnsortedTabStats(); |
| 706 for (auto& tab : tab_stats) { | 706 for (auto& tab : tab_stats) { |
| 707 if (!tab.render_process_host->IsProcessBackgrounded()) | 707 if (!tab.render_process_host->IsProcessBackgrounded()) |
| 708 continue; | 708 continue; |
| 709 // TODO(hajimehoshi): Now calling PurgeAndSuspend is implemented without | 709 // TODO(hajimehoshi): Now calling PurgeAndSuspend is implemented without |
| 710 // timers for simplicity, so PurgeAndSuspend is called even after the | 710 // timers for simplicity, so PurgeAndSuspend is called even after the |
| 711 // renderer is purged and suspended once. This should be replaced with | 711 // renderer is purged and suspended once. This should be replaced with |
| 712 // timers if we want necessary and sufficient signals. | 712 // timers if we want necessary and sufficient signals. |
| 713 if (tab.last_active > purge_and_suspend_time_threshold) | 713 if (tab.last_active > purge_and_suspend_time_threshold) |
| 714 continue; | 714 continue; |
| 715 if (!CanSuspendBackgroundedRenderer(tab.child_process_host_id)) |
| 716 continue; |
| 715 tab.render_process_host->PurgeAndSuspend(); | 717 tab.render_process_host->PurgeAndSuspend(); |
| 716 } | 718 } |
| 717 } | 719 } |
| 718 | 720 |
| 719 WebContents* TabManager::DiscardWebContentsAt(int index, TabStripModel* model) { | 721 WebContents* TabManager::DiscardWebContentsAt(int index, TabStripModel* model) { |
| 720 // Can't discard active index. | 722 // Can't discard active index. |
| 721 if (model->active_index() == index) | 723 if (model->active_index() == index) |
| 722 return nullptr; | 724 return nullptr; |
| 723 | 725 |
| 724 WebContents* old_contents = model->GetWebContentsAt(index); | 726 WebContents* old_contents = model->GetWebContentsAt(index); |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 957 // platform. | 959 // platform. |
| 958 std::string allow_multiple_discards = variations::GetVariationParamValue( | 960 std::string allow_multiple_discards = variations::GetVariationParamValue( |
| 959 features::kAutomaticTabDiscarding.name, "AllowMultipleDiscards"); | 961 features::kAutomaticTabDiscarding.name, "AllowMultipleDiscards"); |
| 960 return (allow_multiple_discards != "true"); | 962 return (allow_multiple_discards != "true"); |
| 961 #else | 963 #else |
| 962 return false; | 964 return false; |
| 963 #endif | 965 #endif |
| 964 } | 966 } |
| 965 | 967 |
| 966 } // namespace memory | 968 } // namespace memory |
| OLD | NEW |