| 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 COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_MODEL_H_ | 5 #ifndef COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_MODEL_H_ |
| 6 #define COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_MODEL_H_ | 6 #define COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_MODEL_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 void SavePage(const GURL& url, | 151 void SavePage(const GURL& url, |
| 152 const ClientId& client_id, | 152 const ClientId& client_id, |
| 153 scoped_ptr<OfflinePageArchiver> archiver, | 153 scoped_ptr<OfflinePageArchiver> archiver, |
| 154 const SavePageCallback& callback); | 154 const SavePageCallback& callback); |
| 155 | 155 |
| 156 // Marks that the offline page related to the passed |offline_id| has been | 156 // Marks that the offline page related to the passed |offline_id| has been |
| 157 // accessed. Its access info, including last access time and access count, | 157 // accessed. Its access info, including last access time and access count, |
| 158 // will be updated. Requires that the model is loaded. | 158 // will be updated. Requires that the model is loaded. |
| 159 void MarkPageAccessed(int64_t offline_id); | 159 void MarkPageAccessed(int64_t offline_id); |
| 160 | 160 |
| 161 // Marks that the offline page related to the passed |offline_id| was going | |
| 162 // to be deleted. The deletion will occur in a short while. The undo can be | |
| 163 // done before this. Requires that the model is loaded. | |
| 164 void MarkPageForDeletion(int64_t offline_id, | |
| 165 const DeletePageCallback& callback); | |
| 166 | |
| 167 // Deletes an offline page related to the passed |offline_id|. | 161 // Deletes an offline page related to the passed |offline_id|. |
| 168 void DeletePageByOfflineId(int64_t offline_id, | 162 void DeletePageByOfflineId(int64_t offline_id, |
| 169 const DeletePageCallback& callback); | 163 const DeletePageCallback& callback); |
| 170 | 164 |
| 171 // Deletes offline pages related to the passed |offline_ids|. | 165 // Deletes offline pages related to the passed |offline_ids|. |
| 172 void DeletePagesByOfflineId(const std::vector<int64_t>& offline_ids, | 166 void DeletePagesByOfflineId(const std::vector<int64_t>& offline_ids, |
| 173 const DeletePageCallback& callback); | 167 const DeletePageCallback& callback); |
| 174 | 168 |
| 175 // Marks pages for deletion. Actual delete is asynchronous. | |
| 176 // Works even if the model isn't loaded. | |
| 177 void MarkPagesForDeletion(const std::vector<int64_t>& offline_ids, | |
| 178 const DeletePageCallback& callback); | |
| 179 | |
| 180 // Wipes out all the data by deleting all saved files and clearing the store. | 169 // Wipes out all the data by deleting all saved files and clearing the store. |
| 181 void ClearAll(const base::Closure& callback); | 170 void ClearAll(const base::Closure& callback); |
| 182 | 171 |
| 183 // Deletes offline pages matching the URL predicate. | 172 // Deletes offline pages matching the URL predicate. |
| 184 void DeletePagesByURLPredicate( | 173 void DeletePagesByURLPredicate( |
| 185 const base::Callback<bool(const GURL&)>& predicate, | 174 const base::Callback<bool(const GURL&)>& predicate, |
| 186 const DeletePageCallback& callback); | 175 const DeletePageCallback& callback); |
| 187 | 176 |
| 188 // Returns true if there are offline pages in the given |name_space|. This | 177 // Returns true if there are offline pages in the given |name_space|. This |
| 189 // method is sync, so the result can be wrong depending on implementation | 178 // method is sync, so the result can be wrong depending on implementation |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 // pages. Method is to be called after a page was saved or some pages are | 223 // pages. Method is to be called after a page was saved or some pages are |
| 235 // deleted. In the latter case |reporting_after_delete| is set to true. | 224 // deleted. In the latter case |reporting_after_delete| is set to true. |
| 236 // Caller is supposed to provide the current |total_space_bytes| on drive | 225 // Caller is supposed to provide the current |total_space_bytes| on drive |
| 237 // where the pages are stored, as well as |free_space_bytes| after the | 226 // where the pages are stored, as well as |free_space_bytes| after the |
| 238 // operation was taken. The method will report total size of all pages, and | 227 // operation was taken. The method will report total size of all pages, and |
| 239 // percentage of size of pages as compared to total space and free space. | 228 // percentage of size of pages as compared to total space and free space. |
| 240 void RecordStorageHistograms(int64_t total_space_bytes, | 229 void RecordStorageHistograms(int64_t total_space_bytes, |
| 241 int64_t free_space_bytes, | 230 int64_t free_space_bytes, |
| 242 bool reporting_after_delete); | 231 bool reporting_after_delete); |
| 243 | 232 |
| 244 // Undo a deletion of a page. Pages that are marked for deletion can | |
| 245 // be restored prior to when they are actually deleted. | |
| 246 void UndoPageDeletion(int64_t offline_id); | |
| 247 | |
| 248 // Methods for testing only: | 233 // Methods for testing only: |
| 249 OfflinePageMetadataStore* GetStoreForTesting(); | 234 OfflinePageMetadataStore* GetStoreForTesting(); |
| 250 | 235 |
| 251 bool is_loaded() const { return is_loaded_; } | 236 bool is_loaded() const { return is_loaded_; } |
| 252 | 237 |
| 253 private: | 238 private: |
| 254 FRIEND_TEST_ALL_PREFIXES(OfflinePageModelTest, MarkPageForDeletion); | 239 FRIEND_TEST_ALL_PREFIXES(OfflinePageModelTest, MarkPageForDeletion); |
| 255 | 240 |
| 256 typedef ScopedVector<OfflinePageArchiver> PendingArchivers; | 241 typedef ScopedVector<OfflinePageArchiver> PendingArchivers; |
| 257 | 242 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 const bool* success); | 279 const bool* success); |
| 295 void OnRemoveOfflinePagesDone(const std::vector<int64_t>& offline_ids, | 280 void OnRemoveOfflinePagesDone(const std::vector<int64_t>& offline_ids, |
| 296 const DeletePageCallback& callback, | 281 const DeletePageCallback& callback, |
| 297 bool success); | 282 bool success); |
| 298 void InformDeletePageDone(const DeletePageCallback& callback, | 283 void InformDeletePageDone(const DeletePageCallback& callback, |
| 299 DeletePageResult result); | 284 DeletePageResult result); |
| 300 | 285 |
| 301 void OnMarkPageAccesseDone(const OfflinePageItem& offline_page_item, | 286 void OnMarkPageAccesseDone(const OfflinePageItem& offline_page_item, |
| 302 bool success); | 287 bool success); |
| 303 | 288 |
| 304 // Steps for marking an offline page for deletion that can be undone. | |
| 305 void OnMarkPageForDeletionDone(const OfflinePageItem& offline_page_item, | |
| 306 const DeletePageCallback& callback, | |
| 307 bool success); | |
| 308 void FinalizePageDeletion(); | |
| 309 | |
| 310 // Steps for undoing an offline page deletion. | |
| 311 void OnUndoOfflinePageDone(const OfflinePageItem& offline_page, bool success); | |
| 312 | |
| 313 // Callbacks for checking if offline pages are missing archive files. | 289 // Callbacks for checking if offline pages are missing archive files. |
| 314 void OnFindPagesMissingArchiveFile( | 290 void OnFindPagesMissingArchiveFile( |
| 315 const std::vector<int64_t>* ids_of_pages_missing_archive_file); | 291 const std::vector<int64_t>* ids_of_pages_missing_archive_file); |
| 316 void OnRemoveOfflinePagesMissingArchiveFileDone( | 292 void OnRemoveOfflinePagesMissingArchiveFileDone( |
| 317 const std::vector<std::pair<int64_t, ClientId>>& offline_client_id_pairs, | 293 const std::vector<std::pair<int64_t, ClientId>>& offline_client_id_pairs, |
| 318 OfflinePageModel::DeletePageResult result); | 294 OfflinePageModel::DeletePageResult result); |
| 319 | 295 |
| 320 // Steps for clearing all. | 296 // Steps for clearing all. |
| 321 void OnRemoveAllFilesDoneForClearAll(const base::Closure& callback, | 297 void OnRemoveAllFilesDoneForClearAll(const base::Closure& callback, |
| 322 DeletePageResult result); | 298 DeletePageResult result); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 363 std::vector<base::Closure> delayed_tasks_; | 339 std::vector<base::Closure> delayed_tasks_; |
| 364 | 340 |
| 365 base::WeakPtrFactory<OfflinePageModel> weak_ptr_factory_; | 341 base::WeakPtrFactory<OfflinePageModel> weak_ptr_factory_; |
| 366 | 342 |
| 367 DISALLOW_COPY_AND_ASSIGN(OfflinePageModel); | 343 DISALLOW_COPY_AND_ASSIGN(OfflinePageModel); |
| 368 }; | 344 }; |
| 369 | 345 |
| 370 } // namespace offline_pages | 346 } // namespace offline_pages |
| 371 | 347 |
| 372 #endif // COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_MODEL_H_ | 348 #endif // COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_MODEL_H_ |
| OLD | NEW |