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 |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 HttpCache::ActiveEntry* entry() { return entry_; } | 110 HttpCache::ActiveEntry* entry() { return entry_; } |
111 | 111 |
112 // Returns the LoadState of the writer transaction of a given ActiveEntry. In | 112 // Returns the LoadState of the writer transaction of a given ActiveEntry. In |
113 // other words, returns the LoadState of this transaction without asking the | 113 // other words, returns the LoadState of this transaction without asking the |
114 // http cache, because this transaction should be the one currently writing | 114 // http cache, because this transaction should be the one currently writing |
115 // to the cache entry. | 115 // to the cache entry. |
116 LoadState GetWriterLoadState() const; | 116 LoadState GetWriterLoadState() const; |
117 | 117 |
118 const CompletionCallback& io_callback() { return io_callback_; } | 118 const CompletionCallback& io_callback() { return io_callback_; } |
119 | 119 |
120 const BoundNetLog& net_log() const; | 120 const NetLogWithSource& net_log() const; |
121 | 121 |
122 // Bypasses the cache lock whenever there is lock contention. | 122 // Bypasses the cache lock whenever there is lock contention. |
123 void BypassLockForTest() { | 123 void BypassLockForTest() { |
124 bypass_lock_for_test_ = true; | 124 bypass_lock_for_test_ = true; |
125 } | 125 } |
126 | 126 |
127 // Generates a failure when attempting to conditionalize a network request. | 127 // Generates a failure when attempting to conditionalize a network request. |
128 void FailConditionalizationForTest() { | 128 void FailConditionalizationForTest() { |
129 fail_conditionalization_for_test_ = true; | 129 fail_conditionalization_for_test_ = true; |
130 } | 130 } |
131 | 131 |
132 // HttpTransaction methods: | 132 // HttpTransaction methods: |
133 int Start(const HttpRequestInfo* request_info, | 133 int Start(const HttpRequestInfo* request_info, |
134 const CompletionCallback& callback, | 134 const CompletionCallback& callback, |
135 const BoundNetLog& net_log) override; | 135 const NetLogWithSource& net_log) override; |
136 int RestartIgnoringLastError(const CompletionCallback& callback) override; | 136 int RestartIgnoringLastError(const CompletionCallback& callback) override; |
137 int RestartWithCertificate(X509Certificate* client_cert, | 137 int RestartWithCertificate(X509Certificate* client_cert, |
138 SSLPrivateKey* client_private_key, | 138 SSLPrivateKey* client_private_key, |
139 const CompletionCallback& callback) override; | 139 const CompletionCallback& callback) override; |
140 int RestartWithAuth(const AuthCredentials& credentials, | 140 int RestartWithAuth(const AuthCredentials& credentials, |
141 const CompletionCallback& callback) override; | 141 const CompletionCallback& callback) override; |
142 bool IsReadyToRestartForAuth() override; | 142 bool IsReadyToRestartForAuth() override; |
143 int Read(IOBuffer* buf, | 143 int Read(IOBuffer* buf, |
144 int buf_len, | 144 int buf_len, |
145 const CompletionCallback& callback) override; | 145 const CompletionCallback& callback) override; |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
286 int DoNetworkRead(); | 286 int DoNetworkRead(); |
287 int DoNetworkReadComplete(int result); | 287 int DoNetworkReadComplete(int result); |
288 int DoCacheReadData(); | 288 int DoCacheReadData(); |
289 int DoCacheReadDataComplete(int result); | 289 int DoCacheReadDataComplete(int result); |
290 int DoCacheWriteData(int num_bytes); | 290 int DoCacheWriteData(int num_bytes); |
291 int DoCacheWriteDataComplete(int result); | 291 int DoCacheWriteDataComplete(int result); |
292 int DoCacheWriteTruncatedResponse(); | 292 int DoCacheWriteTruncatedResponse(); |
293 int DoCacheWriteTruncatedResponseComplete(int result); | 293 int DoCacheWriteTruncatedResponseComplete(int result); |
294 | 294 |
295 // Sets request_ and fields derived from it. | 295 // Sets request_ and fields derived from it. |
296 void SetRequest(const BoundNetLog& net_log, const HttpRequestInfo* request); | 296 void SetRequest(const NetLogWithSource& net_log, |
| 297 const HttpRequestInfo* request); |
297 | 298 |
298 // Returns true if the request should be handled exclusively by the network | 299 // Returns true if the request should be handled exclusively by the network |
299 // layer (skipping the cache entirely). | 300 // layer (skipping the cache entirely). |
300 bool ShouldPassThrough(); | 301 bool ShouldPassThrough(); |
301 | 302 |
302 // Called to begin reading from the cache. Returns network error code. | 303 // Called to begin reading from the cache. Returns network error code. |
303 int BeginCacheRead(); | 304 int BeginCacheRead(); |
304 | 305 |
305 // Called to begin validating the cache entry. Returns network error code. | 306 // Called to begin validating the cache entry. Returns network error code. |
306 int BeginCacheValidation(); | 307 int BeginCacheValidation(); |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
424 // Sets the response.cache_entry_status to the current cache_entry_status_. | 425 // Sets the response.cache_entry_status to the current cache_entry_status_. |
425 void SyncCacheEntryStatusToResponse(); | 426 void SyncCacheEntryStatusToResponse(); |
426 void RecordHistograms(); | 427 void RecordHistograms(); |
427 | 428 |
428 // Called to signal completion of asynchronous IO. | 429 // Called to signal completion of asynchronous IO. |
429 void OnIOComplete(int result); | 430 void OnIOComplete(int result); |
430 | 431 |
431 State next_state_; | 432 State next_state_; |
432 const HttpRequestInfo* request_; | 433 const HttpRequestInfo* request_; |
433 RequestPriority priority_; | 434 RequestPriority priority_; |
434 BoundNetLog net_log_; | 435 NetLogWithSource net_log_; |
435 std::unique_ptr<HttpRequestInfo> custom_request_; | 436 std::unique_ptr<HttpRequestInfo> custom_request_; |
436 HttpRequestHeaders request_headers_copy_; | 437 HttpRequestHeaders request_headers_copy_; |
437 // If extra_headers specified a "if-modified-since" or "if-none-match", | 438 // If extra_headers specified a "if-modified-since" or "if-none-match", |
438 // |external_validation_| contains the value of those headers. | 439 // |external_validation_| contains the value of those headers. |
439 ValidationHeaders external_validation_; | 440 ValidationHeaders external_validation_; |
440 base::WeakPtr<HttpCache> cache_; | 441 base::WeakPtr<HttpCache> cache_; |
441 HttpCache::ActiveEntry* entry_; | 442 HttpCache::ActiveEntry* entry_; |
442 HttpCache::ActiveEntry* new_entry_; | 443 HttpCache::ActiveEntry* new_entry_; |
443 std::unique_ptr<HttpTransaction> network_trans_; | 444 std::unique_ptr<HttpTransaction> network_trans_; |
444 CompletionCallback callback_; // Consumer's callback. | 445 CompletionCallback callback_; // Consumer's callback. |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
503 BeforeHeadersSentCallback before_headers_sent_callback_; | 504 BeforeHeadersSentCallback before_headers_sent_callback_; |
504 | 505 |
505 base::WeakPtrFactory<Transaction> weak_factory_; | 506 base::WeakPtrFactory<Transaction> weak_factory_; |
506 | 507 |
507 DISALLOW_COPY_AND_ASSIGN(Transaction); | 508 DISALLOW_COPY_AND_ASSIGN(Transaction); |
508 }; | 509 }; |
509 | 510 |
510 } // namespace net | 511 } // namespace net |
511 | 512 |
512 #endif // NET_HTTP_HTTP_CACHE_TRANSACTION_H_ | 513 #endif // NET_HTTP_HTTP_CACHE_TRANSACTION_H_ |
OLD | NEW |