| 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 1217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1228 const GURL& url = found->second; | 1228 const GURL& url = found->second; |
| 1229 | 1229 |
| 1230 if (!http_info) { | 1230 if (!http_info) { |
| 1231 LoadFromNewestCacheFailed(url, NULL); // no response found | 1231 LoadFromNewestCacheFailed(url, NULL); // no response found |
| 1232 } else { | 1232 } else { |
| 1233 // Check if response can be re-used according to HTTP caching semantics. | 1233 // Check if response can be re-used according to HTTP caching semantics. |
| 1234 // Responses with a "vary" header get treated as expired. | 1234 // Responses with a "vary" header get treated as expired. |
| 1235 const std::string name = "vary"; | 1235 const std::string name = "vary"; |
| 1236 std::string value; | 1236 std::string value; |
| 1237 void* iter = NULL; | 1237 void* iter = NULL; |
| 1238 if (!http_info->headers.get() || | 1238 base::Time freshness_expiry = base::Time(); |
| 1239 http_info->headers->RequiresValidation(http_info->request_time, | 1239 if (http_info->headers) { |
| 1240 http_info->response_time, | 1240 freshness_expiry = http_info->headers->GetFreshnessExpiry( |
| 1241 base::Time::Now()) || | 1241 http_info->request_time, http_info->response_time); |
| 1242 } |
| 1243 if (freshness_expiry <= base::Time::Now() || |
| 1242 http_info->headers->EnumerateHeader(&iter, name, &value)) { | 1244 http_info->headers->EnumerateHeader(&iter, name, &value)) { |
| 1243 LoadFromNewestCacheFailed(url, response_info); | 1245 LoadFromNewestCacheFailed(url, response_info); |
| 1244 } else { | 1246 } else { |
| 1245 DCHECK(group_->newest_complete_cache()); | 1247 DCHECK(group_->newest_complete_cache()); |
| 1246 AppCacheEntry* copy_me = group_->newest_complete_cache()->GetEntry(url); | 1248 AppCacheEntry* copy_me = group_->newest_complete_cache()->GetEntry(url); |
| 1247 DCHECK(copy_me); | 1249 DCHECK(copy_me); |
| 1248 DCHECK(copy_me->response_id() == response_id); | 1250 DCHECK(copy_me->response_id() == response_id); |
| 1249 | 1251 |
| 1250 AppCache::EntryMap::iterator it = url_file_list_.find(url); | 1252 AppCache::EntryMap::iterator it = url_file_list_.find(url); |
| 1251 DCHECK(it != url_file_list_.end()); | 1253 DCHECK(it != url_file_list_.end()); |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1411 | 1413 |
| 1412 // Break the connection with the group so the group cannot call delete | 1414 // Break the connection with the group so the group cannot call delete |
| 1413 // on this object after we've posted a task to delete ourselves. | 1415 // on this object after we've posted a task to delete ourselves. |
| 1414 group_->SetUpdateStatus(AppCacheGroup::IDLE); | 1416 group_->SetUpdateStatus(AppCacheGroup::IDLE); |
| 1415 group_ = NULL; | 1417 group_ = NULL; |
| 1416 | 1418 |
| 1417 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this); | 1419 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this); |
| 1418 } | 1420 } |
| 1419 | 1421 |
| 1420 } // namespace appcache | 1422 } // namespace appcache |
| OLD | NEW |