| 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 <memory> | 10 #include <memory> |
| 11 #include <set> | 11 #include <set> |
| 12 #include <string> | 12 #include <string> |
| 13 #include <vector> | 13 #include <vector> |
| 14 | 14 |
| 15 #include "base/supports_user_data.h" | 15 #include "base/supports_user_data.h" |
| 16 #include "components/offline_pages/offline_page_archiver.h" | 16 #include "components/offline_pages/offline_page_archiver.h" |
| 17 #include "components/offline_pages/offline_page_storage_manager.h" | 17 #include "components/offline_pages/offline_page_storage_manager.h" |
| 18 #include "components/offline_pages/offline_page_types.h" | 18 #include "components/offline_pages/offline_page_types.h" |
| 19 | 19 |
| 20 class GURL; | 20 class GURL; |
| 21 namespace base { | 21 namespace base { |
| 22 class Time; | 22 class Time; |
| 23 } // namespace base | 23 } // namespace base |
| 24 | 24 |
| 25 namespace offline_pages { | 25 namespace offline_pages { |
| 26 | 26 |
| 27 static const char* const kBookmarkNamespace = "bookmark"; | 27 static const char* const kBookmarkNamespace = "bookmark"; |
| 28 static const int64_t kInvalidOfflineId = 0; | |
| 29 | 28 |
| 30 struct ClientId; | 29 struct ClientId; |
| 31 struct OfflinePageItem; | 30 struct OfflinePageItem; |
| 32 | 31 |
| 33 // Service for saving pages offline, storing the offline copy and metadata, and | 32 // Service for saving pages offline, storing the offline copy and metadata, and |
| 34 // retrieving them upon request. | 33 // retrieving them upon request. |
| 35 // | 34 // |
| 36 // Example usage: | 35 // Example usage: |
| 37 // class ArchiverImpl : public OfflinePageArchiver { | 36 // class ArchiverImpl : public OfflinePageArchiver { |
| 38 // // This is a class that knows how to create archiver | 37 // // This is a class that knows how to create archiver |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 | 71 |
| 73 using CheckPagesExistOfflineResult = | 72 using CheckPagesExistOfflineResult = |
| 74 offline_pages::CheckPagesExistOfflineResult; | 73 offline_pages::CheckPagesExistOfflineResult; |
| 75 using MultipleOfflinePageItemResult = | 74 using MultipleOfflinePageItemResult = |
| 76 offline_pages::MultipleOfflinePageItemResult; | 75 offline_pages::MultipleOfflinePageItemResult; |
| 77 using SingleOfflinePageItemResult = | 76 using SingleOfflinePageItemResult = |
| 78 offline_pages::SingleOfflinePageItemResult; | 77 offline_pages::SingleOfflinePageItemResult; |
| 79 using DeletePageResult = offline_pages::DeletePageResult; | 78 using DeletePageResult = offline_pages::DeletePageResult; |
| 80 using SavePageResult = offline_pages::SavePageResult; | 79 using SavePageResult = offline_pages::SavePageResult; |
| 81 | 80 |
| 82 // Returns true if an offline copy can be saved for the given URL. | 81 // Returns true if saving an offline page may be attempted for |url|. |
| 83 // TODO(dougarnett): Consider renaming and moving to Utils. | 82 static bool CanSaveURL(const GURL& url); |
| 84 static bool CanSavePage(const GURL& url); | |
| 85 | 83 |
| 86 OfflinePageModel(); | 84 OfflinePageModel(); |
| 87 ~OfflinePageModel() override; | 85 ~OfflinePageModel() override; |
| 88 | 86 |
| 89 virtual void AddObserver(Observer* observer) = 0; | 87 virtual void AddObserver(Observer* observer) = 0; |
| 90 virtual void RemoveObserver(Observer* observer) = 0; | 88 virtual void RemoveObserver(Observer* observer) = 0; |
| 91 | 89 |
| 92 // Attempts to save a page addressed by |url| offline. Requires that the model | 90 // Attempts to save a page addressed by |url| offline. Requires that the model |
| 93 // is loaded. Generates a new offline id and returns it. | 91 // is loaded. Generates a new offline id and returns it. |
| 94 virtual void SavePage(const GURL& url, | 92 virtual void SavePage(const GURL& url, |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 // Returns the policy controller. | 188 // Returns the policy controller. |
| 191 virtual ClientPolicyController* GetPolicyController() = 0; | 189 virtual ClientPolicyController* GetPolicyController() = 0; |
| 192 | 190 |
| 193 // TODO(dougarnett): Remove this and its uses. | 191 // TODO(dougarnett): Remove this and its uses. |
| 194 virtual bool is_loaded() const = 0; | 192 virtual bool is_loaded() const = 0; |
| 195 }; | 193 }; |
| 196 | 194 |
| 197 } // namespace offline_pages | 195 } // namespace offline_pages |
| 198 | 196 |
| 199 #endif // COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_MODEL_H_ | 197 #endif // COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_MODEL_H_ |
| OLD | NEW |