Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(58)

Side by Side Diff: components/offline_pages/offline_page_model.h

Issue 2503853004: Support getting offline pages also by original URL (Closed)
Patch Set: Make NTP redirect work per comment Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 30 matching lines...) Expand all
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: 50 public:
51 // Controls how to search on differnt URLs for pages.
52 enum class URLSearchMode {
53 // Match against the last committed URL only.
54 SEARCH_BY_FINAL_URL_ONLY,
55 // Match against all stored URLs, including the last committed URL and
56 // the original request URL.
57 SEARCH_BY_ALL_URLS
58 };
59
51 // Describes the parameters to control how to save a page. 60 // Describes the parameters to control how to save a page.
52 struct SavePageParams { 61 struct SavePageParams {
53 SavePageParams(); 62 SavePageParams();
54 SavePageParams(const SavePageParams& other); 63 SavePageParams(const SavePageParams& other);
55 64
56 // The last committed URL of the page to save. 65 // The last committed URL of the page to save.
57 GURL url; 66 GURL url;
58 67
59 // The identification used by the client. 68 // The identification used by the client.
60 ClientId client_id; 69 ClientId client_id;
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 // Gets all offline ids where the offline page has the matching client id. 162 // Gets all offline ids where the offline page has the matching client id.
154 virtual void GetOfflineIdsForClientId( 163 virtual void GetOfflineIdsForClientId(
155 const ClientId& client_id, 164 const ClientId& client_id,
156 const MultipleOfflineIdCallback& callback) = 0; 165 const MultipleOfflineIdCallback& callback) = 0;
157 166
158 // Returns zero or one offline pages associated with a specified |offline_id|. 167 // Returns zero or one offline pages associated with a specified |offline_id|.
159 virtual void GetPageByOfflineId( 168 virtual void GetPageByOfflineId(
160 int64_t offline_id, 169 int64_t offline_id,
161 const SingleOfflinePageItemCallback& callback) = 0; 170 const SingleOfflinePageItemCallback& callback) = 0;
162 171
163 // Returns the offline pages that are stored under |online_url|. 172 // Returns the offline pages that are related to |url|. |url_search_mode|
164 virtual void GetPagesByOnlineURL( 173 // controls how the url match is done. See URLSearchMode for more details.
165 const GURL& online_url, 174 virtual void GetPagesByURL(
175 const GURL& url,
176 URLSearchMode url_search_mode,
166 const MultipleOfflinePageItemCallback& callback) = 0; 177 const MultipleOfflinePageItemCallback& callback) = 0;
167 178
168 // Marks pages with |offline_ids| as expired and deletes the associated 179 // Marks pages with |offline_ids| as expired and deletes the associated
169 // archive files. 180 // archive files.
170 virtual void ExpirePages(const std::vector<int64_t>& offline_ids, 181 virtual void ExpirePages(const std::vector<int64_t>& offline_ids,
171 const base::Time& expiration_time, 182 const base::Time& expiration_time,
172 const base::Callback<void(bool)>& callback) = 0; 183 const base::Callback<void(bool)>& callback) = 0;
173 184
174 // Returns the policy controller. 185 // Returns the policy controller.
175 virtual ClientPolicyController* GetPolicyController() = 0; 186 virtual ClientPolicyController* GetPolicyController() = 0;
176 187
177 // TODO(dougarnett): Remove this and its uses. 188 // TODO(dougarnett): Remove this and its uses.
178 virtual bool is_loaded() const = 0; 189 virtual bool is_loaded() const = 0;
179 190
180 // Returns the logger. Ownership is retained by the model. 191 // Returns the logger. Ownership is retained by the model.
181 virtual OfflineEventLogger* GetLogger() = 0; 192 virtual OfflineEventLogger* GetLogger() = 0;
182 }; 193 };
183 194
184 } // namespace offline_pages 195 } // namespace offline_pages
185 196
186 #endif // COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_MODEL_H_ 197 #endif // COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_MODEL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698