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

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

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

Powered by Google App Engine
This is Rietveld 408576698