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 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 const DeletePageCallback& callback); | 169 const DeletePageCallback& callback); |
170 | 170 |
171 // Marks pages for deletion. Actual delete is asynchronous. | 171 // Marks pages for deletion. Actual delete is asynchronous. |
172 // Works even if the model isn't loaded. | 172 // Works even if the model isn't loaded. |
173 void MarkPagesForDeletion(const std::vector<int64_t>& offline_ids, | 173 void MarkPagesForDeletion(const std::vector<int64_t>& offline_ids, |
174 const DeletePageCallback& callback); | 174 const DeletePageCallback& callback); |
175 | 175 |
176 // Wipes out all the data by deleting all saved files and clearing the store. | 176 // Wipes out all the data by deleting all saved files and clearing the store. |
177 void ClearAll(const base::Closure& callback); | 177 void ClearAll(const base::Closure& callback); |
178 | 178 |
| 179 // Deletes offline pages matching the URL predicate. |
| 180 void DeletePagesByURLPredicate( |
| 181 const base::Callback<bool(const GURL&)>& predicate, |
| 182 const DeletePageCallback& callback); |
| 183 |
179 // Returns true if there're offline pages. | 184 // Returns true if there're offline pages. |
180 bool HasOfflinePages() const; | 185 bool HasOfflinePages() const; |
181 | 186 |
182 // Gets all available offline pages. Requires that the model is loaded. | 187 // Gets all available offline pages. Requires that the model is loaded. |
183 const std::vector<OfflinePageItem> GetAllPages() const; | 188 const std::vector<OfflinePageItem> GetAllPages() const; |
184 | 189 |
185 // Gets pages that should be removed to clean up storage. Requires that the | 190 // Gets pages that should be removed to clean up storage. Requires that the |
186 // model is loaded. | 191 // model is loaded. |
187 const std::vector<OfflinePageItem> GetPagesToCleanUp() const; | 192 const std::vector<OfflinePageItem> GetPagesToCleanUp() const; |
188 | 193 |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
300 const base::Closure& callback, | 305 const base::Closure& callback, |
301 OfflinePageMetadataStore::LoadStatus load_status, | 306 OfflinePageMetadataStore::LoadStatus load_status, |
302 const std::vector<OfflinePageItem>& offline_pages); | 307 const std::vector<OfflinePageItem>& offline_pages); |
303 | 308 |
304 void CacheLoadedData(const std::vector<OfflinePageItem>& offline_pages); | 309 void CacheLoadedData(const std::vector<OfflinePageItem>& offline_pages); |
305 | 310 |
306 // Actually does the work of deleting, requires the model is loaded. | 311 // Actually does the work of deleting, requires the model is loaded. |
307 void DoDeletePagesByOfflineId(const std::vector<int64_t>& offline_ids, | 312 void DoDeletePagesByOfflineId(const std::vector<int64_t>& offline_ids, |
308 const DeletePageCallback& callback); | 313 const DeletePageCallback& callback); |
309 | 314 |
| 315 // Similar to DoDeletePagesByOfflineId, does actual work of deleting, and |
| 316 // requires that the model is loaded. |
| 317 void DoDeletePagesByURLPredicate( |
| 318 const base::Callback<bool(const GURL&)>& predicate, |
| 319 const DeletePageCallback& callback); |
| 320 |
310 // Persistent store for offline page metadata. | 321 // Persistent store for offline page metadata. |
311 scoped_ptr<OfflinePageMetadataStore> store_; | 322 scoped_ptr<OfflinePageMetadataStore> store_; |
312 | 323 |
313 // Location where all of the archive files will be stored. | 324 // Location where all of the archive files will be stored. |
314 base::FilePath archives_dir_; | 325 base::FilePath archives_dir_; |
315 | 326 |
316 // The observers. | 327 // The observers. |
317 base::ObserverList<Observer> observers_; | 328 base::ObserverList<Observer> observers_; |
318 | 329 |
319 bool is_loaded_; | 330 bool is_loaded_; |
(...skipping 10 matching lines...) Expand all Loading... |
330 std::vector<base::Closure> delayed_tasks_; | 341 std::vector<base::Closure> delayed_tasks_; |
331 | 342 |
332 base::WeakPtrFactory<OfflinePageModel> weak_ptr_factory_; | 343 base::WeakPtrFactory<OfflinePageModel> weak_ptr_factory_; |
333 | 344 |
334 DISALLOW_COPY_AND_ASSIGN(OfflinePageModel); | 345 DISALLOW_COPY_AND_ASSIGN(OfflinePageModel); |
335 }; | 346 }; |
336 | 347 |
337 } // namespace offline_pages | 348 } // namespace offline_pages |
338 | 349 |
339 #endif // COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_MODEL_H_ | 350 #endif // COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_MODEL_H_ |
OLD | NEW |