OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/browser/appcache/appcache_update_job.h" | 5 #include "content/browser/appcache/appcache_update_job.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
(...skipping 1454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1465 const GURL& url = found->second; | 1465 const GURL& url = found->second; |
1466 | 1466 |
1467 if (!http_info) { | 1467 if (!http_info) { |
1468 LoadFromNewestCacheFailed(url, NULL); // no response found | 1468 LoadFromNewestCacheFailed(url, NULL); // no response found |
1469 } else { | 1469 } else { |
1470 // Check if response can be re-used according to HTTP caching semantics. | 1470 // Check if response can be re-used according to HTTP caching semantics. |
1471 // Responses with a "vary" header get treated as expired. | 1471 // Responses with a "vary" header get treated as expired. |
1472 const std::string name = "vary"; | 1472 const std::string name = "vary"; |
1473 std::string value; | 1473 std::string value; |
1474 size_t iter = 0; | 1474 size_t iter = 0; |
| 1475 net::HttpResponseHeaders::ExpirationTimes expiration_times = |
| 1476 http_info->headers->GetExpirationTimes(http_info->request_time, |
| 1477 http_info->response_time); |
1475 if (!http_info->headers.get() || | 1478 if (!http_info->headers.get() || |
1476 http_info->headers->RequiresValidation(http_info->request_time, | 1479 base::Time::Now() >= expiration_times.GetExpirationTime() || |
1477 http_info->response_time, | |
1478 base::Time::Now()) || | |
1479 http_info->headers->EnumerateHeader(&iter, name, &value)) { | 1480 http_info->headers->EnumerateHeader(&iter, name, &value)) { |
1480 LoadFromNewestCacheFailed(url, response_info); | 1481 LoadFromNewestCacheFailed(url, response_info); |
1481 } else { | 1482 } else { |
1482 DCHECK(group_->newest_complete_cache()); | 1483 DCHECK(group_->newest_complete_cache()); |
1483 AppCacheEntry* copy_me = group_->newest_complete_cache()->GetEntry(url); | 1484 AppCacheEntry* copy_me = group_->newest_complete_cache()->GetEntry(url); |
1484 DCHECK(copy_me); | 1485 DCHECK(copy_me); |
1485 DCHECK(copy_me->response_id() == response_id); | 1486 DCHECK(copy_me->response_id() == response_id); |
1486 | 1487 |
1487 AppCache::EntryMap::iterator it = url_file_list_.find(url); | 1488 AppCache::EntryMap::iterator it = url_file_list_.find(url); |
1488 DCHECK(it != url_file_list_.end()); | 1489 DCHECK(it != url_file_list_.end()); |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1706 // on this object after we've posted a task to delete ourselves. | 1707 // on this object after we've posted a task to delete ourselves. |
1707 if (group_) { | 1708 if (group_) { |
1708 group_->SetUpdateAppCacheStatus(AppCacheGroup::IDLE); | 1709 group_->SetUpdateAppCacheStatus(AppCacheGroup::IDLE); |
1709 group_ = NULL; | 1710 group_ = NULL; |
1710 } | 1711 } |
1711 | 1712 |
1712 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this); | 1713 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this); |
1713 } | 1714 } |
1714 | 1715 |
1715 } // namespace content | 1716 } // namespace content |
OLD | NEW |