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 // This file declares HttpCache::Transaction, a private class of HttpCache so | 5 // This file declares HttpCache::Transaction, a private class of HttpCache so |
6 // it should only be included by http_cache.cc | 6 // it should only be included by http_cache.cc |
7 | 7 |
8 #ifndef NET_HTTP_HTTP_CACHE_TRANSACTION_H_ | 8 #ifndef NET_HTTP_HTTP_CACHE_TRANSACTION_H_ |
9 #define NET_HTTP_HTTP_CACHE_TRANSACTION_H_ | 9 #define NET_HTTP_HTTP_CACHE_TRANSACTION_H_ |
10 | 10 |
11 #include <string> | 11 #include <string> |
12 | 12 |
13 #include "base/time/time.h" | 13 #include "base/time/time.h" |
14 #include "net/base/completion_callback.h" | 14 #include "net/base/completion_callback.h" |
15 #include "net/base/net_log.h" | 15 #include "net/base/net_log.h" |
16 #include "net/base/request_priority.h" | 16 #include "net/base/request_priority.h" |
17 #include "net/http/http_cache.h" | 17 #include "net/http/http_cache.h" |
18 #include "net/http/http_request_headers.h" | 18 #include "net/http/http_request_headers.h" |
| 19 #include "net/http/http_response_headers.h" |
19 #include "net/http/http_response_info.h" | 20 #include "net/http/http_response_info.h" |
20 #include "net/http/http_transaction.h" | 21 #include "net/http/http_transaction.h" |
21 | 22 |
22 namespace net { | 23 namespace net { |
23 | 24 |
24 class PartialData; | 25 class PartialData; |
25 struct HttpRequestInfo; | 26 struct HttpRequestInfo; |
26 struct LoadTimingInfo; | 27 struct LoadTimingInfo; |
27 | 28 |
28 // This is the transaction that is returned by the HttpCache transaction | 29 // This is the transaction that is returned by the HttpCache transaction |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 | 102 |
102 const CompletionCallback& io_callback() { return io_callback_; } | 103 const CompletionCallback& io_callback() { return io_callback_; } |
103 | 104 |
104 const BoundNetLog& net_log() const; | 105 const BoundNetLog& net_log() const; |
105 | 106 |
106 // Bypasses the cache lock whenever there is lock contention. | 107 // Bypasses the cache lock whenever there is lock contention. |
107 void BypassLockForTest() { | 108 void BypassLockForTest() { |
108 bypass_lock_for_test_ = true; | 109 bypass_lock_for_test_ = true; |
109 } | 110 } |
110 | 111 |
| 112 // Used by asynchronous validations to ensure that the asynchronous validation |
| 113 // path isn't re-entered. The LOAD_VALIDATE_CACHE flag cannot be passed to |
| 114 // Start() via the HttpRequestInfo object because it has the side effect of |
| 115 // causing HttpNetworkTransaction to add a Cache-Control: max-age=0 header. |
| 116 // This method must be called before Start(). |
| 117 void ValidateInternalCache(); |
| 118 |
111 // HttpTransaction methods: | 119 // HttpTransaction methods: |
112 virtual int Start(const HttpRequestInfo* request_info, | 120 virtual int Start(const HttpRequestInfo* request_info, |
113 const CompletionCallback& callback, | 121 const CompletionCallback& callback, |
114 const BoundNetLog& net_log) OVERRIDE; | 122 const BoundNetLog& net_log) OVERRIDE; |
115 virtual int RestartIgnoringLastError( | 123 virtual int RestartIgnoringLastError( |
116 const CompletionCallback& callback) OVERRIDE; | 124 const CompletionCallback& callback) OVERRIDE; |
117 virtual int RestartWithCertificate( | 125 virtual int RestartWithCertificate( |
118 X509Certificate* client_cert, | 126 X509Certificate* client_cert, |
119 const CompletionCallback& callback) OVERRIDE; | 127 const CompletionCallback& callback) OVERRIDE; |
120 virtual int RestartWithAuth(const AuthCredentials& credentials, | 128 virtual int RestartWithAuth(const AuthCredentials& credentials, |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
304 int RestartNetworkRequest(); | 312 int RestartNetworkRequest(); |
305 | 313 |
306 // Called to restart a network transaction with a client certificate. | 314 // Called to restart a network transaction with a client certificate. |
307 // Returns network error code. | 315 // Returns network error code. |
308 int RestartNetworkRequestWithCertificate(X509Certificate* client_cert); | 316 int RestartNetworkRequestWithCertificate(X509Certificate* client_cert); |
309 | 317 |
310 // Called to restart a network transaction with authentication credentials. | 318 // Called to restart a network transaction with authentication credentials. |
311 // Returns network error code. | 319 // Returns network error code. |
312 int RestartNetworkRequestWithAuth(const AuthCredentials& credentials); | 320 int RestartNetworkRequestWithAuth(const AuthCredentials& credentials); |
313 | 321 |
314 // Called to determine if we need to validate the cache entry before using it. | 322 // Called to determine if we need to validate the cache entry before using it, |
315 bool RequiresValidation(); | 323 // and whether the validation should be synchronous or asynchronous. |
| 324 HttpResponseHeaders::ValidationType RequiredValidationType(); |
316 | 325 |
317 // Called to make the request conditional (to ask the server if the cached | 326 // Called to make the request conditional (to ask the server if the cached |
318 // copy is valid). Returns true if able to make the request conditional. | 327 // copy is valid). Returns true if able to make the request conditional. |
319 bool ConditionalizeRequest(); | 328 bool ConditionalizeRequest(); |
320 | 329 |
321 // Makes sure that a 206 response is expected. Returns true on success. | 330 // Makes sure that a 206 response is expected. Returns true on success. |
322 // On success, handling_206_ will be set to true if we are processing a | 331 // On success, handling_206_ will be set to true if we are processing a |
323 // partial entry. | 332 // partial entry. |
324 bool ValidatePartialResponse(); | 333 bool ValidatePartialResponse(); |
325 | 334 |
326 // Handles a response validation error by bypassing the cache. | 335 // Handles a response validation error by bypassing the cache. |
327 void IgnoreRangeRequest(); | 336 void IgnoreRangeRequest(); |
328 | 337 |
329 // Removes content-length and byte range related info if needed. | 338 // Removes content-length and byte range related info if needed. |
330 void FixHeadersForHead(); | 339 void FixHeadersForHead(); |
331 | 340 |
| 341 // Launches an asynchronous revalidation based on this transaction. |
| 342 void TriggerAsyncValidation(); |
| 343 |
332 // Changes the response code of a range request to be 416 (Requested range not | 344 // Changes the response code of a range request to be 416 (Requested range not |
333 // satisfiable). | 345 // satisfiable). |
334 void FailRangeRequest(); | 346 void FailRangeRequest(); |
335 | 347 |
336 // Setups the transaction for reading from the cache entry. | 348 // Setups the transaction for reading from the cache entry. |
337 int SetupEntryForRead(); | 349 int SetupEntryForRead(); |
338 | 350 |
339 // Reads data from the network. | 351 // Reads data from the network. |
340 int ReadFromNetwork(IOBuffer* data, int data_len); | 352 int ReadFromNetwork(IOBuffer* data, int data_len); |
341 | 353 |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
463 | 475 |
464 BeforeNetworkStartCallback before_network_start_callback_; | 476 BeforeNetworkStartCallback before_network_start_callback_; |
465 BeforeProxyHeadersSentCallback before_proxy_headers_sent_callback_; | 477 BeforeProxyHeadersSentCallback before_proxy_headers_sent_callback_; |
466 | 478 |
467 DISALLOW_COPY_AND_ASSIGN(Transaction); | 479 DISALLOW_COPY_AND_ASSIGN(Transaction); |
468 }; | 480 }; |
469 | 481 |
470 } // namespace net | 482 } // namespace net |
471 | 483 |
472 #endif // NET_HTTP_HTTP_CACHE_TRANSACTION_H_ | 484 #endif // NET_HTTP_HTTP_CACHE_TRANSACTION_H_ |
OLD | NEW |