| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_STORAGE_MANAGER_H_ | 5 #ifndef COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_STORAGE_MANAGER_H_ |
| 6 #define COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_STORAGE_MANAGER_H_ | 6 #define COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_STORAGE_MANAGER_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/callback.h" | 12 #include "base/callback.h" |
| 13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
| 15 #include "base/time/time.h" | 15 #include "base/time/time.h" |
| 16 #include "components/offline_pages/archive_manager.h" | 16 #include "components/offline_pages/archive_manager.h" |
| 17 #include "components/offline_pages/offline_page_types.h" | 17 #include "components/offline_pages/offline_page_types.h" |
| 18 | 18 |
| 19 namespace base { | 19 namespace base { |
| 20 class Clock; | 20 class Clock; |
| 21 } // namespace base | 21 } // namespace base |
| 22 | 22 |
| 23 namespace offline_pages { | 23 namespace offline_pages { |
| 24 | 24 |
| 25 // Maximum % of total available storage that will be occupied by offline pages | 25 // Maximum % of total available storage that will be occupied by offline pages |
| 26 // before a storage clearup. | 26 // before a storage clearup. |
| 27 const double kOfflinePageStorageLimit = 0.3; | 27 struct constants { |
| 28 // The target % of storage usage we try to reach below when expiring pages. | 28 static constexpr double kOfflinePageStorageLimit = 0.3; |
| 29 const double kOfflinePageStorageClearThreshold = 0.1; | 29 // The target % of storage usage we try to reach below when expiring pages. |
| 30 // The time that the storage cleanup will be triggered again since the last one. | 30 static constexpr double kOfflinePageStorageClearThreshold = 0.1; |
| 31 const base::TimeDelta kClearStorageInterval = base::TimeDelta::FromMinutes(10); | 31 // The time that the storage cleanup will be triggered again since the last |
| 32 // The time that the page record will be removed from the store since the page | 32 // one. |
| 33 // has been expired. | 33 static constexpr base::TimeDelta kClearStorageInterval = |
| 34 const base::TimeDelta kRemovePageItemInterval = base::TimeDelta::FromDays(21); | 34 base::TimeDelta::FromMinutes(10); |
| 35 // The time that the page record will be removed from the store since the page |
| 36 // has been expired. |
| 37 static constexpr base::TimeDelta kRemovePageItemInterval = |
| 38 base::TimeDelta::FromDays(21); |
| 39 }; |
| 35 | 40 |
| 36 class ClientPolicyController; | 41 class ClientPolicyController; |
| 37 class OfflinePageModel; | 42 class OfflinePageModel; |
| 38 | 43 |
| 39 // This class is used for storage management of offline pages. It provides | 44 // This class is used for storage management of offline pages. It provides |
| 40 // a ClearPagesIfNeeded method which is used to clear expired offline pages | 45 // a ClearPagesIfNeeded method which is used to clear expired offline pages |
| 41 // based on last_access_time and lifetime policy of its namespace. | 46 // based on last_access_time and lifetime policy of its namespace. |
| 42 // It has its own throttle mechanism so calling the method would not be | 47 // It has its own throttle mechanism so calling the method would not be |
| 43 // guaranteed to clear the pages immediately. | 48 // guaranteed to clear the pages immediately. |
| 44 // | 49 // |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 std::unique_ptr<base::Clock> clock_; | 156 std::unique_ptr<base::Clock> clock_; |
| 152 | 157 |
| 153 base::WeakPtrFactory<OfflinePageStorageManager> weak_ptr_factory_; | 158 base::WeakPtrFactory<OfflinePageStorageManager> weak_ptr_factory_; |
| 154 | 159 |
| 155 DISALLOW_COPY_AND_ASSIGN(OfflinePageStorageManager); | 160 DISALLOW_COPY_AND_ASSIGN(OfflinePageStorageManager); |
| 156 }; | 161 }; |
| 157 | 162 |
| 158 } // namespace offline_pages | 163 } // namespace offline_pages |
| 159 | 164 |
| 160 #endif // COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_STORAGE_MANAGER_H_ | 165 #endif // COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_STORAGE_MANAGER_H_ |
| OLD | NEW |