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_event_logger.h" | 16 #include "components/offline_pages/offline_event_logger.h" |
17 #include "components/offline_pages/offline_page_archiver.h" | 17 #include "components/offline_pages/offline_page_archiver.h" |
18 #include "components/offline_pages/offline_page_model_query.h" | 18 #include "components/offline_pages/offline_page_model_query.h" |
19 #include "components/offline_pages/offline_page_storage_manager.h" | 19 #include "components/offline_pages/offline_page_storage_manager.h" |
20 #include "components/offline_pages/offline_page_types.h" | 20 #include "components/offline_pages/offline_page_types.h" |
21 | 21 |
22 class GURL; | 22 class GURL; |
23 namespace base { | |
24 class Time; | |
25 } // namespace base | |
26 | 23 |
27 namespace offline_pages { | 24 namespace offline_pages { |
28 | 25 |
29 struct ClientId; | 26 struct ClientId; |
30 | 27 |
31 // Service for saving pages offline, storing the offline copy and metadata, and | 28 // Service for saving pages offline, storing the offline copy and metadata, and |
32 // retrieving them upon request. | 29 // retrieving them upon request. |
33 // | 30 // |
34 // Example usage: | 31 // Example usage: |
35 // class ArchiverImpl : public OfflinePageArchiver { | 32 // class ArchiverImpl : public OfflinePageArchiver { |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 | 144 |
148 // Returns via callback all GURLs in |urls| that are equal to the online URL | 145 // Returns via callback all GURLs in |urls| that are equal to the online URL |
149 // of any offline page. | 146 // of any offline page. |
150 virtual void CheckPagesExistOffline( | 147 virtual void CheckPagesExistOffline( |
151 const std::set<GURL>& urls, | 148 const std::set<GURL>& urls, |
152 const CheckPagesExistOfflineCallback& callback) = 0; | 149 const CheckPagesExistOfflineCallback& callback) = 0; |
153 | 150 |
154 // Gets all offline pages. | 151 // Gets all offline pages. |
155 virtual void GetAllPages(const MultipleOfflinePageItemCallback& callback) = 0; | 152 virtual void GetAllPages(const MultipleOfflinePageItemCallback& callback) = 0; |
156 | 153 |
157 // Gets all offline pages including expired ones. | |
158 virtual void GetAllPagesWithExpired( | |
159 const MultipleOfflinePageItemCallback& callback) = 0; | |
160 | |
161 // Gets all offline ids where the offline page has the matching client id. | 154 // Gets all offline ids where the offline page has the matching client id. |
162 virtual void GetOfflineIdsForClientId( | 155 virtual void GetOfflineIdsForClientId( |
163 const ClientId& client_id, | 156 const ClientId& client_id, |
164 const MultipleOfflineIdCallback& callback) = 0; | 157 const MultipleOfflineIdCallback& callback) = 0; |
165 | 158 |
166 // Returns zero or one offline pages associated with a specified |offline_id|. | 159 // Returns zero or one offline pages associated with a specified |offline_id|. |
167 virtual void GetPageByOfflineId( | 160 virtual void GetPageByOfflineId( |
168 int64_t offline_id, | 161 int64_t offline_id, |
169 const SingleOfflinePageItemCallback& callback) = 0; | 162 const SingleOfflinePageItemCallback& callback) = 0; |
170 | 163 |
171 // Returns the offline pages that are related to |url|. |url_search_mode| | 164 // Returns the offline pages that are related to |url|. |url_search_mode| |
172 // controls how the url match is done. See URLSearchMode for more details. | 165 // controls how the url match is done. See URLSearchMode for more details. |
173 virtual void GetPagesByURL( | 166 virtual void GetPagesByURL( |
174 const GURL& url, | 167 const GURL& url, |
175 URLSearchMode url_search_mode, | 168 URLSearchMode url_search_mode, |
176 const MultipleOfflinePageItemCallback& callback) = 0; | 169 const MultipleOfflinePageItemCallback& callback) = 0; |
177 | 170 |
178 // Marks pages with |offline_ids| as expired and deletes the associated | |
179 // archive files. | |
180 virtual void ExpirePages(const std::vector<int64_t>& offline_ids, | |
181 const base::Time& expiration_time, | |
182 const base::Callback<void(bool)>& callback) = 0; | |
183 | |
184 // Returns the policy controller. | 171 // Returns the policy controller. |
185 virtual ClientPolicyController* GetPolicyController() = 0; | 172 virtual ClientPolicyController* GetPolicyController() = 0; |
186 | 173 |
187 // TODO(dougarnett): Remove this and its uses. | 174 // TODO(dougarnett): Remove this and its uses. |
188 virtual bool is_loaded() const = 0; | 175 virtual bool is_loaded() const = 0; |
189 | 176 |
190 // Returns the logger. Ownership is retained by the model. | 177 // Returns the logger. Ownership is retained by the model. |
191 virtual OfflineEventLogger* GetLogger() = 0; | 178 virtual OfflineEventLogger* GetLogger() = 0; |
192 }; | 179 }; |
193 | 180 |
194 } // namespace offline_pages | 181 } // namespace offline_pages |
195 | 182 |
196 #endif // COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_MODEL_H_ | 183 #endif // COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_MODEL_H_ |
OLD | NEW |