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

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

Issue 1345043002: Update access info when an offline page is being visited (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address feedback Created 5 years, 3 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 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 100
101 protected: 101 protected:
102 virtual ~Observer() {} 102 virtual ~Observer() {}
103 }; 103 };
104 104
105 typedef base::Callback<void(SavePageResult)> SavePageCallback; 105 typedef base::Callback<void(SavePageResult)> SavePageCallback;
106 typedef base::Callback<void(bool)> MarkPageAccessedCallback;
106 typedef base::Callback<void(DeletePageResult)> DeletePageCallback; 107 typedef base::Callback<void(DeletePageResult)> DeletePageCallback;
107 108
108 // All blocking calls/disk access will happen on the provided |task_runner|. 109 // All blocking calls/disk access will happen on the provided |task_runner|.
109 OfflinePageModel( 110 OfflinePageModel(
110 scoped_ptr<OfflinePageMetadataStore> store, 111 scoped_ptr<OfflinePageMetadataStore> store,
111 const scoped_refptr<base::SequencedTaskRunner>& task_runner); 112 const scoped_refptr<base::SequencedTaskRunner>& task_runner);
112 ~OfflinePageModel() override; 113 ~OfflinePageModel() override;
113 114
114 // Starts the OfflinePageModel and registers it as a BookmarkModelObserver. 115 // Starts the OfflinePageModel and registers it as a BookmarkModelObserver.
115 // Calling this method is optional, but offline pages will not be deleted 116 // Calling this method is optional, but offline pages will not be deleted
116 // when the bookmark is deleted, i.e. due to sync, until this method is 117 // when the bookmark is deleted, i.e. due to sync, until this method is
117 // called. 118 // called.
118 void Start(bookmarks::BookmarkModel* model); 119 void Start(bookmarks::BookmarkModel* model);
119 120
120 // KeyedService implementation. 121 // KeyedService implementation.
121 void Shutdown() override; 122 void Shutdown() override;
122 123
123 void AddObserver(Observer* observer); 124 void AddObserver(Observer* observer);
124 void RemoveObserver(Observer* observer); 125 void RemoveObserver(Observer* observer);
125 126
126 // Attempts to save a page addressed by |url| offline. Requires that the model 127 // Attempts to save a page addressed by |url| offline. Requires that the model
127 // is loaded. 128 // is loaded.
128 void SavePage(const GURL& url, 129 void SavePage(const GURL& url,
129 int64 bookmark_id, 130 int64 bookmark_id,
130 scoped_ptr<OfflinePageArchiver> archiver, 131 scoped_ptr<OfflinePageArchiver> archiver,
131 const SavePageCallback& callback); 132 const SavePageCallback& callback);
132 133
134 // Marks that the offline page related to the passed |bookmark_id| has been
135 // accessed. Its access info, including last access time and access count,
136 // will be updated. Requires that the model is loaded.
137 void MarkPageAccessed(int64 bookmark_id,
138 const MarkPageAccessedCallback& callback);
139
133 // Deletes an offline page related to the passed |bookmark_id|. Requires that 140 // Deletes an offline page related to the passed |bookmark_id|. Requires that
134 // the model is loaded. 141 // the model is loaded.
135 void DeletePageByBookmarkId(int64 bookmark_id, 142 void DeletePageByBookmarkId(int64 bookmark_id,
136 const DeletePageCallback& callback); 143 const DeletePageCallback& callback);
137 144
138 // Deletes offline pages related to the passed |bookmark_ids|. Requires that 145 // Deletes offline pages related to the passed |bookmark_ids|. Requires that
139 // the model is loaded. 146 // the model is loaded.
140 void DeletePagesByBookmarkId(const std::vector<int64>& bookmark_ids, 147 void DeletePagesByBookmarkId(const std::vector<int64>& bookmark_ids,
141 const DeletePageCallback& callback); 148 const DeletePageCallback& callback);
142 149
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 void OnDeleteArchiveFilesDone( 203 void OnDeleteArchiveFilesDone(
197 const std::vector<int64>& bookmark_ids, 204 const std::vector<int64>& bookmark_ids,
198 const DeletePageCallback& callback, 205 const DeletePageCallback& callback,
199 const bool* success); 206 const bool* success);
200 void OnRemoveOfflinePagesDone(const std::vector<int64>& bookmark_ids, 207 void OnRemoveOfflinePagesDone(const std::vector<int64>& bookmark_ids,
201 const DeletePageCallback& callback, 208 const DeletePageCallback& callback,
202 bool success); 209 bool success);
203 void InformDeletePageDone(const DeletePageCallback& callback, 210 void InformDeletePageDone(const DeletePageCallback& callback,
204 DeletePageResult result); 211 DeletePageResult result);
205 212
213 void OnUpdateOfflinePageDone(const MarkPageAccessedCallback& callback,
214 bool success);
215
206 // Persistent store for offline page metadata. 216 // Persistent store for offline page metadata.
207 scoped_ptr<OfflinePageMetadataStore> store_; 217 scoped_ptr<OfflinePageMetadataStore> store_;
208 218
209 // The observers. 219 // The observers.
210 base::ObserverList<Observer> observers_; 220 base::ObserverList<Observer> observers_;
211 221
212 bool is_loaded_; 222 bool is_loaded_;
213 223
214 // In memory copy of the offline page metadata, keyed by bookmark IDs. 224 // In memory copy of the offline page metadata, keyed by bookmark IDs.
215 std::map<int64, OfflinePageItem> offline_pages_; 225 std::map<int64, OfflinePageItem> offline_pages_;
(...skipping 10 matching lines...) Expand all
226 scoped_observer_; 236 scoped_observer_;
227 237
228 base::WeakPtrFactory<OfflinePageModel> weak_ptr_factory_; 238 base::WeakPtrFactory<OfflinePageModel> weak_ptr_factory_;
229 239
230 DISALLOW_COPY_AND_ASSIGN(OfflinePageModel); 240 DISALLOW_COPY_AND_ASSIGN(OfflinePageModel);
231 }; 241 };
232 242
233 } // namespace offline_pages 243 } // namespace offline_pages
234 244
235 #endif // COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_MODEL_H_ 245 #endif // COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_MODEL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698