Chromium Code Reviews| 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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 90 SUCCESS, | 90 SUCCESS, |
| 91 CANCELLED, | 91 CANCELLED, |
| 92 STORE_FAILURE, | 92 STORE_FAILURE, |
| 93 }; | 93 }; |
| 94 | 94 |
| 95 // Observer of the OfflinePageModel. | 95 // Observer of the OfflinePageModel. |
| 96 class Observer { | 96 class Observer { |
| 97 public: | 97 public: |
| 98 // Invoked when the model has finished loading. | 98 // Invoked when the model has finished loading. |
| 99 virtual void OfflinePageModelLoaded(OfflinePageModel* model) = 0; | 99 virtual void OfflinePageModelLoaded(OfflinePageModel* model) = 0; |
| 100 // Invoked when an offline copy related to |bookmark_id| was deleted. | |
| 101 virtual void OfflinePageDeleted(int64 bookmark_id) = 0; | |
| 100 | 102 |
| 101 protected: | 103 protected: |
| 102 virtual ~Observer() {} | 104 virtual ~Observer() {} |
| 103 }; | 105 }; |
| 104 | 106 |
| 105 typedef base::Callback<void(SavePageResult)> SavePageCallback; | 107 typedef base::Callback<void(SavePageResult)> SavePageCallback; |
| 106 typedef base::Callback<void(DeletePageResult)> DeletePageCallback; | 108 typedef base::Callback<void(DeletePageResult)> DeletePageCallback; |
| 107 | 109 |
| 108 // All blocking calls/disk access will happen on the provided |task_runner|. | 110 // All blocking calls/disk access will happen on the provided |task_runner|. |
| 109 OfflinePageModel( | 111 OfflinePageModel( |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 149 const std::vector<OfflinePageItem> GetAllPages() const; | 151 const std::vector<OfflinePageItem> GetAllPages() const; |
| 150 | 152 |
| 151 // Gets pages that should be removed to clean up storage. Requires that the | 153 // Gets pages that should be removed to clean up storage. Requires that the |
| 152 // model is loaded. | 154 // model is loaded. |
| 153 const std::vector<OfflinePageItem> GetPagesToCleanUp() const; | 155 const std::vector<OfflinePageItem> GetPagesToCleanUp() const; |
| 154 | 156 |
| 155 // Returns an offline page associated with a specified |bookmark_id|. nullptr | 157 // Returns an offline page associated with a specified |bookmark_id|. nullptr |
| 156 // is returned if not found. | 158 // is returned if not found. |
| 157 const OfflinePageItem* GetPageByBookmarkId(int64 bookmark_id) const; | 159 const OfflinePageItem* GetPageByBookmarkId(int64 bookmark_id) const; |
| 158 | 160 |
| 159 // Returns an offline page that is stored as |offline_url|. nullptr is | 161 // Returns an offline page that is stored as |offline_url|. A nullptr is |
| 160 // returned if not found. | 162 // returned if not found. |
| 161 const OfflinePageItem* GetPageByOfflineURL(const GURL& offline_url) const; | 163 const OfflinePageItem* GetPageByOfflineURL(const GURL& offline_url) const; |
| 162 | 164 |
| 165 // Checks that all of the offline pages have corresponding offline copies. | |
|
jianli
2015/10/14 22:30:23
Can you be a bit more specific in the comment? I t
fgorski
2015/10/15 19:12:29
I disagree. See line 36 in this file.
| |
| 166 void CheckForExternalFileDeletion(); | |
| 167 | |
| 163 // Methods for testing only: | 168 // Methods for testing only: |
| 164 OfflinePageMetadataStore* GetStoreForTesting(); | 169 OfflinePageMetadataStore* GetStoreForTesting(); |
| 165 | 170 |
| 166 bool is_loaded() const { return is_loaded_; } | 171 bool is_loaded() const { return is_loaded_; } |
| 167 | 172 |
| 168 private: | 173 private: |
| 169 typedef ScopedVector<OfflinePageArchiver> PendingArchivers; | 174 typedef ScopedVector<OfflinePageArchiver> PendingArchivers; |
| 170 | 175 |
| 171 // BaseBookmarkModelObserver: | 176 // BaseBookmarkModelObserver: |
| 172 void BookmarkModelChanged() override; | 177 void BookmarkModelChanged() override; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 204 const bool* success); | 209 const bool* success); |
| 205 void OnRemoveOfflinePagesDone(const std::vector<int64>& bookmark_ids, | 210 void OnRemoveOfflinePagesDone(const std::vector<int64>& bookmark_ids, |
| 206 const DeletePageCallback& callback, | 211 const DeletePageCallback& callback, |
| 207 bool success); | 212 bool success); |
| 208 void InformDeletePageDone(const DeletePageCallback& callback, | 213 void InformDeletePageDone(const DeletePageCallback& callback, |
| 209 DeletePageResult result); | 214 DeletePageResult result); |
| 210 | 215 |
| 211 void OnUpdateOfflinePageDone(const OfflinePageItem& offline_page_item, | 216 void OnUpdateOfflinePageDone(const OfflinePageItem& offline_page_item, |
| 212 bool success); | 217 bool success); |
| 213 | 218 |
| 219 // Callback for check if offline pages missing offline files. | |
| 220 void OnListPagesMissingArchiveFileDone( | |
| 221 const std::vector<int64>* pages_missing_archive_file); | |
| 222 | |
| 214 // Persistent store for offline page metadata. | 223 // Persistent store for offline page metadata. |
| 215 scoped_ptr<OfflinePageMetadataStore> store_; | 224 scoped_ptr<OfflinePageMetadataStore> store_; |
| 216 | 225 |
| 217 // The observers. | 226 // The observers. |
| 218 base::ObserverList<Observer> observers_; | 227 base::ObserverList<Observer> observers_; |
| 219 | 228 |
| 220 bool is_loaded_; | 229 bool is_loaded_; |
| 221 | 230 |
| 222 // In memory copy of the offline page metadata, keyed by bookmark IDs. | 231 // In memory copy of the offline page metadata, keyed by bookmark IDs. |
| 223 std::map<int64, OfflinePageItem> offline_pages_; | 232 std::map<int64, OfflinePageItem> offline_pages_; |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 234 scoped_observer_; | 243 scoped_observer_; |
| 235 | 244 |
| 236 base::WeakPtrFactory<OfflinePageModel> weak_ptr_factory_; | 245 base::WeakPtrFactory<OfflinePageModel> weak_ptr_factory_; |
| 237 | 246 |
| 238 DISALLOW_COPY_AND_ASSIGN(OfflinePageModel); | 247 DISALLOW_COPY_AND_ASSIGN(OfflinePageModel); |
| 239 }; | 248 }; |
| 240 | 249 |
| 241 } // namespace offline_pages | 250 } // namespace offline_pages |
| 242 | 251 |
| 243 #endif // COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_MODEL_H_ | 252 #endif // COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_MODEL_H_ |
| OLD | NEW |