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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 // Returns the LoadState of the writer transaction of a given ActiveEntry. In | 96 // Returns the LoadState of the writer transaction of a given ActiveEntry. In |
97 // other words, returns the LoadState of this transaction without asking the | 97 // other words, returns the LoadState of this transaction without asking the |
98 // http cache, because this transaction should be the one currently writing | 98 // http cache, because this transaction should be the one currently writing |
99 // to the cache entry. | 99 // to the cache entry. |
100 LoadState GetWriterLoadState() const; | 100 LoadState GetWriterLoadState() const; |
101 | 101 |
102 const CompletionCallback& io_callback() { return io_callback_; } | 102 const CompletionCallback& io_callback() { return io_callback_; } |
103 | 103 |
104 const BoundNetLog& net_log() const; | 104 const BoundNetLog& net_log() const; |
105 | 105 |
| 106 // Bypasses the cache lock whenever there is lock contention. |
| 107 void BypassLockForTest() { |
| 108 bypass_lock_for_test_ = true; |
| 109 } |
| 110 |
106 // HttpTransaction methods: | 111 // HttpTransaction methods: |
107 virtual int Start(const HttpRequestInfo* request_info, | 112 virtual int Start(const HttpRequestInfo* request_info, |
108 const CompletionCallback& callback, | 113 const CompletionCallback& callback, |
109 const BoundNetLog& net_log) OVERRIDE; | 114 const BoundNetLog& net_log) OVERRIDE; |
110 virtual int RestartIgnoringLastError( | 115 virtual int RestartIgnoringLastError( |
111 const CompletionCallback& callback) OVERRIDE; | 116 const CompletionCallback& callback) OVERRIDE; |
112 virtual int RestartWithCertificate( | 117 virtual int RestartWithCertificate( |
113 X509Certificate* client_cert, | 118 X509Certificate* client_cert, |
114 const CompletionCallback& callback) OVERRIDE; | 119 const CompletionCallback& callback) OVERRIDE; |
115 virtual int RestartWithAuth(const AuthCredentials& credentials, | 120 virtual int RestartWithAuth(const AuthCredentials& credentials, |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
343 const CompletionCallback& callback); | 348 const CompletionCallback& callback); |
344 | 349 |
345 // Called when we are done writing to the cache entry. | 350 // Called when we are done writing to the cache entry. |
346 void DoneWritingToEntry(bool success); | 351 void DoneWritingToEntry(bool success); |
347 | 352 |
348 // Returns an error to signal the caller that the current read failed. The | 353 // Returns an error to signal the caller that the current read failed. The |
349 // current operation |result| is also logged. If |restart| is true, the | 354 // current operation |result| is also logged. If |restart| is true, the |
350 // transaction should be restarted. | 355 // transaction should be restarted. |
351 int OnCacheReadError(int result, bool restart); | 356 int OnCacheReadError(int result, bool restart); |
352 | 357 |
| 358 // Called when the cache lock timeout fires. |
| 359 void OnAddToEntryTimeout(base::TimeTicks start_time); |
| 360 |
353 // Deletes the current partial cache entry (sparse), and optionally removes | 361 // Deletes the current partial cache entry (sparse), and optionally removes |
354 // the control object (partial_). | 362 // the control object (partial_). |
355 void DoomPartialEntry(bool delete_object); | 363 void DoomPartialEntry(bool delete_object); |
356 | 364 |
357 // Performs the needed work after receiving data from the network, when | 365 // Performs the needed work after receiving data from the network, when |
358 // working with range requests. | 366 // working with range requests. |
359 int DoPartialNetworkReadCompleted(int result); | 367 int DoPartialNetworkReadCompleted(int result); |
360 | 368 |
361 // Performs the needed work after receiving data from the cache, when | 369 // Performs the needed work after receiving data from the cache, when |
362 // working with range requests. | 370 // working with range requests. |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
405 bool reading_; // We are already reading. Never reverts to false once set. | 413 bool reading_; // We are already reading. Never reverts to false once set. |
406 bool invalid_range_; // We may bypass the cache for this request. | 414 bool invalid_range_; // We may bypass the cache for this request. |
407 bool truncated_; // We don't have all the response data. | 415 bool truncated_; // We don't have all the response data. |
408 bool is_sparse_; // The data is stored in sparse byte ranges. | 416 bool is_sparse_; // The data is stored in sparse byte ranges. |
409 bool range_requested_; // The user requested a byte range. | 417 bool range_requested_; // The user requested a byte range. |
410 bool handling_206_; // We must deal with this 206 response. | 418 bool handling_206_; // We must deal with this 206 response. |
411 bool cache_pending_; // We are waiting for the HttpCache. | 419 bool cache_pending_; // We are waiting for the HttpCache. |
412 bool done_reading_; // All available data was read. | 420 bool done_reading_; // All available data was read. |
413 bool vary_mismatch_; // The request doesn't match the stored vary data. | 421 bool vary_mismatch_; // The request doesn't match the stored vary data. |
414 bool couldnt_conditionalize_request_; | 422 bool couldnt_conditionalize_request_; |
| 423 bool bypass_lock_for_test_; // A test is exercising the cache lock. |
415 scoped_refptr<IOBuffer> read_buf_; | 424 scoped_refptr<IOBuffer> read_buf_; |
416 int io_buf_len_; | 425 int io_buf_len_; |
417 int read_offset_; | 426 int read_offset_; |
418 int effective_load_flags_; | 427 int effective_load_flags_; |
419 int write_len_; | 428 int write_len_; |
420 scoped_ptr<PartialData> partial_; // We are dealing with range requests. | 429 scoped_ptr<PartialData> partial_; // We are dealing with range requests. |
421 UploadProgress final_upload_progress_; | 430 UploadProgress final_upload_progress_; |
422 base::WeakPtrFactory<Transaction> weak_factory_; | 431 base::WeakPtrFactory<Transaction> weak_factory_; |
423 CompletionCallback io_callback_; | 432 CompletionCallback io_callback_; |
424 | 433 |
(...skipping 18 matching lines...) Expand all Loading... |
443 websocket_handshake_stream_base_create_helper_; | 452 websocket_handshake_stream_base_create_helper_; |
444 | 453 |
445 BeforeNetworkStartCallback before_network_start_callback_; | 454 BeforeNetworkStartCallback before_network_start_callback_; |
446 | 455 |
447 DISALLOW_COPY_AND_ASSIGN(Transaction); | 456 DISALLOW_COPY_AND_ASSIGN(Transaction); |
448 }; | 457 }; |
449 | 458 |
450 } // namespace net | 459 } // namespace net |
451 | 460 |
452 #endif // NET_HTTP_HTTP_CACHE_TRANSACTION_H_ | 461 #endif // NET_HTTP_HTTP_CACHE_TRANSACTION_H_ |
OLD | NEW |