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 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; |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 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; |
| 173 void BookmarkNodeRemoved(bookmarks::BookmarkModel* model, | 182 void BookmarkNodeRemoved(bookmarks::BookmarkModel* model, |
| 174 const bookmarks::BookmarkNode* parent, | 183 const bookmarks::BookmarkNode* parent, |
| 175 int old_index, | 184 int old_index, |
| 176 const bookmarks::BookmarkNode* node, | 185 const bookmarks::BookmarkNode* node, |
| 177 const std::set<GURL>& removed_urls) override; | 186 const std::set<GURL>& removed_urls) override; |
| 187 void BookmarkNodeRenumbered(bookmarks::BookmarkModel* model, | |
| 188 int64 old_bookmark_id, | |
|
fgorski
2015/09/25 20:30:50
nit: align
jianli
2015/09/25 20:52:36
Done.
| |
| 189 int64 new_bookmark_id) 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 |
| 183 // Steps for saving a page offline. | 195 // Steps for saving a page offline. |
| 184 void OnCreateArchiveDone(const GURL& requested_url, | 196 void OnCreateArchiveDone(const GURL& requested_url, |
| 185 int64 bookmark_id, | 197 int64 bookmark_id, |
| 186 const SavePageCallback& callback, | 198 const SavePageCallback& callback, |
| 187 OfflinePageArchiver* archiver, | 199 OfflinePageArchiver* archiver, |
| (...skipping 13 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 int64 old_bookmark_id, | |
| 231 bool success); | |
| 232 void FinalizePageDeletion(); | |
| 213 | 233 |
| 214 // Persistent store for offline page metadata. | 234 // Persistent store for offline page metadata. |
| 215 scoped_ptr<OfflinePageMetadataStore> store_; | 235 scoped_ptr<OfflinePageMetadataStore> store_; |
| 216 | 236 |
| 217 // The observers. | 237 // The observers. |
| 218 base::ObserverList<Observer> observers_; | 238 base::ObserverList<Observer> observers_; |
| 219 | 239 |
| 220 bool is_loaded_; | 240 bool is_loaded_; |
| 221 | 241 |
| 222 // In memory copy of the offline page metadata, keyed by bookmark IDs. | 242 // In memory copy of the offline page metadata, keyed by bookmark IDs. |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 234 scoped_observer_; | 254 scoped_observer_; |
| 235 | 255 |
| 236 base::WeakPtrFactory<OfflinePageModel> weak_ptr_factory_; | 256 base::WeakPtrFactory<OfflinePageModel> weak_ptr_factory_; |
| 237 | 257 |
| 238 DISALLOW_COPY_AND_ASSIGN(OfflinePageModel); | 258 DISALLOW_COPY_AND_ASSIGN(OfflinePageModel); |
| 239 }; | 259 }; |
| 240 | 260 |
| 241 } // namespace offline_pages | 261 } // namespace offline_pages |
| 242 | 262 |
| 243 #endif // COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_MODEL_H_ | 263 #endif // COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_MODEL_H_ |
| OLD | NEW |