Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(583)

Side by Side Diff: net/http/http_cache_transaction.h

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

Powered by Google App Engine
This is Rietveld 408576698