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 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
368 int WriteResponseInfoToEntry(bool truncated); | 368 int WriteResponseInfoToEntry(bool truncated); |
369 | 369 |
370 // Helper function, should be called with result of WriteResponseInfoToEntry | 370 // Helper function, should be called with result of WriteResponseInfoToEntry |
371 // (or the result of the callback, when WriteResponseInfoToEntry returns | 371 // (or the result of the callback, when WriteResponseInfoToEntry returns |
372 // ERR_IO_PENDING). Calls DoneWritingToEntry if |result| is not the right | 372 // ERR_IO_PENDING). Calls DoneWritingToEntry if |result| is not the right |
373 // number of bytes. It is expected that the state that calls this will | 373 // number of bytes. It is expected that the state that calls this will |
374 // return whatever net error code this function returns, which currently | 374 // return whatever net error code this function returns, which currently |
375 // is always "OK". | 375 // is always "OK". |
376 int OnWriteResponseInfoToEntryComplete(int result); | 376 int OnWriteResponseInfoToEntryComplete(int result); |
377 | 377 |
| 378 // Called when the client has finished reading. May start the state machine |
| 379 // again. Hence should only be called when there are no more pending |
| 380 // operations. |
| 381 int DoneWithRequest(); |
| 382 |
378 // Called when we are done writing to the cache entry. | 383 // Called when we are done writing to the cache entry. |
379 void DoneWritingToEntry(bool success); | 384 void DoneWritingToEntry(bool success); |
380 | 385 |
| 386 // Called when we are done with the cache entry. |
| 387 void DoneWithEntry(bool cancel); |
| 388 |
381 // Returns an error to signal the caller that the current read failed. The | 389 // Returns an error to signal the caller that the current read failed. The |
382 // current operation |result| is also logged. If |restart| is true, the | 390 // current operation |result| is also logged. If |restart| is true, the |
383 // transaction should be restarted. | 391 // transaction should be restarted. |
384 int OnCacheReadError(int result, bool restart); | 392 int OnCacheReadError(int result, bool restart); |
385 | 393 |
386 // Called when the cache lock timeout fires. | 394 // Called when the cache lock timeout fires. |
387 void OnAddToEntryTimeout(base::TimeTicks start_time); | 395 void OnAddToEntryTimeout(base::TimeTicks start_time); |
388 | 396 |
389 // Deletes the current partial cache entry (sparse), and optionally removes | 397 // Deletes the current partial cache entry (sparse), and optionally removes |
390 // the control object (partial_). | 398 // the control object (partial_). |
391 void DoomPartialEntry(bool delete_object); | 399 void DoomPartialEntry(bool delete_object); |
392 | 400 |
393 // Performs the needed work after receiving data from the network, when | 401 // Performs the needed work after receiving data from the network, when |
394 // working with range requests. | 402 // working with range requests. |
395 int DoPartialNetworkReadCompleted(int result); | 403 int DoPartialNetworkReadCompleted(int result); |
396 | 404 |
397 // Performs the needed work after receiving data from the cache, when | 405 // Performs the needed work after receiving data from the cache, when |
398 // working with range requests. | 406 // working with range requests. |
399 int DoPartialCacheReadCompleted(int result); | 407 int DoPartialCacheReadCompleted(int result); |
400 | 408 |
401 // Restarts this transaction after deleting the cached data. It is meant to | 409 // Restarts this transaction after deleting the cached data. It is meant to |
402 // be used when the current request cannot be fulfilled due to conflicts | 410 // be used when the current request cannot be fulfilled due to conflicts |
403 // between the byte range request and the cached entry. | 411 // between the byte range request and the cached entry. |
404 int DoRestartPartialRequest(); | 412 int DoRestartPartialRequest(); |
405 | 413 |
| 414 int DoReadComplete(int result); |
| 415 |
| 416 int BeginCacheEntryRelease(int result_to_forward); |
| 417 |
| 418 void OnCacheReleaseComplete(const base::Closure& closure, int result); |
| 419 |
406 // Resets the relavant internal state to remove traces of internal processing | 420 // Resets the relavant internal state to remove traces of internal processing |
407 // related to range requests. Deletes |partial_| if |delete_object| is true. | 421 // related to range requests. Deletes |partial_| if |delete_object| is true. |
408 void ResetPartialState(bool delete_object); | 422 void ResetPartialState(bool delete_object); |
409 | 423 |
410 // Resets |network_trans_|, which must be non-NULL. Also updates | 424 // Resets |network_trans_|, which must be non-NULL. Also updates |
411 // |old_network_trans_load_timing_|, which must be NULL when this is called. | 425 // |old_network_trans_load_timing_|, which must be NULL when this is called. |
412 void ResetNetworkTransaction(); | 426 void ResetNetworkTransaction(); |
413 | 427 |
414 // Returns true if we should bother attempting to resume this request if it | 428 // Returns true if we should bother attempting to resume this request if it |
415 // is aborted while in progress. If |has_data| is true, the size of the stored | 429 // is aborted while in progress. If |has_data| is true, the size of the stored |
(...skipping 19 matching lines...) Expand all Loading... |
435 HttpCache::ActiveEntry* entry_; | 449 HttpCache::ActiveEntry* entry_; |
436 HttpCache::ActiveEntry* new_entry_; | 450 HttpCache::ActiveEntry* new_entry_; |
437 scoped_ptr<HttpTransaction> network_trans_; | 451 scoped_ptr<HttpTransaction> network_trans_; |
438 CompletionCallback callback_; // Consumer's callback. | 452 CompletionCallback callback_; // Consumer's callback. |
439 HttpResponseInfo response_; | 453 HttpResponseInfo response_; |
440 HttpResponseInfo auth_response_; | 454 HttpResponseInfo auth_response_; |
441 const HttpResponseInfo* new_response_; | 455 const HttpResponseInfo* new_response_; |
442 std::string cache_key_; | 456 std::string cache_key_; |
443 Mode mode_; | 457 Mode mode_; |
444 bool reading_; // We are already reading. Never reverts to false once set. | 458 bool reading_; // We are already reading. Never reverts to false once set. |
445 bool invalid_range_; // We may bypass the cache for this request. | 459 bool invalid_range_; // We may bypass the cache for this request. |
446 bool truncated_; // We don't have all the response data. | 460 bool truncated_; // We don't have all the response data. |
447 bool is_sparse_; // The data is stored in sparse byte ranges. | 461 bool is_sparse_; // The data is stored in sparse byte ranges. |
448 bool range_requested_; // The user requested a byte range. | 462 bool range_requested_; // The user requested a byte range. |
449 bool handling_206_; // We must deal with this 206 response. | 463 bool handling_206_; // We must deal with this 206 response. |
450 bool cache_pending_; // We are waiting for the HttpCache. | 464 bool cache_pending_; // We are waiting for the HttpCache. |
451 bool done_reading_; // All available data was read. | 465 bool done_writing_; // All available data was written to the cache entry. |
452 bool vary_mismatch_; // The request doesn't match the stored vary data. | 466 bool vary_mismatch_; // The request doesn't match the stored vary data. |
453 bool couldnt_conditionalize_request_; | 467 bool couldnt_conditionalize_request_; |
| 468 bool stopped_caching_; // Avoid further writes to the cache. |
454 bool bypass_lock_for_test_; // A test is exercising the cache lock. | 469 bool bypass_lock_for_test_; // A test is exercising the cache lock. |
455 bool fail_conditionalization_for_test_; // Fail ConditionalizeRequest. | 470 bool fail_conditionalization_for_test_; // Fail ConditionalizeRequest. |
456 scoped_refptr<IOBuffer> read_buf_; | 471 scoped_refptr<IOBuffer> read_buf_; |
457 int io_buf_len_; | 472 int io_buf_len_; |
458 int read_offset_; | 473 int read_offset_; |
459 int effective_load_flags_; | 474 int effective_load_flags_; |
460 int write_len_; | 475 int write_len_; |
461 scoped_ptr<PartialData> partial_; // We are dealing with range requests. | 476 scoped_ptr<PartialData> partial_; // We are dealing with range requests. |
462 UploadProgress final_upload_progress_; | 477 UploadProgress final_upload_progress_; |
463 CompletionCallback io_callback_; | 478 CompletionCallback io_callback_; |
(...skipping 24 matching lines...) Expand all Loading... |
488 BeforeProxyHeadersSentCallback before_proxy_headers_sent_callback_; | 503 BeforeProxyHeadersSentCallback before_proxy_headers_sent_callback_; |
489 | 504 |
490 base::WeakPtrFactory<Transaction> weak_factory_; | 505 base::WeakPtrFactory<Transaction> weak_factory_; |
491 | 506 |
492 DISALLOW_COPY_AND_ASSIGN(Transaction); | 507 DISALLOW_COPY_AND_ASSIGN(Transaction); |
493 }; | 508 }; |
494 | 509 |
495 } // namespace net | 510 } // namespace net |
496 | 511 |
497 #endif // NET_HTTP_HTTP_CACHE_TRANSACTION_H_ | 512 #endif // NET_HTTP_HTTP_CACHE_TRANSACTION_H_ |
OLD | NEW |