Chromium Code Reviews| 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 43 | 43 |
| 44 namespace offline_pages { | 44 namespace offline_pages { |
| 45 | 45 |
| 46 static const int64_t kInvalidOfflineId = 0; | 46 static const int64_t kInvalidOfflineId = 0; |
| 47 | 47 |
| 48 struct ClientId; | 48 struct ClientId; |
| 49 struct OfflinePageItem; | 49 struct OfflinePageItem; |
| 50 | 50 |
| 51 class ArchiveManager; | 51 class ArchiveManager; |
| 52 class ClientPolicyController; | 52 class ClientPolicyController; |
| 53 class OfflinePageMetadataStore; | |
| 54 class OfflinePageStorageManager; | 53 class OfflinePageStorageManager; |
| 55 | 54 |
| 56 // Implementation of service for saving pages offline, storing the offline | 55 // Implementation of service for saving pages offline, storing the offline |
| 57 // copy and metadata, and retrieving them upon request. | 56 // copy and metadata, and retrieving them upon request. |
| 58 class OfflinePageModelImpl : public OfflinePageModel, public KeyedService { | 57 class OfflinePageModelImpl : public OfflinePageModel, public KeyedService { |
| 59 public: | 58 public: |
| 60 // 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|. |
| 61 OfflinePageModelImpl( | 60 OfflinePageModelImpl( |
| 62 std::unique_ptr<OfflinePageMetadataStore> store, | 61 std::unique_ptr<OfflinePageMetadataStore> store, |
| 63 const base::FilePath& archives_dir, | 62 const base::FilePath& archives_dir, |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 173 const SavePageCallback& callback, | 172 const SavePageCallback& callback, |
| 174 OfflinePageArchiver* archiver, | 173 OfflinePageArchiver* archiver, |
| 175 OfflinePageArchiver::ArchiverResult result, | 174 OfflinePageArchiver::ArchiverResult result, |
| 176 const GURL& url, | 175 const GURL& url, |
| 177 const base::FilePath& file_path, | 176 const base::FilePath& file_path, |
| 178 const base::string16& title, | 177 const base::string16& title, |
| 179 int64_t file_size); | 178 int64_t file_size); |
| 180 void OnAddOfflinePageDone(OfflinePageArchiver* archiver, | 179 void OnAddOfflinePageDone(OfflinePageArchiver* archiver, |
| 181 const SavePageCallback& callback, | 180 const SavePageCallback& callback, |
| 182 const OfflinePageItem& offline_page, | 181 const OfflinePageItem& offline_page, |
| 183 OfflinePageMetadataStore::ItemActionStatus status); | 182 ItemActionStatus status); |
| 184 void InformSavePageDone(const SavePageCallback& callback, | 183 void InformSavePageDone(const SavePageCallback& callback, |
| 185 SavePageResult result, | 184 SavePageResult result, |
| 186 const ClientId& client_id, | 185 const ClientId& client_id, |
| 187 int64_t offline_id); | 186 int64_t offline_id); |
| 188 void DeletePendingArchiver(OfflinePageArchiver* archiver); | 187 void DeletePendingArchiver(OfflinePageArchiver* archiver); |
| 189 | 188 |
| 190 // Steps for deleting files and data for an offline page. | 189 // Steps for deleting files and data for an offline page. |
| 191 void OnDeleteArchiveFilesDone(const std::vector<int64_t>& offline_ids, | 190 void OnDeleteArchiveFilesDone(const std::vector<int64_t>& offline_ids, |
| 192 const DeletePageCallback& callback, | 191 const DeletePageCallback& callback, |
| 193 bool success); | 192 bool success); |
| 194 void OnRemoveOfflinePagesDone(const std::vector<int64_t>& offline_ids, | 193 void OnRemoveOfflinePagesDone(const DeletePageCallback& callback, |
| 195 const DeletePageCallback& callback, | 194 std::unique_ptr<StoreUpdateResult> result); |
| 196 bool success); | |
| 197 void InformDeletePageDone(const DeletePageCallback& callback, | 195 void InformDeletePageDone(const DeletePageCallback& callback, |
| 198 DeletePageResult result); | 196 DeletePageResult result); |
| 199 | 197 |
| 200 void OnMarkPageAccesseDone(const OfflinePageItem& offline_page_item, | 198 void OnMarkPageAccesseDone(const OfflinePageItem& offline_page_item, |
|
dewittj
2016/09/23 17:21:36
nit: spelling
| |
| 201 bool success); | 199 std::unique_ptr<StoreUpdateResult> result); |
| 202 | 200 |
| 203 // Callbacks for checking metadata consistency. | 201 // Callbacks for checking metadata consistency. |
| 204 void CheckMetadataConsistencyForArchivePaths( | 202 void CheckMetadataConsistencyForArchivePaths( |
| 205 const std::set<base::FilePath>& archive_paths); | 203 const std::set<base::FilePath>& archive_paths); |
| 206 // Callback called after headless archives deleted. Orphaned archives are | 204 // Callback called after headless archives deleted. Orphaned archives are |
| 207 // archives files on disk which are not pointed to by any of the page items | 205 // archives files on disk which are not pointed to by any of the page items |
| 208 // in metadata store. | 206 // in metadata store. |
| 209 void ExpirePagesMissingArchiveFile( | 207 void ExpirePagesMissingArchiveFile( |
| 210 const std::set<base::FilePath>& archive_paths); | 208 const std::set<base::FilePath>& archive_paths); |
| 211 void OnExpirePagesMissingArchiveFileDone( | 209 void OnExpirePagesMissingArchiveFileDone( |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 236 // Actually does the work of deleting, requires the model is loaded. | 234 // Actually does the work of deleting, requires the model is loaded. |
| 237 void DoDeletePagesByOfflineId(const std::vector<int64_t>& offline_ids, | 235 void DoDeletePagesByOfflineId(const std::vector<int64_t>& offline_ids, |
| 238 const DeletePageCallback& callback); | 236 const DeletePageCallback& callback); |
| 239 | 237 |
| 240 // Similar to DoDeletePagesByOfflineId, does actual work of deleting, and | 238 // Similar to DoDeletePagesByOfflineId, does actual work of deleting, and |
| 241 // requires that the model is loaded. | 239 // requires that the model is loaded. |
| 242 void DoDeleteCachedPagesByURLPredicate(const UrlPredicate& predicate, | 240 void DoDeleteCachedPagesByURLPredicate(const UrlPredicate& predicate, |
| 243 const DeletePageCallback& callback); | 241 const DeletePageCallback& callback); |
| 244 | 242 |
| 245 // Callback completing page expiration. | 243 // Callback completing page expiration. |
| 246 void OnExpirePageDone(const std::vector<OfflinePageItem>& expired_pages, | 244 void OnExpirePageDone(const base::Time& expiration_time, |
| 247 const base::Time& expiration_time, | 245 std::unique_ptr<StoreUpdateResult> result); |
| 248 bool success); | |
| 249 | 246 |
| 250 // Clears expired pages if there are any. | 247 // Clears expired pages if there are any. |
| 251 void ClearStorageIfNeeded( | 248 void ClearStorageIfNeeded( |
| 252 const OfflinePageStorageManager::ClearStorageCallback& callback); | 249 const OfflinePageStorageManager::ClearStorageCallback& callback); |
| 253 | 250 |
| 254 // Callback completing storage clearing. | 251 // Callback completing storage clearing. |
| 255 void OnStorageCleared(size_t expired_page_count, | 252 void OnStorageCleared(size_t expired_page_count, |
| 256 OfflinePageStorageManager::ClearStorageResult result); | 253 OfflinePageStorageManager::ClearStorageResult result); |
| 257 | 254 |
| 258 // Post task to clear storage. | 255 // Post task to clear storage. |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 303 base::Clock* testing_clock_; | 300 base::Clock* testing_clock_; |
| 304 | 301 |
| 305 base::WeakPtrFactory<OfflinePageModelImpl> weak_ptr_factory_; | 302 base::WeakPtrFactory<OfflinePageModelImpl> weak_ptr_factory_; |
| 306 | 303 |
| 307 DISALLOW_COPY_AND_ASSIGN(OfflinePageModelImpl); | 304 DISALLOW_COPY_AND_ASSIGN(OfflinePageModelImpl); |
| 308 }; | 305 }; |
| 309 | 306 |
| 310 } // namespace offline_pages | 307 } // namespace offline_pages |
| 311 | 308 |
| 312 #endif // COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_MODEL_IMPL_H_ | 309 #endif // COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_MODEL_IMPL_H_ |
| OLD | NEW |