OLD | NEW |
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) 2006 Samuel Weinig (sam.weinig@gmail.com) | 5 Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com) |
6 Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All | 6 Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All |
7 rights reserved. | 7 rights reserved. |
8 | 8 |
9 This library is free software; you can redistribute it and/or | 9 This library is free software; you can redistribute it and/or |
10 modify it under the terms of the GNU Library General Public | 10 modify it under the terms of the GNU Library General Public |
(...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
486 ? std::max(0., response_timestamp - date_value) | 486 ? std::max(0., response_timestamp - date_value) |
487 : 0; | 487 : 0; |
488 double age_value = response.Age(); | 488 double age_value = response.Age(); |
489 double corrected_received_age = std::isfinite(age_value) | 489 double corrected_received_age = std::isfinite(age_value) |
490 ? std::max(apparent_age, age_value) | 490 ? std::max(apparent_age, age_value) |
491 : apparent_age; | 491 : apparent_age; |
492 double resident_time = CurrentTime() - response_timestamp; | 492 double resident_time = CurrentTime() - response_timestamp; |
493 return corrected_received_age + resident_time; | 493 return corrected_received_age + resident_time; |
494 } | 494 } |
495 | 495 |
496 double Resource::CurrentAge() const { | |
497 return blink::CurrentAge(GetResponse(), response_timestamp_); | |
498 } | |
499 | |
500 static double FreshnessLifetime(const ResourceResponse& response, | 496 static double FreshnessLifetime(const ResourceResponse& response, |
501 double response_timestamp) { | 497 double response_timestamp) { |
502 #if !OS(ANDROID) | 498 #if !OS(ANDROID) |
503 // On desktop, local files should be reloaded in case they change. | 499 // On desktop, local files should be reloaded in case they change. |
504 if (response.Url().IsLocalFile()) | 500 if (response.Url().IsLocalFile()) |
505 return 0; | 501 return 0; |
506 #endif | 502 #endif |
507 | 503 |
508 // Cache other non-http / non-filesystem resources liberally. | 504 // Cache other non-http / non-filesystem resources liberally. |
509 if (!response.Url().ProtocolIsInHTTPFamily() && | 505 if (!response.Url().ProtocolIsInHTTPFamily() && |
(...skipping 11 matching lines...) Expand all Loading... |
521 if (std::isfinite(expires_value)) | 517 if (std::isfinite(expires_value)) |
522 return expires_value - creation_time; | 518 return expires_value - creation_time; |
523 double last_modified_value = response.LastModified(); | 519 double last_modified_value = response.LastModified(); |
524 if (std::isfinite(last_modified_value)) | 520 if (std::isfinite(last_modified_value)) |
525 return (creation_time - last_modified_value) * 0.1; | 521 return (creation_time - last_modified_value) * 0.1; |
526 // If no cache headers are present, the specification leaves the decision to | 522 // If no cache headers are present, the specification leaves the decision to |
527 // the UA. Other browsers seem to opt for 0. | 523 // the UA. Other browsers seem to opt for 0. |
528 return 0; | 524 return 0; |
529 } | 525 } |
530 | 526 |
531 double Resource::FreshnessLifetime() const { | |
532 return blink::FreshnessLifetime(GetResponse(), response_timestamp_); | |
533 } | |
534 | |
535 static bool CanUseResponse(const ResourceResponse& response, | 527 static bool CanUseResponse(const ResourceResponse& response, |
536 double response_timestamp) { | 528 double response_timestamp) { |
537 if (response.IsNull()) | 529 if (response.IsNull()) |
538 return false; | 530 return false; |
539 | 531 |
540 // FIXME: Why isn't must-revalidate considered a reason we can't use the | 532 // FIXME: Why isn't must-revalidate considered a reason we can't use the |
541 // response? | 533 // response? |
542 if (response.CacheControlContainsNoCache() || | 534 if (response.CacheControlContainsNoCache() || |
543 response.CacheControlContainsNoStore()) | 535 response.CacheControlContainsNoStore()) |
544 return false; | 536 return false; |
(...skipping 583 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1128 case Resource::kMedia: | 1120 case Resource::kMedia: |
1129 case Resource::kManifest: | 1121 case Resource::kManifest: |
1130 case Resource::kMock: | 1122 case Resource::kMock: |
1131 return false; | 1123 return false; |
1132 } | 1124 } |
1133 NOTREACHED(); | 1125 NOTREACHED(); |
1134 return false; | 1126 return false; |
1135 } | 1127 } |
1136 | 1128 |
1137 } // namespace blink | 1129 } // namespace blink |
OLD | NEW |