| 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, |
| 83 // i.e. the last purge-and-suspend modified time. |
| 84 // TODO(tasak): remove this after PurgeAndSuspend code is moved into |
| 85 // MemoryCoordinator. |
| 86 void SetPurgeAndSuspendState(TabManager::PurgeAndSuspendState state); |
| 87 |
| 88 // Returns the last purge-and-suspend modified time. |
| 89 // TODO(tasak): remove this after PurgeAndSuspend code is moved into |
| 90 // MemoryCoordinator. |
| 91 base::TimeTicks LastPurgeAndSuspendModifiedTime() const; |
| 92 |
| 93 // Returns the current state of purge-and-suspend. |
| 94 // TODO(tasak): remove this after PurgeAndSuspend code is moved into |
| 95 // MemoryCoordinator. |
| 96 TabManager::PurgeAndSuspendState GetPurgeAndSuspendState() const; |
| 97 |
| 82 private: | 98 private: |
| 83 // Needed to access tab_data_. | 99 // Needed to access tab_data_. |
| 84 FRIEND_TEST_ALL_PREFIXES(TabManagerWebContentsDataTest, CopyState); | 100 FRIEND_TEST_ALL_PREFIXES(TabManagerWebContentsDataTest, CopyState); |
| 85 | 101 |
| 86 struct Data { | 102 struct Data { |
| 87 Data(); | 103 Data(); |
| 88 bool operator==(const Data& right) const; | 104 bool operator==(const Data& right) const; |
| 89 bool operator!=(const Data& right) const; | 105 bool operator!=(const Data& right) const; |
| 90 | 106 |
| 91 // TODO(georgesak): fix naming (no underscore). | 107 // TODO(georgesak): fix naming (no underscore). |
| (...skipping 22 matching lines...) Expand all Loading... |
| 114 // for more details. | 130 // for more details. |
| 115 base::TimeTicks NowTicks() const; | 131 base::TimeTicks NowTicks() const; |
| 116 | 132 |
| 117 // Contains all the needed data for the tab. | 133 // Contains all the needed data for the tab. |
| 118 Data tab_data_; | 134 Data tab_data_; |
| 119 | 135 |
| 120 // 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 |
| 121 // this test clock. Otherwise it returns the system clock's value. | 137 // this test clock. Otherwise it returns the system clock's value. |
| 122 base::TickClock* test_tick_clock_; | 138 base::TickClock* test_tick_clock_; |
| 123 | 139 |
| 140 // The last time purge-and-suspend state was modified. |
| 141 base::TimeTicks last_purge_and_suspend_modified_time_; |
| 142 |
| 143 // The current state of purge-and-suspend. |
| 144 PurgeAndSuspendState purge_and_suspend_state_; |
| 145 |
| 124 DISALLOW_COPY_AND_ASSIGN(WebContentsData); | 146 DISALLOW_COPY_AND_ASSIGN(WebContentsData); |
| 125 }; | 147 }; |
| 126 | 148 |
| 127 } // namespace memory | 149 } // namespace memory |
| 128 | 150 |
| 129 #endif // CHROME_BROWSER_MEMORY_TAB_MANAGER_WEB_CONTENTS_DATA_H_ | 151 #endif // CHROME_BROWSER_MEMORY_TAB_MANAGER_WEB_CONTENTS_DATA_H_ |
| OLD | NEW |