| 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 17 matching lines...) Expand all Loading... |
| 28 #include "components/offline_pages/offline_page_storage_manager.h" | 28 #include "components/offline_pages/offline_page_storage_manager.h" |
| 29 #include "components/offline_pages/offline_page_types.h" | 29 #include "components/offline_pages/offline_page_types.h" |
| 30 | 30 |
| 31 class GURL; | 31 class GURL; |
| 32 namespace base { | 32 namespace base { |
| 33 class SequencedTaskRunner; | 33 class SequencedTaskRunner; |
| 34 class Time; | 34 class Time; |
| 35 class TimeDelta; | 35 class TimeDelta; |
| 36 class TimeTicks; | 36 class TimeTicks; |
| 37 } | 37 } |
| 38 namespace rappor { |
| 39 class RapporService; |
| 40 } |
| 38 | 41 |
| 39 namespace offline_pages { | 42 namespace offline_pages { |
| 40 | 43 |
| 41 static const char* const kBookmarkNamespace = "bookmark"; | 44 static const char* const kBookmarkNamespace = "bookmark"; |
| 42 static const int64_t kInvalidOfflineId = 0; | 45 static const int64_t kInvalidOfflineId = 0; |
| 43 | 46 |
| 44 struct ClientId; | 47 struct ClientId; |
| 45 | 48 |
| 46 class ClientPolicyController; | 49 class ClientPolicyController; |
| 47 struct OfflinePageItem; | 50 struct OfflinePageItem; |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 static int64_t GenerateOfflineId(); | 105 static int64_t GenerateOfflineId(); |
| 103 | 106 |
| 104 // Returns true if an offline copy can be saved for the given URL. | 107 // Returns true if an offline copy can be saved for the given URL. |
| 105 static bool CanSavePage(const GURL& url); | 108 static bool CanSavePage(const GURL& url); |
| 106 | 109 |
| 107 static base::TimeDelta GetFinalDeletionDelayForTesting(); | 110 static base::TimeDelta GetFinalDeletionDelayForTesting(); |
| 108 | 111 |
| 109 // All blocking calls/disk access will happen on the provided |task_runner|. | 112 // All blocking calls/disk access will happen on the provided |task_runner|. |
| 110 OfflinePageModel(std::unique_ptr<OfflinePageMetadataStore> store, | 113 OfflinePageModel(std::unique_ptr<OfflinePageMetadataStore> store, |
| 111 const base::FilePath& archives_dir, | 114 const base::FilePath& archives_dir, |
| 115 base::WeakPtr<rappor::RapporService> rappor_service, |
| 112 const scoped_refptr<base::SequencedTaskRunner>& task_runner); | 116 const scoped_refptr<base::SequencedTaskRunner>& task_runner); |
| 113 ~OfflinePageModel() override; | 117 ~OfflinePageModel() override; |
| 114 | 118 |
| 115 void AddObserver(Observer* observer); | 119 void AddObserver(Observer* observer); |
| 116 void RemoveObserver(Observer* observer); | 120 void RemoveObserver(Observer* observer); |
| 117 | 121 |
| 118 // Attempts to save a page addressed by |url| offline. Requires that the model | 122 // Attempts to save a page addressed by |url| offline. Requires that the model |
| 119 // is loaded. Generates a new offline id and returns it. | 123 // is loaded. Generates a new offline id and returns it. |
| 120 void SavePage(const GURL& url, | 124 void SavePage(const GURL& url, |
| 121 const ClientId& client_id, | 125 const ClientId& client_id, |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 360 // Delayed tasks that should be invoked after the loading is done. | 364 // Delayed tasks that should be invoked after the loading is done. |
| 361 std::vector<base::Closure> delayed_tasks_; | 365 std::vector<base::Closure> delayed_tasks_; |
| 362 | 366 |
| 363 // Controller of the client policies. | 367 // Controller of the client policies. |
| 364 std::unique_ptr<ClientPolicyController> policy_controller_; | 368 std::unique_ptr<ClientPolicyController> policy_controller_; |
| 365 | 369 |
| 366 // Manager for the storage consumed by archives and responsible for | 370 // Manager for the storage consumed by archives and responsible for |
| 367 // automatic page clearing. | 371 // automatic page clearing. |
| 368 std::unique_ptr<OfflinePageStorageManager> storage_manager_; | 372 std::unique_ptr<OfflinePageStorageManager> storage_manager_; |
| 369 | 373 |
| 374 base::WeakPtr<rappor::RapporService> rappor_service_; |
| 375 |
| 370 base::WeakPtrFactory<OfflinePageModel> weak_ptr_factory_; | 376 base::WeakPtrFactory<OfflinePageModel> weak_ptr_factory_; |
| 371 | 377 |
| 372 DISALLOW_COPY_AND_ASSIGN(OfflinePageModel); | 378 DISALLOW_COPY_AND_ASSIGN(OfflinePageModel); |
| 373 }; | 379 }; |
| 374 | 380 |
| 375 } // namespace offline_pages | 381 } // namespace offline_pages |
| 376 | 382 |
| 377 #endif // COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_MODEL_H_ | 383 #endif // COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_MODEL_H_ |
| OLD | NEW |