| 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 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 void SetPriority(RequestPriority priority) override; | 157 void SetPriority(RequestPriority priority) override; |
| 158 void SetWebSocketHandshakeStreamCreateHelper( | 158 void SetWebSocketHandshakeStreamCreateHelper( |
| 159 WebSocketHandshakeStreamBase::CreateHelper* create_helper) override; | 159 WebSocketHandshakeStreamBase::CreateHelper* create_helper) override; |
| 160 void SetBeforeNetworkStartCallback( | 160 void SetBeforeNetworkStartCallback( |
| 161 const BeforeNetworkStartCallback& callback) override; | 161 const BeforeNetworkStartCallback& callback) override; |
| 162 void SetBeforeHeadersSentCallback( | 162 void SetBeforeHeadersSentCallback( |
| 163 const BeforeHeadersSentCallback& callback) override; | 163 const BeforeHeadersSentCallback& callback) override; |
| 164 int ResumeNetworkStart() override; | 164 int ResumeNetworkStart() override; |
| 165 void GetConnectionAttempts(ConnectionAttempts* out) const override; | 165 void GetConnectionAttempts(ConnectionAttempts* out) const override; |
| 166 | 166 |
| 167 // Invoked when parallel validation cannot proceed due to response failure |
| 168 // and this transaction needs to be restarted. |
| 169 void SetValidatingCannotProceed(); |
| 170 |
| 167 // Returns the estimate of dynamically allocated memory in bytes. | 171 // Returns the estimate of dynamically allocated memory in bytes. |
| 168 size_t EstimateMemoryUsage() const; | 172 size_t EstimateMemoryUsage() const; |
| 169 | 173 |
| 170 private: | 174 private: |
| 171 static const size_t kNumValidationHeaders = 2; | 175 static const size_t kNumValidationHeaders = 2; |
| 172 // Helper struct to pair a header name with its value, for | 176 // Helper struct to pair a header name with its value, for |
| 173 // headers used to validate cache entries. | 177 // headers used to validate cache entries. |
| 174 struct ValidationHeaders { | 178 struct ValidationHeaders { |
| 175 ValidationHeaders() : initialized(false) {} | 179 ValidationHeaders() : initialized(false) {} |
| 176 | 180 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 STATE_OVERWRITE_CACHED_RESPONSE, | 217 STATE_OVERWRITE_CACHED_RESPONSE, |
| 214 STATE_CACHE_WRITE_RESPONSE, | 218 STATE_CACHE_WRITE_RESPONSE, |
| 215 STATE_CACHE_WRITE_RESPONSE_COMPLETE, | 219 STATE_CACHE_WRITE_RESPONSE_COMPLETE, |
| 216 STATE_TRUNCATE_CACHED_DATA, | 220 STATE_TRUNCATE_CACHED_DATA, |
| 217 STATE_TRUNCATE_CACHED_DATA_COMPLETE, | 221 STATE_TRUNCATE_CACHED_DATA_COMPLETE, |
| 218 STATE_TRUNCATE_CACHED_METADATA, | 222 STATE_TRUNCATE_CACHED_METADATA, |
| 219 STATE_TRUNCATE_CACHED_METADATA_COMPLETE, | 223 STATE_TRUNCATE_CACHED_METADATA_COMPLETE, |
| 220 STATE_PARTIAL_HEADERS_RECEIVED, | 224 STATE_PARTIAL_HEADERS_RECEIVED, |
| 221 STATE_CACHE_READ_METADATA, | 225 STATE_CACHE_READ_METADATA, |
| 222 STATE_CACHE_READ_METADATA_COMPLETE, | 226 STATE_CACHE_READ_METADATA_COMPLETE, |
| 227 STATE_HEADERS_PHASE_CANNOT_PROCEED, |
| 228 STATE_FINISH_HEADERS, |
| 229 STATE_FINISH_HEADERS_COMPLETE, |
| 223 | 230 |
| 224 // These states are entered from Read/AddTruncatedFlag. | 231 // These states are entered from Read/AddTruncatedFlag. |
| 225 STATE_NETWORK_READ, | 232 STATE_NETWORK_READ, |
| 226 STATE_NETWORK_READ_COMPLETE, | 233 STATE_NETWORK_READ_COMPLETE, |
| 227 STATE_CACHE_READ_DATA, | 234 STATE_CACHE_READ_DATA, |
| 228 STATE_CACHE_READ_DATA_COMPLETE, | 235 STATE_CACHE_READ_DATA_COMPLETE, |
| 229 STATE_CACHE_WRITE_DATA, | 236 STATE_CACHE_WRITE_DATA, |
| 230 STATE_CACHE_WRITE_DATA_COMPLETE, | 237 STATE_CACHE_WRITE_DATA_COMPLETE, |
| 231 STATE_CACHE_WRITE_TRUNCATED_RESPONSE, | 238 STATE_CACHE_WRITE_TRUNCATED_RESPONSE, |
| 232 STATE_CACHE_WRITE_TRUNCATED_RESPONSE_COMPLETE | 239 STATE_CACHE_WRITE_TRUNCATED_RESPONSE_COMPLETE |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 int DoCacheWriteUpdatedResponseComplete(int result); | 286 int DoCacheWriteUpdatedResponseComplete(int result); |
| 280 int DoUpdateCachedResponseComplete(int result); | 287 int DoUpdateCachedResponseComplete(int result); |
| 281 int DoOverwriteCachedResponse(); | 288 int DoOverwriteCachedResponse(); |
| 282 int DoCacheWriteResponse(); | 289 int DoCacheWriteResponse(); |
| 283 int DoCacheWriteResponseComplete(int result); | 290 int DoCacheWriteResponseComplete(int result); |
| 284 int DoTruncateCachedData(); | 291 int DoTruncateCachedData(); |
| 285 int DoTruncateCachedDataComplete(int result); | 292 int DoTruncateCachedDataComplete(int result); |
| 286 int DoTruncateCachedMetadata(); | 293 int DoTruncateCachedMetadata(); |
| 287 int DoTruncateCachedMetadataComplete(int result); | 294 int DoTruncateCachedMetadataComplete(int result); |
| 288 int DoPartialHeadersReceived(); | 295 int DoPartialHeadersReceived(); |
| 296 int DoHeadersPhaseCannotProceed(); |
| 297 int DoFinishHeaders(int result); |
| 298 int DoFinishHeadersComplete(int result); |
| 289 int DoCacheReadMetadata(); | 299 int DoCacheReadMetadata(); |
| 290 int DoCacheReadMetadataComplete(int result); | 300 int DoCacheReadMetadataComplete(int result); |
| 291 int DoNetworkRead(); | 301 int DoNetworkRead(); |
| 292 int DoNetworkReadComplete(int result); | 302 int DoNetworkReadComplete(int result); |
| 293 int DoCacheReadData(); | 303 int DoCacheReadData(); |
| 294 int DoCacheReadDataComplete(int result); | 304 int DoCacheReadDataComplete(int result); |
| 295 int DoCacheWriteData(int num_bytes); | 305 int DoCacheWriteData(int num_bytes); |
| 296 int DoCacheWriteDataComplete(int result); | 306 int DoCacheWriteDataComplete(int result); |
| 297 int DoCacheWriteTruncatedResponse(); | 307 int DoCacheWriteTruncatedResponse(); |
| 298 int DoCacheWriteTruncatedResponseComplete(int result); | 308 int DoCacheWriteTruncatedResponseComplete(int result); |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 424 void SetResponse(const HttpResponseInfo& new_response); | 434 void SetResponse(const HttpResponseInfo& new_response); |
| 425 void SetAuthResponse(const HttpResponseInfo& new_response); | 435 void SetAuthResponse(const HttpResponseInfo& new_response); |
| 426 | 436 |
| 427 void UpdateCacheEntryStatus( | 437 void UpdateCacheEntryStatus( |
| 428 HttpResponseInfo::CacheEntryStatus new_cache_entry_status); | 438 HttpResponseInfo::CacheEntryStatus new_cache_entry_status); |
| 429 | 439 |
| 430 // Sets the response.cache_entry_status to the current cache_entry_status_. | 440 // Sets the response.cache_entry_status to the current cache_entry_status_. |
| 431 void SyncCacheEntryStatusToResponse(); | 441 void SyncCacheEntryStatusToResponse(); |
| 432 void RecordHistograms(); | 442 void RecordHistograms(); |
| 433 | 443 |
| 434 // Called to signal completion of asynchronous IO. | 444 // Called to signal completion of asynchronous IO. Note that this callback is |
| 445 // used in the conventional sense where one layer calls the callback of the |
| 446 // layer above it e.g. this callback gets called from the network transaction |
| 447 // layer. In addition, it is also used for HttpCache layer to let this |
| 448 // transaction know when it is out of a queued state in ActiveEntry and can |
| 449 // continue its processing. |
| 435 void OnIOComplete(int result); | 450 void OnIOComplete(int result); |
| 436 | 451 |
| 437 // When in a DoLoop, use this to set the next state as it verifies that the | 452 // When in a DoLoop, use this to set the next state as it verifies that the |
| 438 // state isn't set twice. | 453 // state isn't set twice. |
| 439 void TransitionToState(State state); | 454 void TransitionToState(State state); |
| 440 | 455 |
| 441 State next_state_; | 456 State next_state_; |
| 442 const HttpRequestInfo* request_; | 457 const HttpRequestInfo* request_; |
| 443 RequestPriority priority_; | 458 RequestPriority priority_; |
| 444 NetLogWithSource net_log_; | 459 NetLogWithSource net_log_; |
| 445 std::unique_ptr<HttpRequestInfo> custom_request_; | 460 std::unique_ptr<HttpRequestInfo> custom_request_; |
| 446 HttpRequestHeaders request_headers_copy_; | 461 HttpRequestHeaders request_headers_copy_; |
| 447 // If extra_headers specified a "if-modified-since" or "if-none-match", | 462 // If extra_headers specified a "if-modified-since" or "if-none-match", |
| 448 // |external_validation_| contains the value of those headers. | 463 // |external_validation_| contains the value of those headers. |
| 449 ValidationHeaders external_validation_; | 464 ValidationHeaders external_validation_; |
| 450 base::WeakPtr<HttpCache> cache_; | 465 base::WeakPtr<HttpCache> cache_; |
| 451 HttpCache::ActiveEntry* entry_; | 466 HttpCache::ActiveEntry* entry_; |
| 452 HttpCache::ActiveEntry* new_entry_; | 467 HttpCache::ActiveEntry* new_entry_; |
| 453 std::unique_ptr<HttpTransaction> network_trans_; | 468 std::unique_ptr<HttpTransaction> network_trans_; |
| 454 CompletionCallback callback_; // Consumer's callback. | 469 CompletionCallback callback_; // Consumer's callback. |
| 455 HttpResponseInfo response_; | 470 HttpResponseInfo response_; |
| 456 HttpResponseInfo auth_response_; | 471 HttpResponseInfo auth_response_; |
| 457 const HttpResponseInfo* new_response_; | 472 const HttpResponseInfo* new_response_; |
| 458 std::string cache_key_; | 473 std::string cache_key_; |
| 459 Mode mode_; | 474 Mode mode_; |
| 475 Mode original_mode_; // Used when restarting the transaction. |
| 460 bool reading_; // We are already reading. Never reverts to false once set. | 476 bool reading_; // We are already reading. Never reverts to false once set. |
| 461 bool invalid_range_; // We may bypass the cache for this request. | 477 bool invalid_range_; // We may bypass the cache for this request. |
| 462 bool truncated_; // We don't have all the response data. | 478 bool truncated_; // We don't have all the response data. |
| 463 bool is_sparse_; // The data is stored in sparse byte ranges. | 479 bool is_sparse_; // The data is stored in sparse byte ranges. |
| 464 bool range_requested_; // The user requested a byte range. | 480 bool range_requested_; // The user requested a byte range. |
| 465 bool handling_206_; // We must deal with this 206 response. | 481 bool handling_206_; // We must deal with this 206 response. |
| 466 bool cache_pending_; // We are waiting for the HttpCache. | 482 bool cache_pending_; // We are waiting for the HttpCache. |
| 467 bool done_reading_; // All available data was read. | 483 bool done_reading_; // All available data was read. |
| 468 bool vary_mismatch_; // The request doesn't match the stored vary data. | 484 bool vary_mismatch_; // The request doesn't match the stored vary data. |
| 469 bool couldnt_conditionalize_request_; | 485 bool couldnt_conditionalize_request_; |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 516 bool in_do_loop_; | 532 bool in_do_loop_; |
| 517 | 533 |
| 518 base::WeakPtrFactory<Transaction> weak_factory_; | 534 base::WeakPtrFactory<Transaction> weak_factory_; |
| 519 | 535 |
| 520 DISALLOW_COPY_AND_ASSIGN(Transaction); | 536 DISALLOW_COPY_AND_ASSIGN(Transaction); |
| 521 }; | 537 }; |
| 522 | 538 |
| 523 } // namespace net | 539 } // namespace net |
| 524 | 540 |
| 525 #endif // NET_HTTP_HTTP_CACHE_TRANSACTION_H_ | 541 #endif // NET_HTTP_HTTP_CACHE_TRANSACTION_H_ |
| OLD | NEW |