| OLD | NEW |
| 1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 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 "net/http/http_cache.h" | 5 #include "net/http/http_cache.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| (...skipping 825 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 836 // If there is more than one validation header, we can't treat this request as | 836 // If there is more than one validation header, we can't treat this request as |
| 837 // a cache validation, since we don't know for sure which header the server | 837 // a cache validation, since we don't know for sure which header the server |
| 838 // will give us a response for (and they could be contradictory). | 838 // will give us a response for (and they could be contradictory). |
| 839 if (external_validation_error) { | 839 if (external_validation_error) { |
| 840 LOG(WARNING) << "Multiple or malformed validation headers found."; | 840 LOG(WARNING) << "Multiple or malformed validation headers found."; |
| 841 effective_load_flags_ |= LOAD_DISABLE_CACHE; | 841 effective_load_flags_ |= LOAD_DISABLE_CACHE; |
| 842 } | 842 } |
| 843 | 843 |
| 844 if (range_found && !(effective_load_flags_ & LOAD_DISABLE_CACHE)) { | 844 if (range_found && !(effective_load_flags_ & LOAD_DISABLE_CACHE)) { |
| 845 partial_.reset(new PartialData); | 845 partial_.reset(new PartialData); |
| 846 if (partial_->Init(request_->extra_headers, new_extra_headers)) { | 846 if (partial_->Init(request_->extra_headers)) { |
| 847 // We will be modifying the actual range requested to the server, so | 847 // We will be modifying the actual range requested to the server, so |
| 848 // let's remove the header here. | 848 // let's remove the header here. |
| 849 custom_request_.reset(new HttpRequestInfo(*request_)); | 849 custom_request_.reset(new HttpRequestInfo(*request_)); |
| 850 request_ = custom_request_.get(); | 850 request_ = custom_request_.get(); |
| 851 custom_request_->extra_headers = new_extra_headers; | 851 custom_request_->extra_headers = new_extra_headers; |
| 852 partial_->SetHeaders(new_extra_headers); |
| 852 } else { | 853 } else { |
| 853 // The range is invalid or we cannot handle it properly. | 854 // The range is invalid or we cannot handle it properly. |
| 854 LOG(WARNING) << "Invalid byte range found."; | 855 LOG(WARNING) << "Invalid byte range found."; |
| 855 effective_load_flags_ |= LOAD_DISABLE_CACHE; | 856 effective_load_flags_ |= LOAD_DISABLE_CACHE; |
| 856 partial_.reset(NULL); | 857 partial_.reset(NULL); |
| 857 } | 858 } |
| 858 } | 859 } |
| 859 } | 860 } |
| 860 | 861 |
| 861 bool HttpCache::Transaction::ShouldPassThrough() { | 862 bool HttpCache::Transaction::ShouldPassThrough() { |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 939 if (!enable_range_support_) | 940 if (!enable_range_support_) |
| 940 return BeginCacheValidation(); | 941 return BeginCacheValidation(); |
| 941 | 942 |
| 942 bool byte_range_requested = partial_.get() != NULL; | 943 bool byte_range_requested = partial_.get() != NULL; |
| 943 if (byte_range_requested) { | 944 if (byte_range_requested) { |
| 944 if (OK != entry_->disk_entry->ReadyForSparseIO(entry_ready_callback_)) | 945 if (OK != entry_->disk_entry->ReadyForSparseIO(entry_ready_callback_)) |
| 945 return ERR_IO_PENDING; | 946 return ERR_IO_PENDING; |
| 946 } else { | 947 } else { |
| 947 // The request is not for a range, but we have stored just ranges. | 948 // The request is not for a range, but we have stored just ranges. |
| 948 partial_.reset(new PartialData()); | 949 partial_.reset(new PartialData()); |
| 950 partial_->SetHeaders(request_->extra_headers); |
| 949 if (!custom_request_.get()) { | 951 if (!custom_request_.get()) { |
| 950 custom_request_.reset(new HttpRequestInfo(*request_)); | 952 custom_request_.reset(new HttpRequestInfo(*request_)); |
| 951 request_ = custom_request_.get(); | 953 request_ = custom_request_.get(); |
| 952 } | 954 } |
| 953 } | 955 } |
| 954 | 956 |
| 955 return ValidateEntryHeadersAndContinue(byte_range_requested); | 957 return ValidateEntryHeadersAndContinue(byte_range_requested); |
| 956 } | 958 } |
| 957 | 959 |
| 958 int HttpCache::Transaction::ValidateEntryHeadersAndContinue( | 960 int HttpCache::Transaction::ValidateEntryHeadersAndContinue( |
| (...skipping 1138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2097 static_cast<net::HttpNetworkLayer*>(network_layer_.get()); | 2099 static_cast<net::HttpNetworkLayer*>(network_layer_.get()); |
| 2098 HttpNetworkSession* session = network->GetSession(); | 2100 HttpNetworkSession* session = network->GetSession(); |
| 2099 if (session) { | 2101 if (session) { |
| 2100 session->tcp_socket_pool()->CloseIdleSockets(); | 2102 session->tcp_socket_pool()->CloseIdleSockets(); |
| 2101 } | 2103 } |
| 2102 } | 2104 } |
| 2103 | 2105 |
| 2104 //----------------------------------------------------------------------------- | 2106 //----------------------------------------------------------------------------- |
| 2105 | 2107 |
| 2106 } // namespace net | 2108 } // namespace net |
| OLD | NEW |