Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(816)

Unified Diff: chrome/browser/memory/tab_manager_web_contents_data.h

Issue 2711093002: Purge once random minutes(between 30min and 60min) after backgrounded. (Closed)
Patch Set: Fixed. Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/memory/tab_manager_web_contents_data.h
diff --git a/chrome/browser/memory/tab_manager_web_contents_data.h b/chrome/browser/memory/tab_manager_web_contents_data.h
index 8f68c1239dec7c76096869da0df22681c15ff81c..efdeb3ddedba27b48029ecc848e7afb8e462083a 100644
--- a/chrome/browser/memory/tab_manager_web_contents_data.h
+++ b/chrome/browser/memory/tab_manager_web_contents_data.h
@@ -79,25 +79,23 @@ class TabManager::WebContentsData
// Sets/clears the auto-discardable state of the tab.
void SetAutoDiscardableState(bool state);
- // Sets the current purge-and-suspend state, and update the timestamp,
- // i.e. the last purge-and-suspend modified time.
- // TODO(tasak): remove this after PurgeAndSuspend code is moved into
+ // Sets the current purge state.
+ // TODO(tasak): remove this after the logic is moved into
// MemoryCoordinator.
- void SetPurgeAndSuspendState(TabManager::PurgeAndSuspendState state);
+ void SetPurgeState(bool state) { purge_state_ = state; }
Wez 2017/03/02 02:28:32 Similar to below, this can be set_is_purged()
tasak 2017/03/02 09:22:47 Done.
- // Returns the last purge-and-suspend modified time.
- // TODO(tasak): remove this after PurgeAndSuspend code is moved into
+ // Returns the current state of purge.
+ // TODO(tasak): remove this after the logic is moved into
// MemoryCoordinator.
- base::TimeTicks LastPurgeAndSuspendModifiedTime() const;
+ bool IsPurged() const { return purge_state_; }
Wez 2017/03/02 02:28:33 This can be hacker_case is_purged()
tasak 2017/03/02 09:22:47 Done.
- // Sets the timestamp of the last modified time the purge-and-suspend state
- // of the tab was changed for testing.
- void SetLastPurgeAndSuspendModifiedTimeForTesting(base::TimeTicks timestamp);
+ // Sets the time to purge after the tab is backgrounded.
+ void SetTimeToPurge(const base::TimeDelta& time_to_purge) {
Wez 2017/03/02 02:28:32 These can be hacker_case setter and getter.
tasak 2017/03/02 09:22:47 Done.
+ time_to_purge_ = time_to_purge;
+ }
- // Returns the current state of purge-and-suspend.
- // TODO(tasak): remove this after PurgeAndSuspend code is moved into
- // MemoryCoordinator.
- TabManager::PurgeAndSuspendState GetPurgeAndSuspendState() const;
+ // Returns the time to first purge after the tab is backgrounded.
+ base::TimeDelta TimeToPurge() const { return time_to_purge_; }
private:
// Needed to access tab_data_.
@@ -141,11 +139,18 @@ class TabManager::WebContentsData
// this test clock. Otherwise it returns the system clock's value.
base::TickClock* test_tick_clock_;
- // The last time purge-and-suspend state was modified.
- base::TimeTicks last_purge_and_suspend_modified_time_;
-
- // The current state of purge-and-suspend.
- PurgeAndSuspendState purge_and_suspend_state_;
+ // The time to purge after the tab is backgrounded.
+ base::TimeDelta time_to_purge_;
+
+ // The current state of purge. True means PURGED, and false means NOT PURGED.
+ // Initially purge_state_ is false.
Wez 2017/03/02 02:28:32 This isn't very clear; I think you want to say som
tasak 2017/03/02 09:22:47 Done.
+ // false => true
+ // - A tab is kept inactive and background for more than time-to-purge time.
+ // true => false
+ // - When ActiveTabChaged, the newly activated tab's state will be false.
+ // No need to be copied by CopyState, because CopyState is used when a tab is
+ // discarded. Instead, we make purge_state_ true.
+ bool purge_state_;
Wez 2017/03/02 02:28:33 Rename this is_purged_, to match the getter & sett
tasak 2017/03/02 09:22:47 Done.
DISALLOW_COPY_AND_ASSIGN(WebContentsData);
};

Powered by Google App Engine
This is Rietveld 408576698