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 621 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
632 stats.is_app = is_app; | 632 stats.is_app = is_app; |
633 stats.is_internal_page = IsInternalPage(contents->GetLastCommittedURL()); | 633 stats.is_internal_page = IsInternalPage(contents->GetLastCommittedURL()); |
634 stats.is_media = IsMediaTab(contents); | 634 stats.is_media = IsMediaTab(contents); |
635 stats.is_pinned = model->IsTabPinned(i); | 635 stats.is_pinned = model->IsTabPinned(i); |
636 stats.is_selected = active_model && model->IsTabSelected(i); | 636 stats.is_selected = active_model && model->IsTabSelected(i); |
637 stats.is_discarded = GetWebContentsData(contents)->IsDiscarded(); | 637 stats.is_discarded = GetWebContentsData(contents)->IsDiscarded(); |
638 stats.has_form_entry = | 638 stats.has_form_entry = |
639 contents->GetPageImportanceSignals().had_form_interaction; | 639 contents->GetPageImportanceSignals().had_form_interaction; |
640 stats.discard_count = GetWebContentsData(contents)->DiscardCount(); | 640 stats.discard_count = GetWebContentsData(contents)->DiscardCount(); |
641 stats.last_active = contents->GetLastActiveTime(); | 641 stats.last_active = contents->GetLastActiveTime(); |
| 642 stats.last_hidden = contents->GetLastHiddenTime(); |
642 stats.render_process_host = contents->GetRenderProcessHost(); | 643 stats.render_process_host = contents->GetRenderProcessHost(); |
643 stats.renderer_handle = contents->GetRenderProcessHost()->GetHandle(); | 644 stats.renderer_handle = contents->GetRenderProcessHost()->GetHandle(); |
644 stats.child_process_host_id = contents->GetRenderProcessHost()->GetID(); | 645 stats.child_process_host_id = contents->GetRenderProcessHost()->GetID(); |
645 #if defined(OS_CHROMEOS) | 646 #if defined(OS_CHROMEOS) |
646 stats.oom_score = delegate_->GetCachedOomScore(stats.renderer_handle); | 647 stats.oom_score = delegate_->GetCachedOomScore(stats.renderer_handle); |
647 #endif | 648 #endif |
648 stats.title = contents->GetTitle(); | 649 stats.title = contents->GetTitle(); |
649 stats.tab_contents_id = IdFromWebContents(contents); | 650 stats.tab_contents_id = IdFromWebContents(contents); |
650 stats_list->push_back(stats); | 651 stats_list->push_back(stats); |
651 } | 652 } |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
703 auto purge_and_suspend_time_threshold = | 704 auto purge_and_suspend_time_threshold = |
704 NowTicks() - base::TimeDelta::FromSeconds(purge_and_suspend_time); | 705 NowTicks() - base::TimeDelta::FromSeconds(purge_and_suspend_time); |
705 auto tab_stats = GetUnsortedTabStats(); | 706 auto tab_stats = GetUnsortedTabStats(); |
706 for (auto& tab : tab_stats) { | 707 for (auto& tab : tab_stats) { |
707 if (!tab.render_process_host->IsProcessBackgrounded()) | 708 if (!tab.render_process_host->IsProcessBackgrounded()) |
708 continue; | 709 continue; |
709 // TODO(hajimehoshi): Now calling PurgeAndSuspend is implemented without | 710 // TODO(hajimehoshi): Now calling PurgeAndSuspend is implemented without |
710 // timers for simplicity, so PurgeAndSuspend is called even after the | 711 // timers for simplicity, so PurgeAndSuspend is called even after the |
711 // renderer is purged and suspended once. This should be replaced with | 712 // renderer is purged and suspended once. This should be replaced with |
712 // timers if we want necessary and sufficient signals. | 713 // timers if we want necessary and sufficient signals. |
713 if (tab.last_active > purge_and_suspend_time_threshold) | 714 if (tab.last_hidden > purge_and_suspend_time_threshold) |
714 continue; | 715 continue; |
715 if (!CanSuspendBackgroundedRenderer(tab.child_process_host_id)) | 716 if (!CanSuspendBackgroundedRenderer(tab.child_process_host_id)) |
716 continue; | 717 continue; |
717 tab.render_process_host->PurgeAndSuspend(); | 718 tab.render_process_host->PurgeAndSuspend(); |
718 } | 719 } |
719 } | 720 } |
720 | 721 |
721 WebContents* TabManager::DiscardWebContentsAt(int index, TabStripModel* model) { | 722 WebContents* TabManager::DiscardWebContentsAt(int index, TabStripModel* model) { |
722 // Can't discard active index. | 723 // Can't discard active index. |
723 if (model->active_index() == index) | 724 if (model->active_index() == index) |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
959 // platform. | 960 // platform. |
960 std::string allow_multiple_discards = variations::GetVariationParamValue( | 961 std::string allow_multiple_discards = variations::GetVariationParamValue( |
961 features::kAutomaticTabDiscarding.name, "AllowMultipleDiscards"); | 962 features::kAutomaticTabDiscarding.name, "AllowMultipleDiscards"); |
962 return (allow_multiple_discards != "true"); | 963 return (allow_multiple_discards != "true"); |
963 #else | 964 #else |
964 return false; | 965 return false; |
965 #endif | 966 #endif |
966 } | 967 } |
967 | 968 |
968 } // namespace memory | 969 } // namespace memory |
OLD | NEW |