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_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 Loading... | |
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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
191 std::unique_ptr<OfflinePagesUpdateResult> result); | 186 std::unique_ptr<OfflinePagesUpdateResult> result); |
192 void InformDeletePageDone(const DeletePageCallback& callback, | 187 void InformDeletePageDone(const DeletePageCallback& callback, |
193 DeletePageResult result); | 188 DeletePageResult result); |
194 | 189 |
195 void OnMarkPageAccesseDone(const OfflinePageItem& offline_page_item, | 190 void OnMarkPageAccesseDone(const OfflinePageItem& offline_page_item, |
196 std::unique_ptr<OfflinePagesUpdateResult> result); | 191 std::unique_ptr<OfflinePagesUpdateResult> result); |
197 | 192 |
198 // Callbacks for checking metadata consistency. | 193 // Callbacks for checking metadata consistency. |
199 void CheckMetadataConsistencyForArchivePaths( | 194 void CheckMetadataConsistencyForArchivePaths( |
200 const std::set<base::FilePath>& archive_paths); | 195 const std::set<base::FilePath>& archive_paths); |
201 // Callback called after headless archives deleted. Orphaned archives are | 196 // Callbacks called after orphaned archives deleted. Orphaned archives are |
fgorski
2016/11/22 00:03:00
nit: archives *are* deleted. since you are fixing
romax
2016/11/23 23:32:03
Done.
| |
202 // archives files on disk which are not pointed to by any of the page items | 197 // archives files on disk which are not pointed to by any of the page items |
203 // in metadata store. | 198 // in metadata store. |
204 void ExpirePagesMissingArchiveFile( | 199 void DeletePagesMissingArchiveFile( |
205 const std::set<base::FilePath>& archive_paths); | 200 const std::set<base::FilePath>& archive_paths); |
206 void OnExpirePagesMissingArchiveFileDone( | 201 void OnDeletePagesMissingArchiveFileDone( |
207 const std::vector<int64_t>& offline_ids, | 202 const std::vector<int64_t>& offline_ids, |
208 bool success); | 203 DeletePageResult result); |
209 void DeleteOrphanedArchives(const std::set<base::FilePath>& archive_paths); | 204 void DeleteOrphanedArchives(const std::set<base::FilePath>& archive_paths); |
210 void OnDeleteOrphanedArchivesDone(const std::vector<base::FilePath>& archives, | 205 void OnDeleteOrphanedArchivesDone(const std::vector<base::FilePath>& archives, |
211 bool success); | 206 bool success); |
212 | 207 |
213 // Callbacks for deleting pages with same URL when saving pages. | 208 // Callbacks for deleting pages with same URL when saving pages. |
214 void DeleteExistingPagesWithSameURL(const OfflinePageItem& offline_page); | 209 void DeleteExistingPagesWithSameURL(const OfflinePageItem& offline_page); |
215 void OnPagesFoundWithSameURL(const OfflinePageItem& offline_page, | 210 void OnPagesFoundWithSameURL(const OfflinePageItem& offline_page, |
216 size_t pages_allowed, | 211 size_t pages_allowed, |
217 const MultipleOfflinePageItemResult& items); | 212 const MultipleOfflinePageItemResult& items); |
218 void OnDeleteOldPagesWithSameURL(DeletePageResult result); | 213 void OnDeleteOldPagesWithSameURL(DeletePageResult result); |
219 | 214 |
220 void CacheLoadedData(const std::vector<OfflinePageItem>& offline_pages); | 215 void CacheLoadedData(const std::vector<OfflinePageItem>& offline_pages); |
221 | 216 |
222 // Actually does the work of deleting, requires the model is loaded. | 217 // Actually does the work of deleting, requires the model is loaded. |
223 void DoDeletePagesByOfflineId(const std::vector<int64_t>& offline_ids, | 218 void DoDeletePagesByOfflineId(const std::vector<int64_t>& offline_ids, |
224 const DeletePageCallback& callback); | 219 const DeletePageCallback& callback); |
225 | 220 |
226 // Actually does the work of deleting, requires the model is loaded. | 221 // Actually does the work of deleting, requires the model is loaded. |
227 void DeletePages(const DeletePageCallback& callback, | 222 void DeletePages(const DeletePageCallback& callback, |
228 const MultipleOfflinePageItemResult& items); | 223 const MultipleOfflinePageItemResult& items); |
229 | 224 |
230 void DoGetPagesByClientIds(const std::vector<ClientId>& client_ids, | 225 void DoGetPagesByClientIds(const std::vector<ClientId>& client_ids, |
231 const MultipleOfflinePageItemCallback& callback); | 226 const MultipleOfflinePageItemCallback& callback); |
232 | 227 |
233 // Similar to DoDeletePagesByOfflineId, does actual work of deleting, and | 228 // Similar to DoDeletePagesByOfflineId, does actual work of deleting, and |
234 // requires that the model is loaded. | 229 // requires that the model is loaded. |
235 void DoDeleteCachedPagesByURLPredicate(const UrlPredicate& predicate, | 230 void DoDeleteCachedPagesByURLPredicate(const UrlPredicate& predicate, |
236 const DeletePageCallback& callback); | 231 const DeletePageCallback& callback); |
237 | 232 |
238 // Callback completing page expiration. | 233 // 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( | 234 void ClearStorageIfNeeded( |
244 const OfflinePageStorageManager::ClearStorageCallback& callback); | 235 const OfflinePageStorageManager::ClearStorageCallback& callback); |
245 | 236 |
246 // Callback completing storage clearing. | 237 // Callback completing storage clearing. |
247 void OnStorageCleared(size_t expired_page_count, | 238 void OnStorageCleared(size_t cleared_page_count, |
248 OfflinePageStorageManager::ClearStorageResult result); | 239 OfflinePageStorageManager::ClearStorageResult result); |
249 | 240 |
250 // Post task to clear storage. | 241 // Post task to clear storage. |
251 void PostClearStorageIfNeededTask(bool delayed); | 242 void PostClearStorageIfNeededTask(bool delayed); |
252 | 243 |
253 // Check if |offline_page| should be removed on cache reset by user. | 244 // Check if |offline_page| should be removed on cache reset by user. |
254 bool IsRemovedOnCacheReset(const OfflinePageItem& offline_page) const; | 245 bool IsRemovedOnCacheReset(const OfflinePageItem& offline_page) const; |
255 | 246 |
256 void RunWhenLoaded(const base::Closure& job); | 247 void RunWhenLoaded(const base::Closure& job); |
257 | 248 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
295 base::Clock* testing_clock_; | 286 base::Clock* testing_clock_; |
296 | 287 |
297 base::WeakPtrFactory<OfflinePageModelImpl> weak_ptr_factory_; | 288 base::WeakPtrFactory<OfflinePageModelImpl> weak_ptr_factory_; |
298 | 289 |
299 DISALLOW_COPY_AND_ASSIGN(OfflinePageModelImpl); | 290 DISALLOW_COPY_AND_ASSIGN(OfflinePageModelImpl); |
300 }; | 291 }; |
301 | 292 |
302 } // namespace offline_pages | 293 } // namespace offline_pages |
303 | 294 |
304 #endif // COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_MODEL_IMPL_H_ | 295 #endif // COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_MODEL_IMPL_H_ |
OLD | NEW |