Chromium Code Reviews| 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/resource_coordinator/tab_manager.h" | 5 #include "chrome/browser/resource_coordinator/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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 105 TabManager::TabManager() | 105 TabManager::TabManager() |
| 106 : discard_count_(0), | 106 : discard_count_(0), |
| 107 recent_tab_discard_(false), | 107 recent_tab_discard_(false), |
| 108 discard_once_(false), | 108 discard_once_(false), |
| 109 #if !defined(OS_CHROMEOS) | 109 #if !defined(OS_CHROMEOS) |
| 110 minimum_protection_time_(base::TimeDelta::FromMinutes(10)), | 110 minimum_protection_time_(base::TimeDelta::FromMinutes(10)), |
| 111 #endif | 111 #endif |
| 112 browser_tab_strip_tracker_(this, nullptr, nullptr), | 112 browser_tab_strip_tracker_(this, nullptr, nullptr), |
| 113 test_tick_clock_(nullptr), | 113 test_tick_clock_(nullptr), |
| 114 in_session_restore_(false), | 114 in_session_restore_(false), |
| 115 initial_active_tab_changed_(false), | |
| 115 weak_ptr_factory_(this) { | 116 weak_ptr_factory_(this) { |
| 116 #if defined(OS_CHROMEOS) | 117 #if defined(OS_CHROMEOS) |
| 117 delegate_.reset(new TabManagerDelegate(weak_ptr_factory_.GetWeakPtr())); | 118 delegate_.reset(new TabManagerDelegate(weak_ptr_factory_.GetWeakPtr())); |
| 118 #endif | 119 #endif |
| 119 browser_tab_strip_tracker_.Init(); | 120 browser_tab_strip_tracker_.Init(); |
| 120 } | 121 } |
| 121 | 122 |
| 122 TabManager::~TabManager() { | 123 TabManager::~TabManager() { |
| 123 Stop(); | 124 Stop(); |
| 124 } | 125 } |
| (...skipping 661 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 786 // When ActiveTabChanged, |new_contents| purged state changes to be false. | 787 // When ActiveTabChanged, |new_contents| purged state changes to be false. |
| 787 GetWebContentsData(new_contents)->set_is_purged(false); | 788 GetWebContentsData(new_contents)->set_is_purged(false); |
| 788 // If |old_contents| is set, that tab has switched from being active to | 789 // If |old_contents| is set, that tab has switched from being active to |
| 789 // inactive, so record the time of that transition. | 790 // inactive, so record the time of that transition. |
| 790 if (old_contents) { | 791 if (old_contents) { |
| 791 GetWebContentsData(old_contents)->SetLastInactiveTime(NowTicks()); | 792 GetWebContentsData(old_contents)->SetLastInactiveTime(NowTicks()); |
| 792 // Re-setting time-to-purge every time a tab becomes inactive. | 793 // Re-setting time-to-purge every time a tab becomes inactive. |
| 793 GetWebContentsData(old_contents) | 794 GetWebContentsData(old_contents) |
| 794 ->set_time_to_purge(GetTimeToPurge(min_time_to_purge_)); | 795 ->set_time_to_purge(GetTimeToPurge(min_time_to_purge_)); |
| 795 } | 796 } |
| 797 | |
| 798 if (old_contents && !initial_active_tab_changed_) { | |
| 799 initial_active_tab_changed_ = true; | |
|
chrisha
2017/06/21 15:00:26
This logic seems frail. If this is specifically ti
ducbui
2017/06/27 19:41:24
Acknowledged. I reset the flag for each session re
| |
| 800 } | |
| 796 } | 801 } |
| 797 | 802 |
| 798 void TabManager::TabInsertedAt(TabStripModel* tab_strip_model, | 803 void TabManager::TabInsertedAt(TabStripModel* tab_strip_model, |
| 799 content::WebContents* contents, | 804 content::WebContents* contents, |
| 800 int index, | 805 int index, |
| 801 bool foreground) { | 806 bool foreground) { |
| 802 // Only interested in background tabs, as foreground tabs get taken care of by | 807 // Only interested in background tabs, as foreground tabs get taken care of by |
| 803 // ActiveTabChanged. | 808 // ActiveTabChanged. |
| 804 if (foreground) | 809 if (foreground) |
| 805 return; | 810 return; |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 876 // platform. | 881 // platform. |
| 877 std::string allow_multiple_discards = variations::GetVariationParamValue( | 882 std::string allow_multiple_discards = variations::GetVariationParamValue( |
| 878 features::kAutomaticTabDiscarding.name, "AllowMultipleDiscards"); | 883 features::kAutomaticTabDiscarding.name, "AllowMultipleDiscards"); |
| 879 return (allow_multiple_discards != "true"); | 884 return (allow_multiple_discards != "true"); |
| 880 #else | 885 #else |
| 881 return false; | 886 return false; |
| 882 #endif | 887 #endif |
| 883 } | 888 } |
| 884 | 889 |
| 885 } // namespace resource_coordinator | 890 } // namespace resource_coordinator |
| OLD | NEW |