| 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 class TimeTicks; | 42 class TimeTicks; |
| 43 } // namespace base | 43 } // namespace base |
| 44 | 44 |
| 45 namespace offline_pages { | 45 namespace offline_pages { |
| 46 | 46 |
| 47 struct ClientId; | 47 struct ClientId; |
| 48 struct OfflinePageItem; | 48 struct OfflinePageItem; |
| 49 | 49 |
| 50 class ArchiveManager; | 50 class ArchiveManager; |
| 51 class ClientPolicyController; | 51 class ClientPolicyController; |
| 52 class OfflinePageModelQuery; |
| 52 class OfflinePageStorageManager; | 53 class OfflinePageStorageManager; |
| 53 | 54 |
| 54 // Implementation of service for saving pages offline, storing the offline | 55 // Implementation of service for saving pages offline, storing the offline |
| 55 // copy and metadata, and retrieving them upon request. | 56 // copy and metadata, and retrieving them upon request. |
| 56 class OfflinePageModelImpl : public OfflinePageModel, public KeyedService { | 57 class OfflinePageModelImpl : public OfflinePageModel, public KeyedService { |
| 57 public: | 58 public: |
| 58 // All blocking calls/disk access will happen on the provided |task_runner|. | 59 // All blocking calls/disk access will happen on the provided |task_runner|. |
| 59 OfflinePageModelImpl( | 60 OfflinePageModelImpl( |
| 60 std::unique_ptr<OfflinePageMetadataStore> store, | 61 std::unique_ptr<OfflinePageMetadataStore> store, |
| 61 const base::FilePath& archives_dir, | 62 const base::FilePath& archives_dir, |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 OfflineEventLogger* GetLogger() override; | 114 OfflineEventLogger* GetLogger() override; |
| 114 | 115 |
| 115 protected: | 116 protected: |
| 116 // Adding a protected constructor for testing-only purposes in | 117 // Adding a protected constructor for testing-only purposes in |
| 117 // offline_page_storage_manager_unittest.cc | 118 // offline_page_storage_manager_unittest.cc |
| 118 OfflinePageModelImpl(); | 119 OfflinePageModelImpl(); |
| 119 | 120 |
| 120 private: | 121 private: |
| 121 FRIEND_TEST_ALL_PREFIXES(OfflinePageModelImplTest, MarkPageForDeletion); | 122 FRIEND_TEST_ALL_PREFIXES(OfflinePageModelImplTest, MarkPageForDeletion); |
| 122 | 123 |
| 123 enum class GetAllPageMode { | 124 typedef ScopedVector<OfflinePageArchiver> PendingArchivers; |
| 124 ALL, // Get all active page entries. | |
| 125 ALL_WITH_EXPIRED, // Get all pages entries including expired ones. | |
| 126 }; | |
| 127 | 125 |
| 128 typedef ScopedVector<OfflinePageArchiver> PendingArchivers; | 126 void ExecuteQuery(std::unique_ptr<OfflinePageModelQuery> query, |
| 127 const MultipleOfflinePageItemCallback& callback); |
| 129 | 128 |
| 130 // Callback for ensuring archive directory is created. | 129 // Callback for ensuring archive directory is created. |
| 131 void OnEnsureArchivesDirCreatedDone(const base::TimeTicks& start_time); | 130 void OnEnsureArchivesDirCreatedDone(const base::TimeTicks& start_time); |
| 132 | 131 |
| 133 void GetAllPagesAfterLoadDone( | |
| 134 GetAllPageMode mode, | |
| 135 const MultipleOfflinePageItemCallback& callback) const; | |
| 136 void CheckPagesExistOfflineAfterLoadDone( | 132 void CheckPagesExistOfflineAfterLoadDone( |
| 137 const std::set<GURL>& urls, | 133 const std::set<GURL>& urls, |
| 138 const CheckPagesExistOfflineCallback& callback); | 134 const CheckPagesExistOfflineCallback& callback); |
| 139 void GetOfflineIdsForClientIdWhenLoadDone( | 135 void GetOfflineIdsForClientIdWhenLoadDone( |
| 140 const ClientId& client_id, | 136 const ClientId& client_id, |
| 141 const MultipleOfflineIdCallback& callback) const; | 137 const MultipleOfflineIdCallback& callback) const; |
| 142 void GetPageByOfflineIdWhenLoadDone( | 138 void GetPageByOfflineIdWhenLoadDone( |
| 143 int64_t offline_id, | 139 int64_t offline_id, |
| 144 const SingleOfflinePageItemCallback& callback) const; | 140 const SingleOfflinePageItemCallback& callback) const; |
| 145 const std::vector<int64_t> MaybeGetOfflineIdsForClientId( | 141 const std::vector<int64_t> MaybeGetOfflineIdsForClientId( |
| 146 const ClientId& client_id) const; | 142 const ClientId& client_id) const; |
| 147 const OfflinePageItem* MaybeGetPageByOfflineId(int64_t offline_id) const; | |
| 148 void GetPagesByOnlineURLWhenLoadDone( | 143 void GetPagesByOnlineURLWhenLoadDone( |
| 149 const GURL& online_url, | 144 const GURL& online_url, |
| 150 const MultipleOfflinePageItemCallback& callback) const; | 145 const MultipleOfflinePageItemCallback& callback) const; |
| 151 void MarkPageAccessedWhenLoadDone(int64_t offline_id); | 146 void MarkPageAccessedWhenLoadDone(int64_t offline_id); |
| 152 | 147 |
| 153 void CheckMetadataConsistency(); | 148 void CheckMetadataConsistency(); |
| 154 | 149 |
| 155 // Callback for loading pages from the offline page metadata store. | 150 // Callback for loading pages from the offline page metadata store. |
| 156 void OnLoadDone(const base::TimeTicks& start_time, | 151 void OnLoadDone(const base::TimeTicks& start_time, |
| 157 OfflinePageMetadataStore::LoadStatus load_status, | 152 OfflinePageMetadataStore::LoadStatus load_status, |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 const MultipleOfflinePageItemResult& items); | 209 const MultipleOfflinePageItemResult& items); |
| 215 void OnDeleteOldPagesWithSameURL(DeletePageResult result); | 210 void OnDeleteOldPagesWithSameURL(DeletePageResult result); |
| 216 | 211 |
| 217 void CacheLoadedData(const std::vector<OfflinePageItem>& offline_pages); | 212 void CacheLoadedData(const std::vector<OfflinePageItem>& offline_pages); |
| 218 | 213 |
| 219 // Actually does the work of deleting, requires the model is loaded. | 214 // Actually does the work of deleting, requires the model is loaded. |
| 220 void DoDeletePagesByOfflineId(const std::vector<int64_t>& offline_ids, | 215 void DoDeletePagesByOfflineId(const std::vector<int64_t>& offline_ids, |
| 221 const DeletePageCallback& callback); | 216 const DeletePageCallback& callback); |
| 222 | 217 |
| 223 // Actually does the work of deleting, requires the model is loaded. | 218 // Actually does the work of deleting, requires the model is loaded. |
| 224 void DoDeletePagesByClientIds(const std::vector<ClientId>& client_ids, | 219 void DeletePages(const DeletePageCallback& callback, |
| 225 const DeletePageCallback& callback); | 220 const MultipleOfflinePageItemResult& items); |
| 226 | 221 |
| 227 void DoGetPagesByClientIds(const std::vector<ClientId>& client_ids, | 222 void DoGetPagesByClientIds(const std::vector<ClientId>& client_ids, |
| 228 const MultipleOfflinePageItemCallback& callback); | 223 const MultipleOfflinePageItemCallback& callback); |
| 229 | 224 |
| 230 // Similar to DoDeletePagesByOfflineId, does actual work of deleting, and | 225 // Similar to DoDeletePagesByOfflineId, does actual work of deleting, and |
| 231 // requires that the model is loaded. | 226 // requires that the model is loaded. |
| 232 void DoDeleteCachedPagesByURLPredicate(const UrlPredicate& predicate, | 227 void DoDeleteCachedPagesByURLPredicate(const UrlPredicate& predicate, |
| 233 const DeletePageCallback& callback); | 228 const DeletePageCallback& callback); |
| 234 | 229 |
| 235 // Callback completing page expiration. | 230 // Callback completing page expiration. |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 base::Clock* testing_clock_; | 287 base::Clock* testing_clock_; |
| 293 | 288 |
| 294 base::WeakPtrFactory<OfflinePageModelImpl> weak_ptr_factory_; | 289 base::WeakPtrFactory<OfflinePageModelImpl> weak_ptr_factory_; |
| 295 | 290 |
| 296 DISALLOW_COPY_AND_ASSIGN(OfflinePageModelImpl); | 291 DISALLOW_COPY_AND_ASSIGN(OfflinePageModelImpl); |
| 297 }; | 292 }; |
| 298 | 293 |
| 299 } // namespace offline_pages | 294 } // namespace offline_pages |
| 300 | 295 |
| 301 #endif // COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_MODEL_IMPL_H_ | 296 #endif // COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_MODEL_IMPL_H_ |
| OLD | NEW |