Chromium Code Reviews| 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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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. | 75 // Returns the auto-discardable state of the tab. |
| 76 // See tab_manager.h for more information. | 76 // See tab_manager.h for more information. |
| 77 bool IsAutoDiscardable(); | 77 bool IsAutoDiscardable(); |
| 78 | 78 |
| 79 // Sets/clears the auto-discardable state of the tab. | 79 // Sets/clears the auto-discardable state of the tab. |
| 80 void SetAutoDiscardableState(bool state); | 80 void SetAutoDiscardableState(bool state); |
| 81 | 81 |
| 82 // Sets the current purge-and-suspend state, and update the timestamp, | 82 // Sets the current purge state. |
| 83 // i.e. the last purge-and-suspend modified time. | 83 // TODO(tasak): remove this after the logic is moved into |
| 84 // TODO(tasak): remove this after PurgeAndSuspend code is moved into | |
| 85 // MemoryCoordinator. | 84 // MemoryCoordinator. |
| 86 void SetPurgeAndSuspendState(TabManager::PurgeAndSuspendState state); | 85 void SetPurgeState(TabManager::PurgeState state); |
| 87 | 86 |
| 88 // Returns the last purge-and-suspend modified time. | 87 // Sets the time to first purge after the tab is backgrounded. |
| 89 // TODO(tasak): remove this after PurgeAndSuspend code is moved into | 88 void SetTimeToFirstPurge(const base::TimeDelta& time_to_first_purge); |
|
Wez
2017/02/27 22:20:56
since these are simple setter & getter, they can b
tasak
2017/02/28 09:45:40
Done.
| |
| 89 | |
| 90 // Returns the time to first purge after the tab is backgrounded. | |
| 91 base::TimeDelta TimeToFirstPurge() const; | |
| 92 | |
| 93 // Returns the current state of purge. | |
| 94 // TODO(tasak): remove this after the logic is moved into | |
| 90 // MemoryCoordinator. | 95 // MemoryCoordinator. |
| 91 base::TimeTicks LastPurgeAndSuspendModifiedTime() const; | 96 TabManager::PurgeState GetPurgeState() const; |
|
Wez
2017/02/27 22:20:56
Why not put the setter and getter for PurgeState n
tasak
2017/02/28 09:45:41
Done.
| |
| 92 | |
| 93 // Sets the timestamp of the last modified time the purge-and-suspend state | |
| 94 // of the tab was changed for testing. | |
| 95 void SetLastPurgeAndSuspendModifiedTimeForTesting(base::TimeTicks timestamp); | |
| 96 | |
| 97 // Returns the current state of purge-and-suspend. | |
| 98 // TODO(tasak): remove this after PurgeAndSuspend code is moved into | |
| 99 // MemoryCoordinator. | |
| 100 TabManager::PurgeAndSuspendState GetPurgeAndSuspendState() const; | |
| 101 | 97 |
| 102 private: | 98 private: |
| 103 // Needed to access tab_data_. | 99 // Needed to access tab_data_. |
| 104 FRIEND_TEST_ALL_PREFIXES(TabManagerWebContentsDataTest, CopyState); | 100 FRIEND_TEST_ALL_PREFIXES(TabManagerWebContentsDataTest, CopyState); |
| 105 | 101 |
| 106 struct Data { | 102 struct Data { |
| 107 Data(); | 103 Data(); |
| 108 bool operator==(const Data& right) const; | 104 bool operator==(const Data& right) const; |
| 109 bool operator!=(const Data& right) const; | 105 bool operator!=(const Data& right) const; |
| 110 | 106 |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 134 // for more details. | 130 // for more details. |
| 135 base::TimeTicks NowTicks() const; | 131 base::TimeTicks NowTicks() const; |
| 136 | 132 |
| 137 // Contains all the needed data for the tab. | 133 // Contains all the needed data for the tab. |
| 138 Data tab_data_; | 134 Data tab_data_; |
| 139 | 135 |
| 140 // Pointer to a test clock. If this is set, NowTicks() returns the value of | 136 // Pointer to a test clock. If this is set, NowTicks() returns the value of |
| 141 // this test clock. Otherwise it returns the system clock's value. | 137 // this test clock. Otherwise it returns the system clock's value. |
| 142 base::TickClock* test_tick_clock_; | 138 base::TickClock* test_tick_clock_; |
| 143 | 139 |
| 144 // The last time purge-and-suspend state was modified. | 140 // The time to first purge after the tab is backgrounded. |
| 145 base::TimeTicks last_purge_and_suspend_modified_time_; | 141 base::TimeDelta time_to_first_purge_; |
| 146 | 142 |
| 147 // The current state of purge-and-suspend. | 143 // The current state of purge. |
| 148 PurgeAndSuspendState purge_and_suspend_state_; | 144 PurgeState purge_state_; |
|
Wez
2017/02/27 22:20:56
Putting these fields here, rather than in tab_data
tasak
2017/02/28 09:45:42
Done.
| |
| 149 | 145 |
| 150 DISALLOW_COPY_AND_ASSIGN(WebContentsData); | 146 DISALLOW_COPY_AND_ASSIGN(WebContentsData); |
| 151 }; | 147 }; |
| 152 | 148 |
| 153 } // namespace memory | 149 } // namespace memory |
| 154 | 150 |
| 155 #endif // CHROME_BROWSER_MEMORY_TAB_MANAGER_WEB_CONTENTS_DATA_H_ | 151 #endif // CHROME_BROWSER_MEMORY_TAB_MANAGER_WEB_CONTENTS_DATA_H_ |
| OLD | NEW |