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> |
(...skipping 28 matching lines...) Expand all Loading... |
39 // ... | 39 // ... |
40 // } | 40 // } |
41 // | 41 // |
42 // // In code using the OfflinePagesModel to save a page: | 42 // // In code using the OfflinePagesModel to save a page: |
43 // std::unique_ptr<ArchiverImpl> archiver(new ArchiverImpl()); | 43 // std::unique_ptr<ArchiverImpl> archiver(new ArchiverImpl()); |
44 // // Callback is of type SavePageCallback. | 44 // // Callback is of type SavePageCallback. |
45 // model->SavePage(url, std::move(archiver), callback); | 45 // model->SavePage(url, std::move(archiver), callback); |
46 // | 46 // |
47 // TODO(fgorski): Things to describe: | 47 // TODO(fgorski): Things to describe: |
48 // * how to cancel requests and what to expect | 48 // * how to cancel requests and what to expect |
49 class OfflinePageModel : public base::SupportsUserData, | 49 class OfflinePageModel : public base::SupportsUserData { |
50 public OfflinePageStorageManager::Client { | |
51 public: | 50 public: |
52 // Observer of the OfflinePageModel. | 51 // Observer of the OfflinePageModel. |
53 class Observer { | 52 class Observer { |
54 public: | 53 public: |
55 // Invoked when the model has finished loading. | 54 // Invoked when the model has finished loading. |
56 virtual void OfflinePageModelLoaded(OfflinePageModel* model) = 0; | 55 virtual void OfflinePageModelLoaded(OfflinePageModel* model) = 0; |
57 | 56 |
58 // Invoked when the model is being updated, due to adding, removing or | 57 // Invoked when the model is being updated, due to adding, removing or |
59 // updating an offline page. | 58 // updating an offline page. |
60 virtual void OfflinePageModelChanged(OfflinePageModel* model) = 0; | 59 virtual void OfflinePageModelChanged(OfflinePageModel* model) = 0; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 virtual void SavePage(const GURL& url, | 92 virtual void SavePage(const GURL& url, |
94 const ClientId& client_id, | 93 const ClientId& client_id, |
95 std::unique_ptr<OfflinePageArchiver> archiver, | 94 std::unique_ptr<OfflinePageArchiver> archiver, |
96 const SavePageCallback& callback) = 0; | 95 const SavePageCallback& callback) = 0; |
97 | 96 |
98 // Marks that the offline page related to the passed |offline_id| has been | 97 // Marks that the offline page related to the passed |offline_id| has been |
99 // accessed. Its access info, including last access time and access count, | 98 // accessed. Its access info, including last access time and access count, |
100 // will be updated. Requires that the model is loaded. | 99 // will be updated. Requires that the model is loaded. |
101 virtual void MarkPageAccessed(int64_t offline_id) = 0; | 100 virtual void MarkPageAccessed(int64_t offline_id) = 0; |
102 | 101 |
103 // TODO(romax): Pull this interface up from OfflinePageStorageManager::Client | |
104 // void DeletePagesByOfflineId(const std::vector<int64_t>& offline_ids, | |
105 // const DeletePageCallback& callback); | |
106 | |
107 // Wipes out all the data by deleting all saved files and clearing the store. | 102 // Wipes out all the data by deleting all saved files and clearing the store. |
108 virtual void ClearAll(const base::Closure& callback) = 0; | 103 virtual void ClearAll(const base::Closure& callback) = 0; |
109 | 104 |
| 105 // Deletes pages based on |ofline_ids|. |
| 106 virtual void DeletePagesByOfflineId(const std::vector<int64_t>& offline_ids, |
| 107 const DeletePageCallback& callback) = 0; |
| 108 |
110 // Deletes offline pages matching the URL predicate. | 109 // Deletes offline pages matching the URL predicate. |
111 virtual void DeletePagesByURLPredicate( | 110 virtual void DeletePagesByURLPredicate( |
112 const UrlPredicate& predicate, | 111 const UrlPredicate& predicate, |
113 const DeletePageCallback& callback) = 0; | 112 const DeletePageCallback& callback) = 0; |
114 | 113 |
115 // Returns true via callback if there are offline pages in the given | 114 // Returns true via callback if there are offline pages in the given |
116 // |name_space|. | 115 // |name_space|. |
117 virtual void HasPages(const std::string& name_space, | 116 virtual void HasPages(const std::string& name_space, |
118 const HasPagesCallback& callback) = 0; | 117 const HasPagesCallback& callback) = 0; |
119 | 118 |
120 // Returns via callback all GURLs in |urls| that are equal to the online URL | 119 // Returns via callback all GURLs in |urls| that are equal to the online URL |
121 // of any offline page. | 120 // of any offline page. |
122 virtual void CheckPagesExistOffline( | 121 virtual void CheckPagesExistOffline( |
123 const std::set<GURL>& urls, | 122 const std::set<GURL>& urls, |
124 const CheckPagesExistOfflineCallback& callback) = 0; | 123 const CheckPagesExistOfflineCallback& callback) = 0; |
125 | 124 |
| 125 // Gets all offline pages. |
| 126 virtual void GetAllPages(const MultipleOfflinePageItemCallback& callback) = 0; |
| 127 |
126 // Gets all offline ids where the offline page has the matching client id. | 128 // Gets all offline ids where the offline page has the matching client id. |
127 virtual void GetOfflineIdsForClientId( | 129 virtual void GetOfflineIdsForClientId( |
128 const ClientId& client_id, | 130 const ClientId& client_id, |
129 const MultipleOfflineIdCallback& callback) = 0; | 131 const MultipleOfflineIdCallback& callback) = 0; |
130 | 132 |
131 // Gets all offline ids where the offline page has the matching client id. | 133 // Gets all offline ids where the offline page has the matching client id. |
132 // Requires that the model is loaded. May not return matching IDs depending | 134 // Requires that the model is loaded. May not return matching IDs depending |
133 // on the internal state of the model. | 135 // on the internal state of the model. |
134 // | 136 // |
135 // This function is deprecated. Use |GetOfflineIdsForClientId| instead. | 137 // This function is deprecated. Use |GetOfflineIdsForClientId| instead. |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 // not found. See |GetBestPageForOnlineURL| for selection criteria. | 181 // not found. See |GetBestPageForOnlineURL| for selection criteria. |
180 virtual const OfflinePageItem* MaybeGetBestPageForOnlineURL( | 182 virtual const OfflinePageItem* MaybeGetBestPageForOnlineURL( |
181 const GURL& online_url) const = 0; | 183 const GURL& online_url) const = 0; |
182 | 184 |
183 // Checks that all of the offline pages have corresponding offline copies. | 185 // Checks that all of the offline pages have corresponding offline copies. |
184 // If a page is discovered to be missing an offline copy, its offline page | 186 // If a page is discovered to be missing an offline copy, its offline page |
185 // metadata will be removed and |OfflinePageDeleted| will be sent to model | 187 // metadata will be removed and |OfflinePageDeleted| will be sent to model |
186 // observers. | 188 // observers. |
187 virtual void CheckForExternalFileDeletion() = 0; | 189 virtual void CheckForExternalFileDeletion() = 0; |
188 | 190 |
| 191 // Marks pages with |offline_ids| as expired and deletes the associated |
| 192 // archive files. |
| 193 virtual void ExpirePages(const std::vector<int64_t>& offline_ids, |
| 194 const base::Time& expiration_time, |
| 195 const base::Callback<void(bool)>& callback) = 0; |
| 196 |
189 // Returns the policy controller. | 197 // Returns the policy controller. |
190 virtual ClientPolicyController* GetPolicyController() = 0; | 198 virtual ClientPolicyController* GetPolicyController() = 0; |
191 | 199 |
192 // TODO(dougarnett): Remove this and its uses. | 200 // TODO(dougarnett): Remove this and its uses. |
193 virtual bool is_loaded() const = 0; | 201 virtual bool is_loaded() const = 0; |
194 }; | 202 }; |
195 | 203 |
196 } // namespace offline_pages | 204 } // namespace offline_pages |
197 | 205 |
198 #endif // COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_MODEL_H_ | 206 #endif // COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_MODEL_H_ |
OLD | NEW |