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

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

Issue 1959393002: Choose the best offline page when given an online URL. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address nits. Created 4 years, 7 months 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 <map> 10 #include <map>
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 // This function is deprecated, and may return |nullptr| even if a page 235 // This function is deprecated, and may return |nullptr| even if a page
236 // exists, depending on the implementation details of OfflinePageModel. 236 // exists, depending on the implementation details of OfflinePageModel.
237 // Use |GetPageByOfflineURL| instead. 237 // Use |GetPageByOfflineURL| instead.
238 const OfflinePageItem* MaybeGetPageByOfflineURL( 238 const OfflinePageItem* MaybeGetPageByOfflineURL(
239 const GURL& offline_url) const; 239 const GURL& offline_url) const;
240 240
241 // Returns the offline pages that are stored under |online_url|. 241 // Returns the offline pages that are stored under |online_url|.
242 void GetPagesByOnlineURL(const GURL& online_url, 242 void GetPagesByOnlineURL(const GURL& online_url,
243 const MultipleOfflinePageItemCallback& callback); 243 const MultipleOfflinePageItemCallback& callback);
244 244
245 // Returns via callback an offline page saved for |online_url|, if any. The
246 // best page is chosen based on creation date; a more recently created offline
247 // page will be preferred over an older one. This API function does not
248 // respect namespaces, as it is used to choose which page is rendered in a
249 // tab. Today all namespaces are treated equally for the purposes of this
250 // selection.
251 void GetBestPageForOnlineURL(const GURL& online_url,
252 const SingleOfflinePageItemCallback callback);
253
245 // Returns an offline page saved for |online_url|. A nullptr is returned if 254 // Returns an offline page saved for |online_url|. A nullptr is returned if
246 // not found. 255 // not found. See |GetBestPageForOnlineURL| for selection criteria.
247 const OfflinePageItem* MaybeGetPageByOnlineURL(const GURL& online_url) const; 256 const OfflinePageItem* MaybeGetBestPageForOnlineURL(
257 const GURL& online_url) const;
248 258
249 // Checks that all of the offline pages have corresponding offline copies. 259 // Checks that all of the offline pages have corresponding offline copies.
250 // If a page is discovered to be missing an offline copy, its offline page 260 // If a page is discovered to be missing an offline copy, its offline page
251 // metadata will be removed and |OfflinePageDeleted| will be sent to model 261 // metadata will be removed and |OfflinePageDeleted| will be sent to model
252 // observers. 262 // observers.
253 void CheckForExternalFileDeletion(); 263 void CheckForExternalFileDeletion();
254 264
255 // Reports the storage histograms related to total size of all stored offline 265 // Reports the storage histograms related to total size of all stored offline
256 // pages. Method is to be called after a page was saved or some pages are 266 // pages. Method is to be called after a page was saved or some pages are
257 // deleted. In the latter case |reporting_after_delete| is set to true. 267 // deleted. In the latter case |reporting_after_delete| is set to true.
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 const MultipleOfflineIdCallback& callback) const; 308 const MultipleOfflineIdCallback& callback) const;
299 void GetPageByOfflineIdWhenLoadDone( 309 void GetPageByOfflineIdWhenLoadDone(
300 int64_t offline_id, 310 int64_t offline_id,
301 const SingleOfflinePageItemCallback& callback) const; 311 const SingleOfflinePageItemCallback& callback) const;
302 void GetPagesByOnlineURLWhenLoadDone( 312 void GetPagesByOnlineURLWhenLoadDone(
303 const GURL& offline_url, 313 const GURL& offline_url,
304 const MultipleOfflinePageItemCallback& callback) const; 314 const MultipleOfflinePageItemCallback& callback) const;
305 void GetPageByOfflineURLWhenLoadDone( 315 void GetPageByOfflineURLWhenLoadDone(
306 const GURL& offline_url, 316 const GURL& offline_url,
307 const SingleOfflinePageItemCallback& callback) const; 317 const SingleOfflinePageItemCallback& callback) const;
318 void GetBestPageForOnlineURLWhenLoadDone(
319 const GURL& online_url,
320 const SingleOfflinePageItemCallback& callback) const;
308 321
309 // Callback for checking whether we have offline pages. 322 // Callback for checking whether we have offline pages.
310 void HasPagesAfterLoadDone(const std::string& name_space, 323 void HasPagesAfterLoadDone(const std::string& name_space,
311 const HasPagesCallback& callback) const; 324 const HasPagesCallback& callback) const;
312 325
313 // Callback for loading pages from the offline page metadata store. 326 // Callback for loading pages from the offline page metadata store.
314 void OnLoadDone(const base::TimeTicks& start_time, 327 void OnLoadDone(const base::TimeTicks& start_time,
315 OfflinePageMetadataStore::LoadStatus load_status, 328 OfflinePageMetadataStore::LoadStatus load_status,
316 const std::vector<OfflinePageItem>& offline_pages); 329 const std::vector<OfflinePageItem>& offline_pages);
317 330
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 std::unique_ptr<OfflinePageStorageManager> storage_manager_; 421 std::unique_ptr<OfflinePageStorageManager> storage_manager_;
409 422
410 base::WeakPtrFactory<OfflinePageModel> weak_ptr_factory_; 423 base::WeakPtrFactory<OfflinePageModel> weak_ptr_factory_;
411 424
412 DISALLOW_COPY_AND_ASSIGN(OfflinePageModel); 425 DISALLOW_COPY_AND_ASSIGN(OfflinePageModel);
413 }; 426 };
414 427
415 } // namespace offline_pages 428 } // namespace offline_pages
416 429
417 #endif // COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_MODEL_H_ 430 #endif // COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_MODEL_H_
OLDNEW
« no previous file with comments | « chrome/browser/android/offline_pages/offline_page_utils.cc ('k') | components/offline_pages/offline_page_model.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698