OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/service_worker/service_worker_write_to_cache_job.h" | 5 #include "content/browser/service_worker/service_worker_write_to_cache_job.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
10 #include "base/trace_event/trace_event.h" | 10 #include "base/trace_event/trace_event.h" |
(...skipping 651 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
662 : base::StringPrintf(kBadMIMEError, mime_type.c_str()); | 662 : base::StringPrintf(kBadMIMEError, mime_type.c_str()); |
663 AsyncNotifyDoneHelper(net::URLRequestStatus(net::URLRequestStatus::FAILED, | 663 AsyncNotifyDoneHelper(net::URLRequestStatus(net::URLRequestStatus::FAILED, |
664 net::ERR_INSECURE_RESPONSE), | 664 net::ERR_INSECURE_RESPONSE), |
665 error_message); | 665 error_message); |
666 return; | 666 return; |
667 } | 667 } |
668 | 668 |
669 if (!CheckPathRestriction(request)) | 669 if (!CheckPathRestriction(request)) |
670 return; | 670 return; |
671 | 671 |
| 672 const net::HttpResponseHeaders* headers = request->response_headers(); |
| 673 base::TimeDelta result; |
| 674 if (headers->GetMaxAgeValue(&result) && |
| 675 result < base::TimeDelta::FromSeconds( |
| 676 kServiceWorkerScriptMaxCacheAgeInSeconds)) |
| 677 version_->set_max_age(result); |
| 678 |
672 version_->SetMainScriptHttpResponseInfo(net_request_->response_info()); | 679 version_->SetMainScriptHttpResponseInfo(net_request_->response_info()); |
673 } | 680 } |
674 | 681 |
675 if (net_request_->response_info().network_accessed) | 682 if (net_request_->response_info().network_accessed) |
676 version_->embedded_worker()->OnNetworkAccessedForScriptLoad(); | 683 version_->embedded_worker()->OnNetworkAccessedForScriptLoad(); |
677 | 684 |
678 consumer_->OnResponseStarted(); | 685 consumer_->OnResponseStarted(); |
679 } | 686 } |
680 | 687 |
681 void ServiceWorkerWriteToCacheJob::CommitHeadersAndNotifyHeadersComplete() { | 688 void ServiceWorkerWriteToCacheJob::CommitHeadersAndNotifyHeadersComplete() { |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
816 DCHECK(!did_notify_finished_); | 823 DCHECK(!did_notify_finished_); |
817 int size = -1; | 824 int size = -1; |
818 if (status.is_success()) | 825 if (status.is_success()) |
819 size = writer_ ? writer_->amount_written() : 0; | 826 size = writer_ ? writer_->amount_written() : 0; |
820 version_->script_cache_map()->NotifyFinishedCaching(url_, size, status, | 827 version_->script_cache_map()->NotifyFinishedCaching(url_, size, status, |
821 status_message); | 828 status_message); |
822 did_notify_finished_ = true; | 829 did_notify_finished_ = true; |
823 } | 830 } |
824 | 831 |
825 } // namespace content | 832 } // namespace content |
OLD | NEW |