| 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 30 matching lines...) Expand all Loading... |
| 41 | 41 |
| 42 namespace offline_pages { | 42 namespace offline_pages { |
| 43 | 43 |
| 44 static const int64_t kInvalidOfflineId = 0; | 44 static const int64_t kInvalidOfflineId = 0; |
| 45 | 45 |
| 46 struct ClientId; | 46 struct ClientId; |
| 47 struct OfflinePageItem; | 47 struct OfflinePageItem; |
| 48 | 48 |
| 49 class ArchiveManager; | 49 class ArchiveManager; |
| 50 class ClientPolicyController; | 50 class ClientPolicyController; |
| 51 class DownloadUIAdapter; |
| 51 class OfflinePageMetadataStore; | 52 class OfflinePageMetadataStore; |
| 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, |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 void GetBestPageForOnlineURL( | 105 void GetBestPageForOnlineURL( |
| 105 const GURL& online_url, | 106 const GURL& online_url, |
| 106 const SingleOfflinePageItemCallback callback) override; | 107 const SingleOfflinePageItemCallback callback) override; |
| 107 const OfflinePageItem* MaybeGetBestPageForOnlineURL( | 108 const OfflinePageItem* MaybeGetBestPageForOnlineURL( |
| 108 const GURL& online_url) const override; | 109 const GURL& online_url) const override; |
| 109 void CheckMetadataConsistency() override; | 110 void CheckMetadataConsistency() override; |
| 110 void ExpirePages(const std::vector<int64_t>& offline_ids, | 111 void ExpirePages(const std::vector<int64_t>& offline_ids, |
| 111 const base::Time& expiration_time, | 112 const base::Time& expiration_time, |
| 112 const base::Callback<void(bool)>& callback) override; | 113 const base::Callback<void(bool)>& callback) override; |
| 113 ClientPolicyController* GetPolicyController() override; | 114 ClientPolicyController* GetPolicyController() override; |
| 115 DownloadUIAdapter* GetDownloadUIAdapter() override; |
| 114 | 116 |
| 115 // Methods for testing only: | 117 // Methods for testing only: |
| 116 OfflinePageMetadataStore* GetStoreForTesting(); | 118 OfflinePageMetadataStore* GetStoreForTesting(); |
| 117 | 119 |
| 118 OfflinePageStorageManager* GetStorageManager(); | 120 OfflinePageStorageManager* GetStorageManager(); |
| 119 | 121 |
| 120 bool is_loaded() const override; | 122 bool is_loaded() const override; |
| 121 | 123 |
| 122 OfflineEventLogger* GetLogger() override; | 124 OfflineEventLogger* GetLogger() override; |
| 123 | 125 |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 282 | 284 |
| 283 // Pending archivers owned by this model. | 285 // Pending archivers owned by this model. |
| 284 PendingArchivers pending_archivers_; | 286 PendingArchivers pending_archivers_; |
| 285 | 287 |
| 286 // Delayed tasks that should be invoked after the loading is done. | 288 // Delayed tasks that should be invoked after the loading is done. |
| 287 std::vector<base::Closure> delayed_tasks_; | 289 std::vector<base::Closure> delayed_tasks_; |
| 288 | 290 |
| 289 // Controller of the client policies. | 291 // Controller of the client policies. |
| 290 std::unique_ptr<ClientPolicyController> policy_controller_; | 292 std::unique_ptr<ClientPolicyController> policy_controller_; |
| 291 | 293 |
| 294 // Adapts offline page related structures to Download UI structures. |
| 295 std::unique_ptr<DownloadUIAdapter> download_ui_adapter_; |
| 296 |
| 292 // Manager for the storage consumed by archives and responsible for | 297 // Manager for the storage consumed by archives and responsible for |
| 293 // automatic page clearing. | 298 // automatic page clearing. |
| 294 std::unique_ptr<OfflinePageStorageManager> storage_manager_; | 299 std::unique_ptr<OfflinePageStorageManager> storage_manager_; |
| 295 | 300 |
| 296 // Manager for the offline archive files and directory. | 301 // Manager for the offline archive files and directory. |
| 297 std::unique_ptr<ArchiveManager> archive_manager_; | 302 std::unique_ptr<ArchiveManager> archive_manager_; |
| 298 | 303 |
| 299 // Logger to facilitate recording of events. | 304 // Logger to facilitate recording of events. |
| 300 OfflinePageModelEventLogger offline_event_logger_; | 305 OfflinePageModelEventLogger offline_event_logger_; |
| 301 | 306 |
| 302 base::WeakPtrFactory<OfflinePageModelImpl> weak_ptr_factory_; | 307 base::WeakPtrFactory<OfflinePageModelImpl> weak_ptr_factory_; |
| 303 | 308 |
| 304 DISALLOW_COPY_AND_ASSIGN(OfflinePageModelImpl); | 309 DISALLOW_COPY_AND_ASSIGN(OfflinePageModelImpl); |
| 305 }; | 310 }; |
| 306 | 311 |
| 307 } // namespace offline_pages | 312 } // namespace offline_pages |
| 308 | 313 |
| 309 #endif // COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_MODEL_IMPL_H_ | 314 #endif // COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_MODEL_IMPL_H_ |
| OLD | NEW |