| OLD | NEW |
| 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 <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 #include "components/offline_pages/offline_page_archiver.h" | 26 #include "components/offline_pages/offline_page_archiver.h" |
| 27 #include "components/offline_pages/offline_page_metadata_store.h" | 27 #include "components/offline_pages/offline_page_metadata_store.h" |
| 28 | 28 |
| 29 class GURL; | 29 class GURL; |
| 30 namespace base { | 30 namespace base { |
| 31 class SequencedTaskRunner; | 31 class SequencedTaskRunner; |
| 32 class Time; | 32 class Time; |
| 33 class TimeDelta; | 33 class TimeDelta; |
| 34 class TimeTicks; | 34 class TimeTicks; |
| 35 } | 35 } |
| 36 namespace rappor { |
| 37 class RapporService; |
| 38 } |
| 36 | 39 |
| 37 namespace offline_pages { | 40 namespace offline_pages { |
| 38 | 41 |
| 39 static const char* const kBookmarkNamespace = "bookmark"; | 42 static const char* const kBookmarkNamespace = "bookmark"; |
| 40 static const int64_t kInvalidOfflineId = 0; | 43 static const int64_t kInvalidOfflineId = 0; |
| 41 | 44 |
| 42 struct ClientId; | 45 struct ClientId; |
| 43 | 46 |
| 44 class ClientPolicyController; | 47 class ClientPolicyController; |
| 45 struct OfflinePageItem; | 48 struct OfflinePageItem; |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 static int64_t GenerateOfflineId(); | 152 static int64_t GenerateOfflineId(); |
| 150 | 153 |
| 151 // Returns true if an offline copy can be saved for the given URL. | 154 // Returns true if an offline copy can be saved for the given URL. |
| 152 static bool CanSavePage(const GURL& url); | 155 static bool CanSavePage(const GURL& url); |
| 153 | 156 |
| 154 static base::TimeDelta GetFinalDeletionDelayForTesting(); | 157 static base::TimeDelta GetFinalDeletionDelayForTesting(); |
| 155 | 158 |
| 156 // All blocking calls/disk access will happen on the provided |task_runner|. | 159 // All blocking calls/disk access will happen on the provided |task_runner|. |
| 157 OfflinePageModel(std::unique_ptr<OfflinePageMetadataStore> store, | 160 OfflinePageModel(std::unique_ptr<OfflinePageMetadataStore> store, |
| 158 const base::FilePath& archives_dir, | 161 const base::FilePath& archives_dir, |
| 162 base::WeakPtr<rappor::RapporService> rappor_service, |
| 159 const scoped_refptr<base::SequencedTaskRunner>& task_runner); | 163 const scoped_refptr<base::SequencedTaskRunner>& task_runner); |
| 160 ~OfflinePageModel() override; | 164 ~OfflinePageModel() override; |
| 161 | 165 |
| 162 void AddObserver(Observer* observer); | 166 void AddObserver(Observer* observer); |
| 163 void RemoveObserver(Observer* observer); | 167 void RemoveObserver(Observer* observer); |
| 164 | 168 |
| 165 // Attempts to save a page addressed by |url| offline. Requires that the model | 169 // Attempts to save a page addressed by |url| offline. Requires that the model |
| 166 // is loaded. Generates a new offline id and returns it. | 170 // is loaded. Generates a new offline id and returns it. |
| 167 void SavePage(const GURL& url, | 171 void SavePage(const GURL& url, |
| 168 const ClientId& client_id, | 172 const ClientId& client_id, |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 400 // Delayed tasks that should be invoked after the loading is done. | 404 // Delayed tasks that should be invoked after the loading is done. |
| 401 std::vector<base::Closure> delayed_tasks_; | 405 std::vector<base::Closure> delayed_tasks_; |
| 402 | 406 |
| 403 // Controller of the client policies. | 407 // Controller of the client policies. |
| 404 std::unique_ptr<ClientPolicyController> policy_controller_; | 408 std::unique_ptr<ClientPolicyController> policy_controller_; |
| 405 | 409 |
| 406 // Manager for the storage consumed by archives and responsible for | 410 // Manager for the storage consumed by archives and responsible for |
| 407 // automatic page clearing. | 411 // automatic page clearing. |
| 408 std::unique_ptr<OfflinePageStorageManager> storage_manager_; | 412 std::unique_ptr<OfflinePageStorageManager> storage_manager_; |
| 409 | 413 |
| 414 base::WeakPtr<rappor::RapporService> rappor_service_; |
| 415 |
| 410 base::WeakPtrFactory<OfflinePageModel> weak_ptr_factory_; | 416 base::WeakPtrFactory<OfflinePageModel> weak_ptr_factory_; |
| 411 | 417 |
| 412 DISALLOW_COPY_AND_ASSIGN(OfflinePageModel); | 418 DISALLOW_COPY_AND_ASSIGN(OfflinePageModel); |
| 413 }; | 419 }; |
| 414 | 420 |
| 415 } // namespace offline_pages | 421 } // namespace offline_pages |
| 416 | 422 |
| 417 #endif // COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_MODEL_H_ | 423 #endif // COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_MODEL_H_ |
| OLD | NEW |