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

Side by Side Diff: components/offline_pages/offline_page_model_impl.h

Issue 2512073002: [Offline Pages] Removes two-step expiration related. (Closed)
Patch Set: Addressed comments. Created 4 years 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 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_MODEL_IMPL_H_ 5 #ifndef COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_MODEL_IMPL_H_
6 #define COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_MODEL_IMPL_H_ 6 #define COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_MODEL_IMPL_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <map> 10 #include <map>
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 const std::vector<ClientId>& client_ids, 83 const std::vector<ClientId>& client_ids,
84 const MultipleOfflinePageItemCallback& callback) override; 84 const MultipleOfflinePageItemCallback& callback) override;
85 85
86 void DeleteCachedPagesByURLPredicate( 86 void DeleteCachedPagesByURLPredicate(
87 const UrlPredicate& predicate, 87 const UrlPredicate& predicate,
88 const DeletePageCallback& callback) override; 88 const DeletePageCallback& callback) override;
89 void CheckPagesExistOffline( 89 void CheckPagesExistOffline(
90 const std::set<GURL>& urls, 90 const std::set<GURL>& urls,
91 const CheckPagesExistOfflineCallback& callback) override; 91 const CheckPagesExistOfflineCallback& callback) override;
92 void GetAllPages(const MultipleOfflinePageItemCallback& callback) override; 92 void GetAllPages(const MultipleOfflinePageItemCallback& callback) override;
93 void GetAllPagesWithExpired(
94 const MultipleOfflinePageItemCallback& callback) override;
95 void GetOfflineIdsForClientId( 93 void GetOfflineIdsForClientId(
96 const ClientId& client_id, 94 const ClientId& client_id,
97 const MultipleOfflineIdCallback& callback) override; 95 const MultipleOfflineIdCallback& callback) override;
98 void GetPageByOfflineId( 96 void GetPageByOfflineId(
99 int64_t offline_id, 97 int64_t offline_id,
100 const SingleOfflinePageItemCallback& callback) override; 98 const SingleOfflinePageItemCallback& callback) override;
101 void GetPagesByURL( 99 void GetPagesByURL(
102 const GURL& url, 100 const GURL& url,
103 URLSearchMode url_search_mode, 101 URLSearchMode url_search_mode,
104 const MultipleOfflinePageItemCallback& callback) override; 102 const MultipleOfflinePageItemCallback& callback) override;
105 void ExpirePages(const std::vector<int64_t>& offline_ids,
106 const base::Time& expiration_time,
107 const base::Callback<void(bool)>& callback) override;
108 ClientPolicyController* GetPolicyController() override; 103 ClientPolicyController* GetPolicyController() override;
109 104
110 // Methods for testing only: 105 // Methods for testing only:
111 OfflinePageMetadataStore* GetStoreForTesting(); 106 OfflinePageMetadataStore* GetStoreForTesting();
112 void set_testing_clock(base::Clock* clock) { testing_clock_ = clock; } 107 void set_testing_clock(base::Clock* clock) { testing_clock_ = clock; }
113 108
114 OfflinePageStorageManager* GetStorageManager(); 109 OfflinePageStorageManager* GetStorageManager();
115 110
116 bool is_loaded() const override; 111 bool is_loaded() const override;
117 112
(...skipping 22 matching lines...) Expand all
140 int64_t offline_id, 135 int64_t offline_id,
141 const SingleOfflinePageItemCallback& callback) const; 136 const SingleOfflinePageItemCallback& callback) const;
142 const std::vector<int64_t> MaybeGetOfflineIdsForClientId( 137 const std::vector<int64_t> MaybeGetOfflineIdsForClientId(
143 const ClientId& client_id) const; 138 const ClientId& client_id) const;
144 void GetPagesByURLWhenLoadDone( 139 void GetPagesByURLWhenLoadDone(
145 const GURL& url, 140 const GURL& url,
146 URLSearchMode url_search_mode, 141 URLSearchMode url_search_mode,
147 const MultipleOfflinePageItemCallback& callback) const; 142 const MultipleOfflinePageItemCallback& callback) const;
148 void MarkPageAccessedWhenLoadDone(int64_t offline_id); 143 void MarkPageAccessedWhenLoadDone(int64_t offline_id);
149 144
145 // Check the consistency between metadata store and archives on disk,
146 // would delete the metadata entries which don't have an associated
147 // archive and the archives which doesn't have a metadata in the store.
148 // The expired pages (from previous versions) would also be cleared
149 // during this process.
150 void CheckMetadataConsistency(); 150 void CheckMetadataConsistency();
151 151
152 // Callback for loading pages from the offline page metadata store. 152 // Callback for loading pages from the offline page metadata store.
153 void OnStoreInitialized(const base::TimeTicks& start_time, 153 void OnStoreInitialized(const base::TimeTicks& start_time,
154 int reset_attempts_left, 154 int reset_attempts_left,
155 bool success); 155 bool success);
156 void OnStoreResetDone(const base::TimeTicks& start_time, 156 void OnStoreResetDone(const base::TimeTicks& start_time,
157 int reset_attempts_left, 157 int reset_attempts_left,
158 bool success); 158 bool success);
159 void OnInitialGetOfflinePagesDone( 159 void OnInitialGetOfflinePagesDone(
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 std::unique_ptr<OfflinePagesUpdateResult> result); 191 std::unique_ptr<OfflinePagesUpdateResult> result);
192 void InformDeletePageDone(const DeletePageCallback& callback, 192 void InformDeletePageDone(const DeletePageCallback& callback,
193 DeletePageResult result); 193 DeletePageResult result);
194 194
195 void OnMarkPageAccesseDone(const OfflinePageItem& offline_page_item, 195 void OnMarkPageAccesseDone(const OfflinePageItem& offline_page_item,
196 std::unique_ptr<OfflinePagesUpdateResult> result); 196 std::unique_ptr<OfflinePagesUpdateResult> result);
197 197
198 // Callbacks for checking metadata consistency. 198 // Callbacks for checking metadata consistency.
199 void CheckMetadataConsistencyForArchivePaths( 199 void CheckMetadataConsistencyForArchivePaths(
200 const std::set<base::FilePath>& archive_paths); 200 const std::set<base::FilePath>& archive_paths);
201 // Callback called after headless archives deleted. Orphaned archives are 201 // Callbacks which would be called after orphaned archives are deleted.
202 // archives files on disk which are not pointed to by any of the page items 202 // Orphaned archives are the files on disk which are not pointed to by any of
203 // in metadata store. 203 // the page entries in the metadata store.
204 void ExpirePagesMissingArchiveFile( 204 void DeletePagesMissingArchiveFile(
205 const std::set<base::FilePath>& archive_paths); 205 const std::set<base::FilePath>& archive_paths);
206 void OnExpirePagesMissingArchiveFileDone( 206 void OnDeletePagesMissingArchiveFileDone(
207 const std::vector<int64_t>& offline_ids, 207 const std::vector<int64_t>& offline_ids,
208 bool success); 208 DeletePageResult result);
209 void DeleteOrphanedArchives(const std::set<base::FilePath>& archive_paths); 209 void DeleteOrphanedArchives(const std::set<base::FilePath>& archive_paths);
210 void OnDeleteOrphanedArchivesDone(const std::vector<base::FilePath>& archives, 210 void OnDeleteOrphanedArchivesDone(const std::vector<base::FilePath>& archives,
211 bool success); 211 bool success);
212 212
213 // Callbacks for deleting pages with same URL when saving pages. 213 // Callbacks for deleting pages with same URL when saving pages.
214 void DeleteExistingPagesWithSameURL(const OfflinePageItem& offline_page); 214 void DeleteExistingPagesWithSameURL(const OfflinePageItem& offline_page);
215 void OnPagesFoundWithSameURL(const OfflinePageItem& offline_page, 215 void OnPagesFoundWithSameURL(const OfflinePageItem& offline_page,
216 size_t pages_allowed, 216 size_t pages_allowed,
217 const MultipleOfflinePageItemResult& items); 217 const MultipleOfflinePageItemResult& items);
218 void OnDeleteOldPagesWithSameURL(DeletePageResult result); 218 void OnDeleteOldPagesWithSameURL(DeletePageResult result);
219 219
220 void CacheLoadedData(const std::vector<OfflinePageItem>& offline_pages); 220 void CacheLoadedData(const std::vector<OfflinePageItem>& offline_pages);
221 221
222 // Actually does the work of deleting, requires the model is loaded. 222 // Actually does the work of deleting, requires the model is loaded.
223 void DoDeletePagesByOfflineId(const std::vector<int64_t>& offline_ids, 223 void DoDeletePagesByOfflineId(const std::vector<int64_t>& offline_ids,
224 const DeletePageCallback& callback); 224 const DeletePageCallback& callback);
225 225
226 // Actually does the work of deleting, requires the model is loaded. 226 // Actually does the work of deleting, requires the model is loaded.
227 void DeletePages(const DeletePageCallback& callback, 227 void DeletePages(const DeletePageCallback& callback,
228 const MultipleOfflinePageItemResult& items); 228 const MultipleOfflinePageItemResult& items);
229 229
230 void DoGetPagesByClientIds(const std::vector<ClientId>& client_ids, 230 void DoGetPagesByClientIds(const std::vector<ClientId>& client_ids,
231 const MultipleOfflinePageItemCallback& callback); 231 const MultipleOfflinePageItemCallback& callback);
232 232
233 // Similar to DoDeletePagesByOfflineId, does actual work of deleting, and 233 // Similar to DoDeletePagesByOfflineId, does actual work of deleting, and
234 // requires that the model is loaded. 234 // requires that the model is loaded.
235 void DoDeleteCachedPagesByURLPredicate(const UrlPredicate& predicate, 235 void DoDeleteCachedPagesByURLPredicate(const UrlPredicate& predicate,
236 const DeletePageCallback& callback); 236 const DeletePageCallback& callback);
237 237
238 // Callback completing page expiration. 238 // Clears expired pages if there are any or we're running out of storage.
239 void OnExpirePageDone(const base::Time& expiration_time,
240 std::unique_ptr<OfflinePagesUpdateResult> result);
241
242 // Clears expired pages if there are any.
243 void ClearStorageIfNeeded( 239 void ClearStorageIfNeeded(
244 const OfflinePageStorageManager::ClearStorageCallback& callback); 240 const OfflinePageStorageManager::ClearStorageCallback& callback);
245 241
246 // Callback completing storage clearing. 242 // Callback completing storage clearing.
247 void OnStorageCleared(size_t expired_page_count, 243 void OnStorageCleared(size_t cleared_page_count,
248 OfflinePageStorageManager::ClearStorageResult result); 244 OfflinePageStorageManager::ClearStorageResult result);
249 245
250 // Post task to clear storage. 246 // Post task to clear storage.
251 void PostClearStorageIfNeededTask(bool delayed); 247 void PostClearStorageIfNeededTask(bool delayed);
252 248
253 // Check if |offline_page| should be removed on cache reset by user. 249 // Check if |offline_page| should be removed on cache reset by user.
254 bool IsRemovedOnCacheReset(const OfflinePageItem& offline_page) const; 250 bool IsRemovedOnCacheReset(const OfflinePageItem& offline_page) const;
255 251
256 void RunWhenLoaded(const base::Closure& job); 252 void RunWhenLoaded(const base::Closure& job);
257 253
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 base::Clock* testing_clock_; 291 base::Clock* testing_clock_;
296 292
297 base::WeakPtrFactory<OfflinePageModelImpl> weak_ptr_factory_; 293 base::WeakPtrFactory<OfflinePageModelImpl> weak_ptr_factory_;
298 294
299 DISALLOW_COPY_AND_ASSIGN(OfflinePageModelImpl); 295 DISALLOW_COPY_AND_ASSIGN(OfflinePageModelImpl);
300 }; 296 };
301 297
302 } // namespace offline_pages 298 } // namespace offline_pages
303 299
304 #endif // COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_MODEL_IMPL_H_ 300 #endif // COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_MODEL_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698