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

Side by Side Diff: third_party/WebKit/Source/core/fetch/ResourceFetcher.cpp

Issue 1987973002: Reload cache control: remove redundant header insertion from Blink Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: (just rebase to see bots' results again) Created 4 years, 6 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 /* 1 /*
2 Copyright (C) 1998 Lars Knoll (knoll@mpi-hd.mpg.de) 2 Copyright (C) 1998 Lars Knoll (knoll@mpi-hd.mpg.de)
3 Copyright (C) 2001 Dirk Mueller (mueller@kde.org) 3 Copyright (C) 2001 Dirk Mueller (mueller@kde.org)
4 Copyright (C) 2002 Waldo Bastian (bastian@kde.org) 4 Copyright (C) 2002 Waldo Bastian (bastian@kde.org)
5 Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved. 5 Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved.
6 Copyright (C) 2009 Torch Mobile Inc. http://www.torchmobile.com/ 6 Copyright (C) 2009 Torch Mobile Inc. http://www.torchmobile.com/
7 7
8 This library is free software; you can redistribute it and/or 8 This library is free software; you can redistribute it and/or
9 modify it under the terms of the GNU Library General Public 9 modify it under the terms of the GNU Library General Public
10 License as published by the Free Software Foundation; either 10 License as published by the Free Software Foundation; either
(...skipping 556 matching lines...) Expand 10 before | Expand all | Expand 10 after
567 ASSERT(memoryCache()->contains(resource)); 567 ASSERT(memoryCache()->contains(resource));
568 ASSERT(resource->isLoaded()); 568 ASSERT(resource->isLoaded());
569 ASSERT(resource->canUseCacheValidator()); 569 ASSERT(resource->canUseCacheValidator());
570 ASSERT(!resource->isCacheValidator()); 570 ASSERT(!resource->isCacheValidator());
571 ASSERT(!context().isControlledByServiceWorker()); 571 ASSERT(!context().isControlledByServiceWorker());
572 572
573 ResourceRequest revalidatingRequest(resource->resourceRequest()); 573 ResourceRequest revalidatingRequest(resource->resourceRequest());
574 revalidatingRequest.clearHTTPReferrer(); 574 revalidatingRequest.clearHTTPReferrer();
575 initializeResourceRequest(revalidatingRequest, resource->getType(), request. defer()); 575 initializeResourceRequest(revalidatingRequest, resource->getType(), request. defer());
576 576
577 const AtomicString& lastModified = resource->response().httpHeaderField(HTTP Names::Last_Modified); 577 // TODO(toyoshim): Figure out if following code is really needed and
578 const AtomicString& eTag = resource->response().httpHeaderField(HTTPNames::E Tag); 578 // how this code works with Stale-While-Revalidate field trial.
579 if (!lastModified.isEmpty() || !eTag.isEmpty()) {
580 ASSERT(context().getCachePolicy() != CachePolicyReload);
581 if (context().getCachePolicy() == CachePolicyRevalidate)
582 revalidatingRequest.setHTTPHeaderField(HTTPNames::Cache_Control, "ma x-age=0");
583 }
584 if (!lastModified.isEmpty())
585 revalidatingRequest.setHTTPHeaderField(HTTPNames::If_Modified_Since, las tModified);
586 if (!eTag.isEmpty())
587 revalidatingRequest.setHTTPHeaderField(HTTPNames::If_None_Match, eTag);
588
589 double stalenessLifetime = resource->stalenessLifetime(); 579 double stalenessLifetime = resource->stalenessLifetime();
590 if (std::isfinite(stalenessLifetime) && stalenessLifetime > 0) { 580 if (std::isfinite(stalenessLifetime) && stalenessLifetime > 0) {
591 revalidatingRequest.setHTTPHeaderField(HTTPNames::Resource_Freshness, At omicString(String::format("max-age=%.0lf,stale-while-revalidate=%.0lf,age=%.0lf" , resource->freshnessLifetime(), stalenessLifetime, resource->currentAge()))); 581 revalidatingRequest.setHTTPHeaderField(HTTPNames::Resource_Freshness, At omicString(String::format("max-age=%.0lf,stale-while-revalidate=%.0lf,age=%.0lf" , resource->freshnessLifetime(), stalenessLifetime, resource->currentAge())));
592 } 582 }
593 583
594 resource->setRevalidatingRequest(revalidatingRequest); 584 resource->setRevalidatingRequest(revalidatingRequest);
595 } 585 }
596 586
597 Resource* ResourceFetcher::createResourceForLoading(FetchRequest& request, const String& charset, const ResourceFactory& factory) 587 Resource* ResourceFetcher::createResourceForLoading(FetchRequest& request, const String& charset, const ResourceFactory& factory)
598 { 588 {
(...skipping 660 matching lines...) Expand 10 before | Expand all | Expand 10 after
1259 visitor->trace(m_context); 1249 visitor->trace(m_context);
1260 visitor->trace(m_archive); 1250 visitor->trace(m_archive);
1261 visitor->trace(m_loaders); 1251 visitor->trace(m_loaders);
1262 visitor->trace(m_nonBlockingLoaders); 1252 visitor->trace(m_nonBlockingLoaders);
1263 visitor->trace(m_documentResources); 1253 visitor->trace(m_documentResources);
1264 visitor->trace(m_preloads); 1254 visitor->trace(m_preloads);
1265 visitor->trace(m_resourceTimingInfoMap); 1255 visitor->trace(m_resourceTimingInfoMap);
1266 } 1256 }
1267 1257
1268 } // namespace blink 1258 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698