OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_IMPL_H_ | 5 #ifndef COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_MODEL_IMPL_H_ |
6 #define COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_MODEL_IMPL_H_ | 6 #define COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_MODEL_IMPL_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <map> | 10 #include <map> |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 void AddObserver(Observer* observer) override; | 66 void AddObserver(Observer* observer) override; |
67 void RemoveObserver(Observer* observer) override; | 67 void RemoveObserver(Observer* observer) override; |
68 void SavePage(const GURL& url, | 68 void SavePage(const GURL& url, |
69 const ClientId& client_id, | 69 const ClientId& client_id, |
70 int64_t proposed_offline_id, | 70 int64_t proposed_offline_id, |
71 std::unique_ptr<OfflinePageArchiver> archiver, | 71 std::unique_ptr<OfflinePageArchiver> archiver, |
72 const SavePageCallback& callback) override; | 72 const SavePageCallback& callback) override; |
73 void MarkPageAccessed(int64_t offline_id) override; | 73 void MarkPageAccessed(int64_t offline_id) override; |
74 void DeletePagesByOfflineId(const std::vector<int64_t>& offline_ids, | 74 void DeletePagesByOfflineId(const std::vector<int64_t>& offline_ids, |
75 const DeletePageCallback& callback) override; | 75 const DeletePageCallback& callback) override; |
| 76 void DeletePagesByClientIds(const std::vector<ClientId>& client_ids, |
| 77 const DeletePageCallback& callback) override; |
| 78 void GetPagesByClientIds( |
| 79 const std::vector<ClientId>& client_ids, |
| 80 const MultipleOfflinePageItemCallback& callback) override; |
| 81 |
76 void DeleteCachedPagesByURLPredicate( | 82 void DeleteCachedPagesByURLPredicate( |
77 const UrlPredicate& predicate, | 83 const UrlPredicate& predicate, |
78 const DeletePageCallback& callback) override; | 84 const DeletePageCallback& callback) override; |
79 void CheckPagesExistOffline( | 85 void CheckPagesExistOffline( |
80 const std::set<GURL>& urls, | 86 const std::set<GURL>& urls, |
81 const CheckPagesExistOfflineCallback& callback) override; | 87 const CheckPagesExistOfflineCallback& callback) override; |
82 void GetAllPages(const MultipleOfflinePageItemCallback& callback) override; | 88 void GetAllPages(const MultipleOfflinePageItemCallback& callback) override; |
83 void GetAllPagesWithExpired( | 89 void GetAllPagesWithExpired( |
84 const MultipleOfflinePageItemCallback& callback) override; | 90 const MultipleOfflinePageItemCallback& callback) override; |
85 void GetOfflineIdsForClientId( | 91 void GetOfflineIdsForClientId( |
86 const ClientId& client_id, | 92 const ClientId& client_id, |
87 const MultipleOfflineIdCallback& callback) override; | 93 const MultipleOfflineIdCallback& callback) override; |
88 const std::vector<int64_t> MaybeGetOfflineIdsForClientId( | |
89 const ClientId& client_id) const override; | |
90 void GetPageByOfflineId( | 94 void GetPageByOfflineId( |
91 int64_t offline_id, | 95 int64_t offline_id, |
92 const SingleOfflinePageItemCallback& callback) override; | 96 const SingleOfflinePageItemCallback& callback) override; |
93 const OfflinePageItem* MaybeGetPageByOfflineId( | |
94 int64_t offline_id) const override; | |
95 void GetPagesByOnlineURL( | 97 void GetPagesByOnlineURL( |
96 const GURL& online_url, | 98 const GURL& online_url, |
97 const MultipleOfflinePageItemCallback& callback) override; | 99 const MultipleOfflinePageItemCallback& callback) override; |
98 const OfflinePageItem* MaybeGetBestPageForOnlineURL( | |
99 const GURL& online_url) const override; | |
100 void ExpirePages(const std::vector<int64_t>& offline_ids, | 100 void ExpirePages(const std::vector<int64_t>& offline_ids, |
101 const base::Time& expiration_time, | 101 const base::Time& expiration_time, |
102 const base::Callback<void(bool)>& callback) override; | 102 const base::Callback<void(bool)>& callback) override; |
103 ClientPolicyController* GetPolicyController() override; | 103 ClientPolicyController* GetPolicyController() override; |
104 | 104 |
105 // Methods for testing only: | 105 // Methods for testing only: |
106 OfflinePageMetadataStore* GetStoreForTesting(); | 106 OfflinePageMetadataStore* GetStoreForTesting(); |
107 void set_testing_clock(base::Clock* clock) { testing_clock_ = clock; } | 107 void set_testing_clock(base::Clock* clock) { testing_clock_ = clock; } |
108 | 108 |
109 OfflinePageStorageManager* GetStorageManager(); | 109 OfflinePageStorageManager* GetStorageManager(); |
(...skipping 25 matching lines...) Expand all Loading... |
135 const MultipleOfflinePageItemCallback& callback) const; | 135 const MultipleOfflinePageItemCallback& callback) const; |
136 void CheckPagesExistOfflineAfterLoadDone( | 136 void CheckPagesExistOfflineAfterLoadDone( |
137 const std::set<GURL>& urls, | 137 const std::set<GURL>& urls, |
138 const CheckPagesExistOfflineCallback& callback); | 138 const CheckPagesExistOfflineCallback& callback); |
139 void GetOfflineIdsForClientIdWhenLoadDone( | 139 void GetOfflineIdsForClientIdWhenLoadDone( |
140 const ClientId& client_id, | 140 const ClientId& client_id, |
141 const MultipleOfflineIdCallback& callback) const; | 141 const MultipleOfflineIdCallback& callback) const; |
142 void GetPageByOfflineIdWhenLoadDone( | 142 void GetPageByOfflineIdWhenLoadDone( |
143 int64_t offline_id, | 143 int64_t offline_id, |
144 const SingleOfflinePageItemCallback& callback) const; | 144 const SingleOfflinePageItemCallback& callback) const; |
| 145 const std::vector<int64_t> MaybeGetOfflineIdsForClientId( |
| 146 const ClientId& client_id) const; |
| 147 const OfflinePageItem* MaybeGetPageByOfflineId(int64_t offline_id) const; |
145 void GetPagesByOnlineURLWhenLoadDone( | 148 void GetPagesByOnlineURLWhenLoadDone( |
146 const GURL& online_url, | 149 const GURL& online_url, |
147 const MultipleOfflinePageItemCallback& callback) const; | 150 const MultipleOfflinePageItemCallback& callback) const; |
148 void MarkPageAccessedWhenLoadDone(int64_t offline_id); | 151 void MarkPageAccessedWhenLoadDone(int64_t offline_id); |
149 | 152 |
150 void CheckMetadataConsistency(); | 153 void CheckMetadataConsistency(); |
151 | 154 |
152 // Callback for loading pages from the offline page metadata store. | 155 // Callback for loading pages from the offline page metadata store. |
153 void OnLoadDone(const base::TimeTicks& start_time, | 156 void OnLoadDone(const base::TimeTicks& start_time, |
154 OfflinePageMetadataStore::LoadStatus load_status, | 157 OfflinePageMetadataStore::LoadStatus load_status, |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 size_t pages_allowed, | 213 size_t pages_allowed, |
211 const MultipleOfflinePageItemResult& items); | 214 const MultipleOfflinePageItemResult& items); |
212 void OnDeleteOldPagesWithSameURL(DeletePageResult result); | 215 void OnDeleteOldPagesWithSameURL(DeletePageResult result); |
213 | 216 |
214 void CacheLoadedData(const std::vector<OfflinePageItem>& offline_pages); | 217 void CacheLoadedData(const std::vector<OfflinePageItem>& offline_pages); |
215 | 218 |
216 // Actually does the work of deleting, requires the model is loaded. | 219 // Actually does the work of deleting, requires the model is loaded. |
217 void DoDeletePagesByOfflineId(const std::vector<int64_t>& offline_ids, | 220 void DoDeletePagesByOfflineId(const std::vector<int64_t>& offline_ids, |
218 const DeletePageCallback& callback); | 221 const DeletePageCallback& callback); |
219 | 222 |
| 223 // Actually does the work of deleting, requires the model is loaded. |
| 224 void DoDeletePagesByClientIds(const std::vector<ClientId>& client_ids, |
| 225 const DeletePageCallback& callback); |
| 226 |
| 227 void DoGetPagesByClientIds(const std::vector<ClientId>& client_ids, |
| 228 const MultipleOfflinePageItemCallback& callback); |
| 229 |
220 // Similar to DoDeletePagesByOfflineId, does actual work of deleting, and | 230 // Similar to DoDeletePagesByOfflineId, does actual work of deleting, and |
221 // requires that the model is loaded. | 231 // requires that the model is loaded. |
222 void DoDeleteCachedPagesByURLPredicate(const UrlPredicate& predicate, | 232 void DoDeleteCachedPagesByURLPredicate(const UrlPredicate& predicate, |
223 const DeletePageCallback& callback); | 233 const DeletePageCallback& callback); |
224 | 234 |
225 // Callback completing page expiration. | 235 // Callback completing page expiration. |
226 void OnExpirePageDone(const base::Time& expiration_time, | 236 void OnExpirePageDone(const base::Time& expiration_time, |
227 std::unique_ptr<OfflinePagesUpdateResult> result); | 237 std::unique_ptr<OfflinePagesUpdateResult> result); |
228 | 238 |
229 // Clears expired pages if there are any. | 239 // Clears expired pages if there are any. |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
282 base::Clock* testing_clock_; | 292 base::Clock* testing_clock_; |
283 | 293 |
284 base::WeakPtrFactory<OfflinePageModelImpl> weak_ptr_factory_; | 294 base::WeakPtrFactory<OfflinePageModelImpl> weak_ptr_factory_; |
285 | 295 |
286 DISALLOW_COPY_AND_ASSIGN(OfflinePageModelImpl); | 296 DISALLOW_COPY_AND_ASSIGN(OfflinePageModelImpl); |
287 }; | 297 }; |
288 | 298 |
289 } // namespace offline_pages | 299 } // namespace offline_pages |
290 | 300 |
291 #endif // COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_MODEL_IMPL_H_ | 301 #endif // COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_MODEL_IMPL_H_ |
OLD | NEW |