Chromium Code Reviews| 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 11 matching lines...) Expand all Loading... | |
| 22 #include "base/observer_list.h" | 22 #include "base/observer_list.h" |
| 23 #include "base/optional.h" | 23 #include "base/optional.h" |
| 24 #include "base/supports_user_data.h" | 24 #include "base/supports_user_data.h" |
| 25 #include "components/keyed_service/core/keyed_service.h" | 25 #include "components/keyed_service/core/keyed_service.h" |
| 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 #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 class PrefService; | |
| 32 namespace base { | 33 namespace base { |
| 33 class SequencedTaskRunner; | 34 class SequencedTaskRunner; |
| 34 class Time; | 35 class Time; |
| 35 class TimeDelta; | 36 class TimeDelta; |
| 36 class TimeTicks; | 37 class TimeTicks; |
| 37 } | 38 } |
| 38 | 39 |
| 39 namespace offline_pages { | 40 namespace offline_pages { |
| 40 | 41 |
| 41 static const char* const kBookmarkNamespace = "bookmark"; | 42 static const char* const kBookmarkNamespace = "bookmark"; |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 102 static int64_t GenerateOfflineId(); | 103 static int64_t GenerateOfflineId(); |
| 103 | 104 |
| 104 // Returns true if an offline copy can be saved for the given URL. | 105 // Returns true if an offline copy can be saved for the given URL. |
| 105 static bool CanSavePage(const GURL& url); | 106 static bool CanSavePage(const GURL& url); |
| 106 | 107 |
| 107 static base::TimeDelta GetFinalDeletionDelayForTesting(); | 108 static base::TimeDelta GetFinalDeletionDelayForTesting(); |
| 108 | 109 |
| 109 // All blocking calls/disk access will happen on the provided |task_runner|. | 110 // All blocking calls/disk access will happen on the provided |task_runner|. |
| 110 OfflinePageModel(std::unique_ptr<OfflinePageMetadataStore> store, | 111 OfflinePageModel(std::unique_ptr<OfflinePageMetadataStore> store, |
| 111 const base::FilePath& archives_dir, | 112 const base::FilePath& archives_dir, |
| 112 const scoped_refptr<base::SequencedTaskRunner>& task_runner); | 113 const scoped_refptr<base::SequencedTaskRunner>& task_runner, |
| 114 PrefService* prefs); | |
| 113 ~OfflinePageModel() override; | 115 ~OfflinePageModel() override; |
| 114 | 116 |
| 115 void AddObserver(Observer* observer); | 117 void AddObserver(Observer* observer); |
| 116 void RemoveObserver(Observer* observer); | 118 void RemoveObserver(Observer* observer); |
| 117 | 119 |
| 118 // Attempts to save a page addressed by |url| offline. Requires that the model | 120 // Attempts to save a page addressed by |url| offline. Requires that the model |
| 119 // is loaded. Generates a new offline id and returns it. | 121 // is loaded. Generates a new offline id and returns it. |
| 120 void SavePage(const GURL& url, | 122 void SavePage(const GURL& url, |
| 121 const ClientId& client_id, | 123 const ClientId& client_id, |
| 122 std::unique_ptr<OfflinePageArchiver> archiver, | 124 std::unique_ptr<OfflinePageArchiver> archiver, |
| (...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 360 // Delayed tasks that should be invoked after the loading is done. | 362 // Delayed tasks that should be invoked after the loading is done. |
| 361 std::vector<base::Closure> delayed_tasks_; | 363 std::vector<base::Closure> delayed_tasks_; |
| 362 | 364 |
| 363 // Controller of the client policies. | 365 // Controller of the client policies. |
| 364 std::unique_ptr<ClientPolicyController> policy_controller_; | 366 std::unique_ptr<ClientPolicyController> policy_controller_; |
| 365 | 367 |
| 366 // Manager for the storage consumed by archives and responsible for | 368 // Manager for the storage consumed by archives and responsible for |
| 367 // automatic page clearing. | 369 // automatic page clearing. |
| 368 std::unique_ptr<OfflinePageStorageManager> storage_manager_; | 370 std::unique_ptr<OfflinePageStorageManager> storage_manager_; |
| 369 | 371 |
| 372 // PrefService which should be used by the storage manager. | |
|
fgorski
2016/05/17 05:33:29
Not owned.
romax
2016/05/18 02:36:19
removing
| |
| 373 PrefService* prefs_; | |
| 374 | |
| 370 base::WeakPtrFactory<OfflinePageModel> weak_ptr_factory_; | 375 base::WeakPtrFactory<OfflinePageModel> weak_ptr_factory_; |
| 371 | 376 |
| 372 DISALLOW_COPY_AND_ASSIGN(OfflinePageModel); | 377 DISALLOW_COPY_AND_ASSIGN(OfflinePageModel); |
| 373 }; | 378 }; |
| 374 | 379 |
| 375 } // namespace offline_pages | 380 } // namespace offline_pages |
| 376 | 381 |
| 377 #endif // COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_MODEL_H_ | 382 #endif // COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_MODEL_H_ |
| OLD | NEW |