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 1175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1186 const GURL& url = found->second; | 1186 const GURL& url = found->second; |
1187 | 1187 |
1188 if (!http_info) { | 1188 if (!http_info) { |
1189 LoadFromNewestCacheFailed(url, NULL); // no response found | 1189 LoadFromNewestCacheFailed(url, NULL); // no response found |
1190 } else { | 1190 } else { |
1191 // Check if response can be re-used according to HTTP caching semantics. | 1191 // Check if response can be re-used according to HTTP caching semantics. |
1192 // Responses with a "vary" header get treated as expired. | 1192 // Responses with a "vary" header get treated as expired. |
1193 const std::string name = "vary"; | 1193 const std::string name = "vary"; |
1194 std::string value; | 1194 std::string value; |
1195 void* iter = NULL; | 1195 void* iter = NULL; |
1196 if (!http_info->headers.get() || | 1196 base::Time freshness_expiry = |
1197 http_info->headers->RequiresValidation(http_info->request_time, | 1197 http_info->headers ? base::Time() : |
1198 http_info->response_time, | 1198 http_info->headers->GetFreshnessExpiry(http_info->request_time, |
1199 base::Time::Now()) || | 1199 http_info->response_time); |
| 1200 if (freshness_expiry <= base::Time::Now() || |
1200 http_info->headers->EnumerateHeader(&iter, name, &value)) { | 1201 http_info->headers->EnumerateHeader(&iter, name, &value)) { |
1201 LoadFromNewestCacheFailed(url, response_info); | 1202 LoadFromNewestCacheFailed(url, response_info); |
1202 } else { | 1203 } else { |
1203 DCHECK(group_->newest_complete_cache()); | 1204 DCHECK(group_->newest_complete_cache()); |
1204 AppCacheEntry* copy_me = group_->newest_complete_cache()->GetEntry(url); | 1205 AppCacheEntry* copy_me = group_->newest_complete_cache()->GetEntry(url); |
1205 DCHECK(copy_me); | 1206 DCHECK(copy_me); |
1206 DCHECK(copy_me->response_id() == response_id); | 1207 DCHECK(copy_me->response_id() == response_id); |
1207 | 1208 |
1208 AppCache::EntryMap::iterator it = url_file_list_.find(url); | 1209 AppCache::EntryMap::iterator it = url_file_list_.find(url); |
1209 DCHECK(it != url_file_list_.end()); | 1210 DCHECK(it != url_file_list_.end()); |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1367 | 1368 |
1368 // Break the connection with the group so the group cannot call delete | 1369 // Break the connection with the group so the group cannot call delete |
1369 // on this object after we've posted a task to delete ourselves. | 1370 // on this object after we've posted a task to delete ourselves. |
1370 group_->SetUpdateStatus(AppCacheGroup::IDLE); | 1371 group_->SetUpdateStatus(AppCacheGroup::IDLE); |
1371 group_ = NULL; | 1372 group_ = NULL; |
1372 | 1373 |
1373 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this); | 1374 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this); |
1374 } | 1375 } |
1375 | 1376 |
1376 } // namespace appcache | 1377 } // namespace appcache |
OLD | NEW |