Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(88)

Side by Side Diff: components/offline_pages/offline_page_model.h

Issue 1397233002: [Offline pages] Detecting missing offline copy (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Updates based on the latest code review feedback Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 // Observer of the OfflinePageModel. 96 // Observer of the OfflinePageModel.
97 class Observer { 97 class Observer {
98 public: 98 public:
99 // Invoked when the model has finished loading. 99 // Invoked when the model has finished loading.
100 virtual void OfflinePageModelLoaded(OfflinePageModel* model) = 0; 100 virtual void OfflinePageModelLoaded(OfflinePageModel* model) = 0;
101 101
102 // Invoked when the model is being updated, due to adding, removing or 102 // Invoked when the model is being updated, due to adding, removing or
103 // updating an offline page. 103 // updating an offline page.
104 virtual void OfflinePageModelChanged(OfflinePageModel* model) = 0; 104 virtual void OfflinePageModelChanged(OfflinePageModel* model) = 0;
105 105
106 // Invoked when an offline copy related to |bookmark_id| was deleted.
107 // In can be invoked as a result of |CheckForExternalFileDeletion|, if a
108 // deleted page is detected.
109 virtual void OfflinePageDeleted(int64 bookmark_id) = 0;
110
106 protected: 111 protected:
107 virtual ~Observer() {} 112 virtual ~Observer() {}
108 }; 113 };
109 114
110 typedef base::Callback<void(SavePageResult)> SavePageCallback; 115 typedef base::Callback<void(SavePageResult)> SavePageCallback;
111 typedef base::Callback<void(DeletePageResult)> DeletePageCallback; 116 typedef base::Callback<void(DeletePageResult)> DeletePageCallback;
112 117
113 // All blocking calls/disk access will happen on the provided |task_runner|. 118 // All blocking calls/disk access will happen on the provided |task_runner|.
114 OfflinePageModel( 119 OfflinePageModel(
115 scoped_ptr<OfflinePageMetadataStore> store, 120 scoped_ptr<OfflinePageMetadataStore> store,
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 const std::vector<OfflinePageItem> GetAllPages() const; 167 const std::vector<OfflinePageItem> GetAllPages() const;
163 168
164 // Gets pages that should be removed to clean up storage. Requires that the 169 // Gets pages that should be removed to clean up storage. Requires that the
165 // model is loaded. 170 // model is loaded.
166 const std::vector<OfflinePageItem> GetPagesToCleanUp() const; 171 const std::vector<OfflinePageItem> GetPagesToCleanUp() const;
167 172
168 // Returns an offline page associated with a specified |bookmark_id|. nullptr 173 // Returns an offline page associated with a specified |bookmark_id|. nullptr
169 // is returned if not found. 174 // is returned if not found.
170 const OfflinePageItem* GetPageByBookmarkId(int64 bookmark_id) const; 175 const OfflinePageItem* GetPageByBookmarkId(int64 bookmark_id) const;
171 176
172 // Returns an offline page that is stored as |offline_url|. nullptr is 177 // Returns an offline page that is stored as |offline_url|. A nullptr is
173 // returned if not found. 178 // returned if not found.
174 const OfflinePageItem* GetPageByOfflineURL(const GURL& offline_url) const; 179 const OfflinePageItem* GetPageByOfflineURL(const GURL& offline_url) const;
175 180
181 // Checks that all of the offline pages have corresponding offline copies.
182 // If a page is discovered to be missing an offline copy, its offline page
183 // metadata will be removed and |OfflinePageDeleted| will be sent to model
184 // observers.
185 void CheckForExternalFileDeletion();
186
176 // Methods for testing only: 187 // Methods for testing only:
177 OfflinePageMetadataStore* GetStoreForTesting(); 188 OfflinePageMetadataStore* GetStoreForTesting();
178 189
179 bool is_loaded() const { return is_loaded_; } 190 bool is_loaded() const { return is_loaded_; }
180 191
181 private: 192 private:
182 FRIEND_TEST_ALL_PREFIXES(OfflinePageModelTest, MarkPageForDeletion); 193 FRIEND_TEST_ALL_PREFIXES(OfflinePageModelTest, MarkPageForDeletion);
183 194
184 typedef ScopedVector<OfflinePageArchiver> PendingArchivers; 195 typedef ScopedVector<OfflinePageArchiver> PendingArchivers;
185 196
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 const bool* success); 233 const bool* success);
223 void OnRemoveOfflinePagesDone(const std::vector<int64>& bookmark_ids, 234 void OnRemoveOfflinePagesDone(const std::vector<int64>& bookmark_ids,
224 const DeletePageCallback& callback, 235 const DeletePageCallback& callback,
225 bool success); 236 bool success);
226 void InformDeletePageDone(const DeletePageCallback& callback, 237 void InformDeletePageDone(const DeletePageCallback& callback,
227 DeletePageResult result); 238 DeletePageResult result);
228 239
229 void OnMarkPageAccesseDone(const OfflinePageItem& offline_page_item, 240 void OnMarkPageAccesseDone(const OfflinePageItem& offline_page_item,
230 bool success); 241 bool success);
231 242
232 // Steps for marking an offline page for deletion that can be undo-ed. 243 // Steps for marking an offline page for deletion that can be undone.
233 void OnMarkPageForDeletionDone(const OfflinePageItem& offline_page_item, 244 void OnMarkPageForDeletionDone(const OfflinePageItem& offline_page_item,
234 const DeletePageCallback& callback, 245 const DeletePageCallback& callback,
235 bool success); 246 bool success);
236 void FinalizePageDeletion(); 247 void FinalizePageDeletion();
237 248
238 // Steps for undoing a offline page deletion. 249 // Steps for undoing an offline page deletion.
239 void UndoPageDeletion(int64 bookmark_id); 250 void UndoPageDeletion(int64 bookmark_id);
240 void OnUndoOfflinePageDone(const OfflinePageItem& offline_page, bool success); 251 void OnUndoOfflinePageDone(const OfflinePageItem& offline_page, bool success);
241 252
253 // Callbacks for checking if offline pages are missing archive files.
254 void OnFindPagesMissingArchiveFile(
255 const std::vector<int64>* pages_missing_archive_file);
256 void OnRemoveOfflinePagesMissingArchiveFileDone(
257 const std::vector<int64>& bookmark_ids,
258 OfflinePageModel::DeletePageResult result);
259
242 // Persistent store for offline page metadata. 260 // Persistent store for offline page metadata.
243 scoped_ptr<OfflinePageMetadataStore> store_; 261 scoped_ptr<OfflinePageMetadataStore> store_;
244 262
245 // The observers. 263 // The observers.
246 base::ObserverList<Observer> observers_; 264 base::ObserverList<Observer> observers_;
247 265
248 bool is_loaded_; 266 bool is_loaded_;
249 267
250 // In memory copy of the offline page metadata, keyed by bookmark IDs. 268 // In memory copy of the offline page metadata, keyed by bookmark IDs.
251 std::map<int64, OfflinePageItem> offline_pages_; 269 std::map<int64, OfflinePageItem> offline_pages_;
(...skipping 10 matching lines...) Expand all
262 scoped_observer_; 280 scoped_observer_;
263 281
264 base::WeakPtrFactory<OfflinePageModel> weak_ptr_factory_; 282 base::WeakPtrFactory<OfflinePageModel> weak_ptr_factory_;
265 283
266 DISALLOW_COPY_AND_ASSIGN(OfflinePageModel); 284 DISALLOW_COPY_AND_ASSIGN(OfflinePageModel);
267 }; 285 };
268 286
269 } // namespace offline_pages 287 } // namespace offline_pages
270 288
271 #endif // COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_MODEL_H_ 289 #endif // COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_MODEL_H_
OLDNEW
« no previous file with comments | « chrome/browser/android/offline_pages/offline_page_bridge.cc ('k') | components/offline_pages/offline_page_model.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698