| 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 <map> | 8 #include <map> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 const DeletePageCallback& callback); | 166 const DeletePageCallback& callback); |
| 167 | 167 |
| 168 // Deletes offline pages related to the passed |bookmark_ids|. Requires that | 168 // Deletes offline pages related to the passed |bookmark_ids|. Requires that |
| 169 // the model is loaded. | 169 // the model is loaded. |
| 170 void DeletePagesByBookmarkId(const std::vector<int64>& bookmark_ids, | 170 void DeletePagesByBookmarkId(const std::vector<int64>& bookmark_ids, |
| 171 const DeletePageCallback& callback); | 171 const DeletePageCallback& callback); |
| 172 | 172 |
| 173 // Wipes out all the data by deleting all saved files and clearing the store. | 173 // Wipes out all the data by deleting all saved files and clearing the store. |
| 174 void ClearAll(const base::Closure& callback); | 174 void ClearAll(const base::Closure& callback); |
| 175 | 175 |
| 176 // Returns true if there're offline pages. |
| 177 bool HasOfflinePages() const; |
| 178 |
| 176 // Gets all available offline pages. Requires that the model is loaded. | 179 // Gets all available offline pages. Requires that the model is loaded. |
| 177 const std::vector<OfflinePageItem> GetAllPages() const; | 180 const std::vector<OfflinePageItem> GetAllPages() const; |
| 178 | 181 |
| 179 // Gets pages that should be removed to clean up storage. Requires that the | 182 // Gets pages that should be removed to clean up storage. Requires that the |
| 180 // model is loaded. | 183 // model is loaded. |
| 181 const std::vector<OfflinePageItem> GetPagesToCleanUp() const; | 184 const std::vector<OfflinePageItem> GetPagesToCleanUp() const; |
| 182 | 185 |
| 183 // Returns an offline page associated with a specified |bookmark_id|. nullptr | 186 // Returns an offline page associated with a specified |bookmark_id|. nullptr |
| 184 // is returned if not found. | 187 // is returned if not found. |
| 185 const OfflinePageItem* GetPageByBookmarkId(int64 bookmark_id) const; | 188 const OfflinePageItem* GetPageByBookmarkId(int64 bookmark_id) const; |
| 186 | 189 |
| 187 // Returns an offline page that is stored as |offline_url|. A nullptr is | 190 // Returns an offline page that is stored as |offline_url|. A nullptr is |
| 188 // returned if not found. | 191 // returned if not found. |
| 189 const OfflinePageItem* GetPageByOfflineURL(const GURL& offline_url) const; | 192 const OfflinePageItem* GetPageByOfflineURL(const GURL& offline_url) const; |
| 190 | 193 |
| 194 // Returns an offline page saved for |online_url|. A nullptr is returned if |
| 195 // not found. |
| 196 const OfflinePageItem* GetPageByOnlineURL(const GURL& online_url) const; |
| 197 |
| 191 // Checks that all of the offline pages have corresponding offline copies. | 198 // Checks that all of the offline pages have corresponding offline copies. |
| 192 // If a page is discovered to be missing an offline copy, its offline page | 199 // If a page is discovered to be missing an offline copy, its offline page |
| 193 // metadata will be removed and |OfflinePageDeleted| will be sent to model | 200 // metadata will be removed and |OfflinePageDeleted| will be sent to model |
| 194 // observers. | 201 // observers. |
| 195 void CheckForExternalFileDeletion(); | 202 void CheckForExternalFileDeletion(); |
| 196 | 203 |
| 197 // Methods for testing only: | 204 // Methods for testing only: |
| 198 OfflinePageMetadataStore* GetStoreForTesting(); | 205 OfflinePageMetadataStore* GetStoreForTesting(); |
| 199 | 206 |
| 200 bool is_loaded() const { return is_loaded_; } | 207 bool is_loaded() const { return is_loaded_; } |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 308 scoped_observer_; | 315 scoped_observer_; |
| 309 | 316 |
| 310 base::WeakPtrFactory<OfflinePageModel> weak_ptr_factory_; | 317 base::WeakPtrFactory<OfflinePageModel> weak_ptr_factory_; |
| 311 | 318 |
| 312 DISALLOW_COPY_AND_ASSIGN(OfflinePageModel); | 319 DISALLOW_COPY_AND_ASSIGN(OfflinePageModel); |
| 313 }; | 320 }; |
| 314 | 321 |
| 315 } // namespace offline_pages | 322 } // namespace offline_pages |
| 316 | 323 |
| 317 #endif // COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_MODEL_H_ | 324 #endif // COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_MODEL_H_ |
| OLD | NEW |