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 "webkit/browser/appcache/appcache_update_job.h" | 5 #include "webkit/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/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
(...skipping 1219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1230 const GURL& url = found->second; | 1230 const GURL& url = found->second; |
1231 | 1231 |
1232 if (!http_info) { | 1232 if (!http_info) { |
1233 LoadFromNewestCacheFailed(url, NULL); // no response found | 1233 LoadFromNewestCacheFailed(url, NULL); // no response found |
1234 } else { | 1234 } else { |
1235 // Check if response can be re-used according to HTTP caching semantics. | 1235 // Check if response can be re-used according to HTTP caching semantics. |
1236 // Responses with a "vary" header get treated as expired. | 1236 // Responses with a "vary" header get treated as expired. |
1237 const std::string name = "vary"; | 1237 const std::string name = "vary"; |
1238 std::string value; | 1238 std::string value; |
1239 void* iter = NULL; | 1239 void* iter = NULL; |
1240 if (!http_info->headers.get() || | 1240 base::Time expiration_time = base::Time(); |
1241 http_info->headers->RequiresValidation(http_info->request_time, | 1241 if (http_info->headers) { |
1242 http_info->response_time, | 1242 expiration_time = http_info->headers->GetExpirationTime( |
1243 base::Time::Now()) || | 1243 http_info->request_time, http_info->response_time); |
| 1244 } |
| 1245 if (expiration_time <= base::Time::Now() || |
1244 http_info->headers->EnumerateHeader(&iter, name, &value)) { | 1246 http_info->headers->EnumerateHeader(&iter, name, &value)) { |
1245 LoadFromNewestCacheFailed(url, response_info); | 1247 LoadFromNewestCacheFailed(url, response_info); |
1246 } else { | 1248 } else { |
1247 DCHECK(group_->newest_complete_cache()); | 1249 DCHECK(group_->newest_complete_cache()); |
1248 AppCacheEntry* copy_me = group_->newest_complete_cache()->GetEntry(url); | 1250 AppCacheEntry* copy_me = group_->newest_complete_cache()->GetEntry(url); |
1249 DCHECK(copy_me); | 1251 DCHECK(copy_me); |
1250 DCHECK(copy_me->response_id() == response_id); | 1252 DCHECK(copy_me->response_id() == response_id); |
1251 | 1253 |
1252 AppCache::EntryMap::iterator it = url_file_list_.find(url); | 1254 AppCache::EntryMap::iterator it = url_file_list_.find(url); |
1253 DCHECK(it != url_file_list_.end()); | 1255 DCHECK(it != url_file_list_.end()); |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1425 | 1427 |
1426 // Break the connection with the group so the group cannot call delete | 1428 // Break the connection with the group so the group cannot call delete |
1427 // on this object after we've posted a task to delete ourselves. | 1429 // on this object after we've posted a task to delete ourselves. |
1428 group_->SetUpdateStatus(AppCacheGroup::IDLE); | 1430 group_->SetUpdateStatus(AppCacheGroup::IDLE); |
1429 group_ = NULL; | 1431 group_ = NULL; |
1430 | 1432 |
1431 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this); | 1433 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this); |
1432 } | 1434 } |
1433 | 1435 |
1434 } // namespace appcache | 1436 } // namespace appcache |
OLD | NEW |