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

Side by Side Diff: chrome/browser/memory/tab_manager_web_contents_data.h

Issue 2167843004: Discardable property support on TabManager (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 5 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 #ifndef CHROME_BROWSER_MEMORY_TAB_MANAGER_WEB_CONTENTS_DATA_H_ 5 #ifndef CHROME_BROWSER_MEMORY_TAB_MANAGER_WEB_CONTENTS_DATA_H_
6 #define CHROME_BROWSER_MEMORY_TAB_MANAGER_WEB_CONTENTS_DATA_H_ 6 #define CHROME_BROWSER_MEMORY_TAB_MANAGER_WEB_CONTENTS_DATA_H_
7 7
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/time/time.h" 9 #include "base/time/time.h"
10 #include "chrome/browser/memory/tab_manager.h" 10 #include "chrome/browser/memory/tab_manager.h"
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 void SetLastInactiveTime(base::TimeTicks timestamp); 65 void SetLastInactiveTime(base::TimeTicks timestamp);
66 66
67 // Copies the discard state from |old_contents| to |new_contents|. 67 // Copies the discard state from |old_contents| to |new_contents|.
68 static void CopyState(content::WebContents* old_contents, 68 static void CopyState(content::WebContents* old_contents,
69 content::WebContents* new_contents); 69 content::WebContents* new_contents);
70 70
71 // Used to set the test TickClock, which then gets used by NowTicks(). See 71 // Used to set the test TickClock, which then gets used by NowTicks(). See
72 // |test_tick_clock_| for more details. 72 // |test_tick_clock_| for more details.
73 void set_test_tick_clock(base::TickClock* test_tick_clock); 73 void set_test_tick_clock(base::TickClock* test_tick_clock);
74 74
75 // Returns true if the tab is auto discardable by auto discarding feature.
Georges Khalil 2016/07/22 15:07:57 nit: comment change: Returns the auto discardable
Anderson Silva 2016/07/22 15:34:51 Done.
76 bool IsAutoDiscardable();
77
78 // Sets/clears the auto discardable state of the tab.
79 void SetAutoDiscardableState(bool state);
80
75 private: 81 private:
76 // Needed to access tab_data_. 82 // Needed to access tab_data_.
77 FRIEND_TEST_ALL_PREFIXES(TabManagerWebContentsDataTest, CopyState); 83 FRIEND_TEST_ALL_PREFIXES(TabManagerWebContentsDataTest, CopyState);
78 84
79 struct Data { 85 struct Data {
80 Data(); 86 Data();
81 bool operator==(const Data& right) const; 87 bool operator==(const Data& right) const;
82 bool operator!=(const Data& right) const; 88 bool operator!=(const Data& right) const;
83 89
84 // TODO(georgesak): fix naming (no underscore). 90 // TODO(georgesak): fix naming (no underscore).
85 // Is the tab currently discarded? 91 // Is the tab currently discarded?
86 bool is_discarded_; 92 bool is_discarded_;
87 // Number of times the tab has been discarded. 93 // Number of times the tab has been discarded.
88 int discard_count_; 94 int discard_count_;
89 // Is the tab playing audio? 95 // Is the tab playing audio?
90 bool is_recently_audible_; 96 bool is_recently_audible_;
91 // Last time the tab started or stopped playing audio (we record the 97 // Last time the tab started or stopped playing audio (we record the
92 // transition time). 98 // transition time).
93 base::TimeTicks last_audio_change_time_; 99 base::TimeTicks last_audio_change_time_;
94 // The last time the tab was discarded. 100 // The last time the tab was discarded.
95 base::TimeTicks last_discard_time_; 101 base::TimeTicks last_discard_time_;
96 // The last time the tab was reloaded after being discarded. 102 // The last time the tab was reloaded after being discarded.
97 base::TimeTicks last_reload_time_; 103 base::TimeTicks last_reload_time_;
98 // The last time the tab switched from being active to inactive. 104 // The last time the tab switched from being active to inactive.
99 base::TimeTicks last_inactive_time_; 105 base::TimeTicks last_inactive_time_;
100 // Site Engagement score (set to -1 if not available). 106 // Site Engagement score (set to -1 if not available).
101 double engagement_score_; 107 double engagement_score_;
108 // Is tab eligible for auto discarding by TabManager? Defaults to true.
Georges Khalil 2016/07/22 15:07:57 nit: remove "by TabManager".
Anderson Silva 2016/07/22 15:34:52 Done.
109 bool is_auto_discardable;
102 }; 110 };
103 111
104 // Returns either the system's clock or the test clock. See |test_tick_clock_| 112 // Returns either the system's clock or the test clock. See |test_tick_clock_|
105 // for more details. 113 // for more details.
106 base::TimeTicks NowTicks() const; 114 base::TimeTicks NowTicks() const;
107 115
108 // Contains all the needed data for the tab. 116 // Contains all the needed data for the tab.
109 Data tab_data_; 117 Data tab_data_;
110 118
111 // Pointer to a test clock. If this is set, NowTicks() returns the value of 119 // Pointer to a test clock. If this is set, NowTicks() returns the value of
112 // this test clock. Otherwise it returns the system clock's value. 120 // this test clock. Otherwise it returns the system clock's value.
113 base::TickClock* test_tick_clock_; 121 base::TickClock* test_tick_clock_;
114 122
115 DISALLOW_COPY_AND_ASSIGN(WebContentsData); 123 DISALLOW_COPY_AND_ASSIGN(WebContentsData);
116 }; 124 };
117 125
118 } // namespace memory 126 } // namespace memory
119 127
120 #endif // CHROME_BROWSER_MEMORY_TAB_MANAGER_WEB_CONTENTS_DATA_H_ 128 #endif // CHROME_BROWSER_MEMORY_TAB_MANAGER_WEB_CONTENTS_DATA_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698