| OLD | NEW |
| 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 Loading... |
| 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 the auto discardable state of the tab. |
| 76 // See tab_manager.h for more information. |
| 77 bool IsAutoDiscardable(); |
| 78 |
| 79 // Sets/clears the auto discardable state of the tab. |
| 80 void SetAutoDiscardableState(bool state); |
| 81 |
| 75 private: | 82 private: |
| 76 // Needed to access tab_data_. | 83 // Needed to access tab_data_. |
| 77 FRIEND_TEST_ALL_PREFIXES(TabManagerWebContentsDataTest, CopyState); | 84 FRIEND_TEST_ALL_PREFIXES(TabManagerWebContentsDataTest, CopyState); |
| 78 | 85 |
| 79 struct Data { | 86 struct Data { |
| 80 Data(); | 87 Data(); |
| 81 bool operator==(const Data& right) const; | 88 bool operator==(const Data& right) const; |
| 82 bool operator!=(const Data& right) const; | 89 bool operator!=(const Data& right) const; |
| 83 | 90 |
| 84 // TODO(georgesak): fix naming (no underscore). | 91 // TODO(georgesak): fix naming (no underscore). |
| 85 // Is the tab currently discarded? | 92 // Is the tab currently discarded? |
| 86 bool is_discarded_; | 93 bool is_discarded_; |
| 87 // Number of times the tab has been discarded. | 94 // Number of times the tab has been discarded. |
| 88 int discard_count_; | 95 int discard_count_; |
| 89 // Is the tab playing audio? | 96 // Is the tab playing audio? |
| 90 bool is_recently_audible_; | 97 bool is_recently_audible_; |
| 91 // Last time the tab started or stopped playing audio (we record the | 98 // Last time the tab started or stopped playing audio (we record the |
| 92 // transition time). | 99 // transition time). |
| 93 base::TimeTicks last_audio_change_time_; | 100 base::TimeTicks last_audio_change_time_; |
| 94 // The last time the tab was discarded. | 101 // The last time the tab was discarded. |
| 95 base::TimeTicks last_discard_time_; | 102 base::TimeTicks last_discard_time_; |
| 96 // The last time the tab was reloaded after being discarded. | 103 // The last time the tab was reloaded after being discarded. |
| 97 base::TimeTicks last_reload_time_; | 104 base::TimeTicks last_reload_time_; |
| 98 // The last time the tab switched from being active to inactive. | 105 // The last time the tab switched from being active to inactive. |
| 99 base::TimeTicks last_inactive_time_; | 106 base::TimeTicks last_inactive_time_; |
| 100 // Site Engagement score (set to -1 if not available). | 107 // Site Engagement score (set to -1 if not available). |
| 101 double engagement_score_; | 108 double engagement_score_; |
| 109 // Is tab eligible for auto discarding? Defaults to true. |
| 110 bool is_auto_discardable; |
| 102 }; | 111 }; |
| 103 | 112 |
| 104 // Returns either the system's clock or the test clock. See |test_tick_clock_| | 113 // Returns either the system's clock or the test clock. See |test_tick_clock_| |
| 105 // for more details. | 114 // for more details. |
| 106 base::TimeTicks NowTicks() const; | 115 base::TimeTicks NowTicks() const; |
| 107 | 116 |
| 108 // Contains all the needed data for the tab. | 117 // Contains all the needed data for the tab. |
| 109 Data tab_data_; | 118 Data tab_data_; |
| 110 | 119 |
| 111 // Pointer to a test clock. If this is set, NowTicks() returns the value of | 120 // 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. | 121 // this test clock. Otherwise it returns the system clock's value. |
| 113 base::TickClock* test_tick_clock_; | 122 base::TickClock* test_tick_clock_; |
| 114 | 123 |
| 115 DISALLOW_COPY_AND_ASSIGN(WebContentsData); | 124 DISALLOW_COPY_AND_ASSIGN(WebContentsData); |
| 116 }; | 125 }; |
| 117 | 126 |
| 118 } // namespace memory | 127 } // namespace memory |
| 119 | 128 |
| 120 #endif // CHROME_BROWSER_MEMORY_TAB_MANAGER_WEB_CONTENTS_DATA_H_ | 129 #endif // CHROME_BROWSER_MEMORY_TAB_MANAGER_WEB_CONTENTS_DATA_H_ |
| OLD | NEW |