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

Side by Side Diff: chrome/browser/android/offline_pages/offline_page_request_job.cc

Issue 2537563002: Making offline previews freshness configurable (Closed)
Patch Set: Created 4 years 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 #include "chrome/browser/android/offline_pages/offline_page_request_job.h" 5 #include "chrome/browser/android/offline_pages/offline_page_request_job.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 return RequestResult::OFFLINE_PAGE_NOT_FOUND; 305 return RequestResult::OFFLINE_PAGE_NOT_FOUND;
306 306
307 // |web_contents_getter| is passed from IO thread. We need to check if 307 // |web_contents_getter| is passed from IO thread. We need to check if
308 // web contents is still valid. 308 // web contents is still valid.
309 content::WebContents* web_contents = web_contents_getter.Run(); 309 content::WebContents* web_contents = web_contents_getter.Run();
310 if (!web_contents) 310 if (!web_contents)
311 return RequestResult::NO_WEB_CONTENTS; 311 return RequestResult::NO_WEB_CONTENTS;
312 312
313 // If the page is being loaded on a slow network, only use the offline page 313 // If the page is being loaded on a slow network, only use the offline page
314 // if it was created within the past day. 314 // if it was created within the past day.
315 // TODO(romax): Make the constant be policy driven.
316 if (network_state == NetworkState::PROHIBITIVELY_SLOW_NETWORK && 315 if (network_state == NetworkState::PROHIBITIVELY_SLOW_NETWORK &&
317 base::Time::Now() - offline_page->creation_time > 316 base::Time::Now() - offline_page->creation_time >
318 base::TimeDelta::FromDays(1)) { 317 previews::params::OfflinePreviewFreshnessDuration()) {
319 return RequestResult::PAGE_NOT_FRESH; 318 return RequestResult::PAGE_NOT_FRESH;
320 } 319 }
321 320
322 // Since offline page will be loaded, it should be marked as accessed. 321 // Since offline page will be loaded, it should be marked as accessed.
323 OfflinePageModel* offline_page_model = 322 OfflinePageModel* offline_page_model =
324 OfflinePageModelFactory::GetForBrowserContext( 323 OfflinePageModelFactory::GetForBrowserContext(
325 web_contents->GetBrowserContext()); 324 web_contents->GetBrowserContext());
326 // |offline_page_model| cannot be null because OfflinePageRequestInterceptor 325 // |offline_page_model| cannot be null because OfflinePageRequestInterceptor
327 // will not be created under incognito mode. 326 // will not be created under incognito mode.
328 DCHECK(offline_page_model); 327 DCHECK(offline_page_model);
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after
688 687
689 URLRequestJob::NotifyHeadersComplete(); 688 URLRequestJob::NotifyHeadersComplete();
690 } 689 }
691 690
692 void OfflinePageRequestJob::SetDelegateForTesting( 691 void OfflinePageRequestJob::SetDelegateForTesting(
693 std::unique_ptr<Delegate> delegate) { 692 std::unique_ptr<Delegate> delegate) {
694 delegate_ = std::move(delegate); 693 delegate_ = std::move(delegate);
695 } 694 }
696 695
697 } // namespace offline_pages 696 } // namespace offline_pages
OLDNEW
« no previous file with comments | « no previous file | components/previews/core/previews_experiments.h » ('j') | components/previews/core/previews_experiments.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698