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 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 void SavePage(const GURL& url, | 128 void SavePage(const GURL& url, |
129 int64 bookmark_id, | 129 int64 bookmark_id, |
130 scoped_ptr<OfflinePageArchiver> archiver, | 130 scoped_ptr<OfflinePageArchiver> archiver, |
131 const SavePageCallback& callback); | 131 const SavePageCallback& callback); |
132 | 132 |
133 // Marks that the offline page related to the passed |bookmark_id| has been | 133 // Marks that the offline page related to the passed |bookmark_id| has been |
134 // accessed. Its access info, including last access time and access count, | 134 // accessed. Its access info, including last access time and access count, |
135 // will be updated. Requires that the model is loaded. | 135 // will be updated. Requires that the model is loaded. |
136 void MarkPageAccessed(int64 bookmark_id); | 136 void MarkPageAccessed(int64 bookmark_id); |
137 | 137 |
| 138 // Marks that the offline page related to the passed |bookmark_id| was going |
| 139 // to be deleted. The deletion will occur in a short while. The undo can be |
| 140 // done before this. Requires that the model is loaded. |
| 141 void MarkPageForDeletion(int64 bookmark_id, |
| 142 const DeletePageCallback& callback); |
| 143 |
138 // Deletes an offline page related to the passed |bookmark_id|. Requires that | 144 // Deletes an offline page related to the passed |bookmark_id|. Requires that |
139 // the model is loaded. | 145 // the model is loaded. |
140 void DeletePageByBookmarkId(int64 bookmark_id, | 146 void DeletePageByBookmarkId(int64 bookmark_id, |
141 const DeletePageCallback& callback); | 147 const DeletePageCallback& callback); |
142 | 148 |
143 // Deletes offline pages related to the passed |bookmark_ids|. Requires that | 149 // Deletes offline pages related to the passed |bookmark_ids|. Requires that |
144 // the model is loaded. | 150 // the model is loaded. |
145 void DeletePagesByBookmarkId(const std::vector<int64>& bookmark_ids, | 151 void DeletePagesByBookmarkId(const std::vector<int64>& bookmark_ids, |
146 const DeletePageCallback& callback); | 152 const DeletePageCallback& callback); |
147 | 153 |
| 154 void UndeletePage(int64 bookmark_id, |
| 155 const DeletePageCallback& callback); |
| 156 |
148 // Gets all available offline pages. Requires that the model is loaded. | 157 // Gets all available offline pages. Requires that the model is loaded. |
149 const std::vector<OfflinePageItem> GetAllPages() const; | 158 const std::vector<OfflinePageItem> GetAllPages() const; |
150 | 159 |
151 // Gets pages that should be removed to clean up storage. Requires that the | 160 // Gets pages that should be removed to clean up storage. Requires that the |
152 // model is loaded. | 161 // model is loaded. |
153 const std::vector<OfflinePageItem> GetPagesToCleanUp() const; | 162 const std::vector<OfflinePageItem> GetPagesToCleanUp() const; |
154 | 163 |
155 // Returns an offline page associated with a specified |bookmark_id|. nullptr | 164 // Returns an offline page associated with a specified |bookmark_id|. nullptr |
156 // is returned if not found. | 165 // is returned if not found. |
157 const OfflinePageItem* GetPageByBookmarkId(int64 bookmark_id) const; | 166 const OfflinePageItem* GetPageByBookmarkId(int64 bookmark_id) const; |
158 | 167 |
159 // Returns an offline page that is stored as |offline_url|. nullptr is | 168 // Returns an offline page that is stored as |offline_url|. nullptr is |
160 // returned if not found. | 169 // returned if not found. |
161 const OfflinePageItem* GetPageByOfflineURL(const GURL& offline_url) const; | 170 const OfflinePageItem* GetPageByOfflineURL(const GURL& offline_url) const; |
162 | 171 |
163 // Methods for testing only: | 172 // Methods for testing only: |
164 OfflinePageMetadataStore* GetStoreForTesting(); | 173 OfflinePageMetadataStore* GetStoreForTesting(); |
165 | 174 |
166 bool is_loaded() const { return is_loaded_; } | 175 bool is_loaded() const { return is_loaded_; } |
167 | 176 |
168 private: | 177 private: |
169 typedef ScopedVector<OfflinePageArchiver> PendingArchivers; | 178 typedef ScopedVector<OfflinePageArchiver> PendingArchivers; |
170 | 179 |
171 // BaseBookmarkModelObserver: | 180 // BaseBookmarkModelObserver: |
172 void BookmarkModelChanged() override; | 181 void BookmarkModelChanged() override; |
| 182 void BookmarkNodeAdded(bookmarks::BookmarkModel* model, |
| 183 const bookmarks::BookmarkNode* parent, |
| 184 int index) override; |
173 void BookmarkNodeRemoved(bookmarks::BookmarkModel* model, | 185 void BookmarkNodeRemoved(bookmarks::BookmarkModel* model, |
174 const bookmarks::BookmarkNode* parent, | 186 const bookmarks::BookmarkNode* parent, |
175 int old_index, | 187 int old_index, |
176 const bookmarks::BookmarkNode* node, | 188 const bookmarks::BookmarkNode* node, |
177 const std::set<GURL>& removed_urls) override; | 189 const std::set<GURL>& removed_urls) override; |
178 | 190 |
179 // Callback for loading pages from the offline page metadata store. | 191 // Callback for loading pages from the offline page metadata store. |
180 void OnLoadDone(bool success, | 192 void OnLoadDone(bool success, |
181 const std::vector<OfflinePageItem>& offline_pages); | 193 const std::vector<OfflinePageItem>& offline_pages); |
182 | 194 |
(...skipping 18 matching lines...) Expand all Loading... |
201 void OnDeleteArchiveFilesDone( | 213 void OnDeleteArchiveFilesDone( |
202 const std::vector<int64>& bookmark_ids, | 214 const std::vector<int64>& bookmark_ids, |
203 const DeletePageCallback& callback, | 215 const DeletePageCallback& callback, |
204 const bool* success); | 216 const bool* success); |
205 void OnRemoveOfflinePagesDone(const std::vector<int64>& bookmark_ids, | 217 void OnRemoveOfflinePagesDone(const std::vector<int64>& bookmark_ids, |
206 const DeletePageCallback& callback, | 218 const DeletePageCallback& callback, |
207 bool success); | 219 bool success); |
208 void InformDeletePageDone(const DeletePageCallback& callback, | 220 void InformDeletePageDone(const DeletePageCallback& callback, |
209 DeletePageResult result); | 221 DeletePageResult result); |
210 | 222 |
211 void OnUpdateOfflinePageDone(const OfflinePageItem& offline_page_item, | 223 void OnMarkPageAccesseDone(const OfflinePageItem& offline_page_item, |
212 bool success); | 224 bool success); |
| 225 |
| 226 void OnMarkPageForDeletionDone(const OfflinePageItem& offline_page_item, |
| 227 const DeletePageCallback& callback, |
| 228 bool success); |
| 229 void OnUndoOfflinePageDone(const OfflinePageItem& offline_page, |
| 230 bool success); |
| 231 void FinalizePageDeletion(); |
213 | 232 |
214 // Persistent store for offline page metadata. | 233 // Persistent store for offline page metadata. |
215 scoped_ptr<OfflinePageMetadataStore> store_; | 234 scoped_ptr<OfflinePageMetadataStore> store_; |
216 | 235 |
217 // The observers. | 236 // The observers. |
218 base::ObserverList<Observer> observers_; | 237 base::ObserverList<Observer> observers_; |
219 | 238 |
220 bool is_loaded_; | 239 bool is_loaded_; |
221 | 240 |
222 // In memory copy of the offline page metadata, keyed by bookmark IDs. | 241 // In memory copy of the offline page metadata, keyed by bookmark IDs. |
(...skipping 11 matching lines...) Expand all Loading... |
234 scoped_observer_; | 253 scoped_observer_; |
235 | 254 |
236 base::WeakPtrFactory<OfflinePageModel> weak_ptr_factory_; | 255 base::WeakPtrFactory<OfflinePageModel> weak_ptr_factory_; |
237 | 256 |
238 DISALLOW_COPY_AND_ASSIGN(OfflinePageModel); | 257 DISALLOW_COPY_AND_ASSIGN(OfflinePageModel); |
239 }; | 258 }; |
240 | 259 |
241 } // namespace offline_pages | 260 } // namespace offline_pages |
242 | 261 |
243 #endif // COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_MODEL_H_ | 262 #endif // COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_MODEL_H_ |
OLD | NEW |