| 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 "net/url_request/sdch_dictionary_fetcher.h" | 5 #include "net/url_request/sdch_dictionary_fetcher.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 #include <queue> | 8 #include <queue> |
| 9 #include <set> | 9 #include <set> |
| 10 | 10 |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 DCHECK_EQ(request, current_request_.get()); | 160 DCHECK_EQ(request, current_request_.get()); |
| 161 DCHECK_EQ(next_state_, STATE_SEND_REQUEST_PENDING); | 161 DCHECK_EQ(next_state_, STATE_SEND_REQUEST_PENDING); |
| 162 DCHECK(!in_loop_); | 162 DCHECK(!in_loop_); |
| 163 | 163 |
| 164 // Confirm that the response isn't a stale read from the cache (as | 164 // Confirm that the response isn't a stale read from the cache (as |
| 165 // may happen in the reload case). If the response was not retrieved over | 165 // may happen in the reload case). If the response was not retrieved over |
| 166 // HTTP, it is presumed to be fresh. | 166 // HTTP, it is presumed to be fresh. |
| 167 HttpResponseHeaders* response_headers = request->response_headers(); | 167 HttpResponseHeaders* response_headers = request->response_headers(); |
| 168 int result = request->status().error(); | 168 int result = request->status().error(); |
| 169 if (result == OK && response_headers) { | 169 if (result == OK && response_headers) { |
| 170 ValidationType validation_type = response_headers->RequiresValidation( | 170 HttpResponseHeaders::ExpirationTimes expirations = |
| 171 request->response_info().request_time, | 171 response_headers->GetExpirationTimes( |
| 172 request->response_info().response_time, base::Time::Now()); | 172 request->response_info().request_time, |
| 173 // TODO(rdsmith): Maybe handle VALIDATION_ASYNCHRONOUS by queueing | 173 request->response_info().response_time); |
| 174 // a non-reload request for the dictionary. | 174 // TODO(rdsmith): Maybe handle stale resources by queueing a non-reload |
| 175 if (validation_type != VALIDATION_NONE) | 175 // request for the dictionary. |
| 176 if (base::Time::Now() >= expirations.GetFreshnessExpiry()) |
| 176 result = ERR_FAILED; | 177 result = ERR_FAILED; |
| 177 } | 178 } |
| 178 | 179 |
| 179 DoLoop(result); | 180 DoLoop(result); |
| 180 } | 181 } |
| 181 | 182 |
| 182 void SdchDictionaryFetcher::OnReadCompleted(URLRequest* request, | 183 void SdchDictionaryFetcher::OnReadCompleted(URLRequest* request, |
| 183 int bytes_read) { | 184 int bytes_read) { |
| 184 DCHECK(CalledOnValidThread()); | 185 DCHECK(CalledOnValidThread()); |
| 185 DCHECK_EQ(request, current_request_.get()); | 186 DCHECK_EQ(request, current_request_.get()); |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 372 current_request_->net_log(), | 373 current_request_->net_log(), |
| 373 current_request_->was_cached()); | 374 current_request_->was_cached()); |
| 374 } | 375 } |
| 375 | 376 |
| 376 ResetRequest(); | 377 ResetRequest(); |
| 377 next_state_ = STATE_SEND_REQUEST; | 378 next_state_ = STATE_SEND_REQUEST; |
| 378 return OK; | 379 return OK; |
| 379 } | 380 } |
| 380 | 381 |
| 381 } // namespace net | 382 } // namespace net |
| OLD | NEW |