| 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 // the cache entry. | 42 // the cache entry. |
| 43 // | 43 // |
| 44 // o If the mode of the transaction is READ_WRITE, then the transaction may | 44 // o If the mode of the transaction is READ_WRITE, then the transaction may |
| 45 // optionally modify the cache entry (e.g., possibly corresponding to | 45 // optionally modify the cache entry (e.g., possibly corresponding to |
| 46 // cache validation). | 46 // cache validation). |
| 47 // | 47 // |
| 48 // o If the mode of the transaction is UPDATE, then the transaction may | 48 // o If the mode of the transaction is UPDATE, then the transaction may |
| 49 // update existing cache entries, but will never create a new entry or | 49 // update existing cache entries, but will never create a new entry or |
| 50 // respond using the entry read from the cache. | 50 // respond using the entry read from the cache. |
| 51 enum Mode { | 51 enum Mode { |
| 52 NONE = 0, | 52 NONE = 0, |
| 53 READ_META = 1 << 0, | 53 READ_META = 1 << 0, |
| 54 READ_DATA = 1 << 1, | 54 READ_DATA = 1 << 1, |
| 55 READ = READ_META | READ_DATA, | 55 READ = READ_META | READ_DATA, |
| 56 WRITE = 1 << 2, | 56 WRITE = 1 << 2, |
| 57 READ_WRITE = READ | WRITE, | 57 READ_WRITE = READ | WRITE, |
| 58 UPDATE = READ_META | WRITE, // READ_WRITE & ~READ_DATA | 58 UPDATE = READ_META | WRITE, // READ_WRITE & ~READ_DATA |
| 59 }; | 59 }; |
| 60 | 60 |
| 61 Transaction(RequestPriority priority, | 61 Transaction(RequestPriority priority, HttpCache* cache); |
| 62 HttpCache* cache); | |
| 63 virtual ~Transaction(); | 62 virtual ~Transaction(); |
| 64 | 63 |
| 65 Mode mode() const { return mode_; } | 64 Mode mode() const { return mode_; } |
| 66 | 65 |
| 67 const std::string& key() const { return cache_key_; } | 66 const std::string& key() const { return cache_key_; } |
| 68 | 67 |
| 69 // Writes |buf_len| bytes of meta-data from the provided buffer |buf|. to the | 68 // Writes |buf_len| bytes of meta-data from the provided buffer |buf|. to the |
| 70 // HTTP cache entry that backs this transaction (if any). | 69 // HTTP cache entry that backs this transaction (if any). |
| 71 // Returns the number of bytes actually written, or a net error code. If the | 70 // Returns the number of bytes actually written, or a net error code. If the |
| 72 // operation cannot complete immediately, returns ERR_IO_PENDING, grabs a | 71 // operation cannot complete immediately, returns ERR_IO_PENDING, grabs a |
| (...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 323 | 322 |
| 324 // Reads data from the network. | 323 // Reads data from the network. |
| 325 int ReadFromNetwork(IOBuffer* data, int data_len); | 324 int ReadFromNetwork(IOBuffer* data, int data_len); |
| 326 | 325 |
| 327 // Reads data from the cache entry. | 326 // Reads data from the cache entry. |
| 328 int ReadFromEntry(IOBuffer* data, int data_len); | 327 int ReadFromEntry(IOBuffer* data, int data_len); |
| 329 | 328 |
| 330 // Called to write data to the cache entry. If the write fails, then the | 329 // Called to write data to the cache entry. If the write fails, then the |
| 331 // cache entry is destroyed. Future calls to this function will just do | 330 // cache entry is destroyed. Future calls to this function will just do |
| 332 // nothing without side-effect. Returns a network error code. | 331 // nothing without side-effect. Returns a network error code. |
| 333 int WriteToEntry(int index, int offset, IOBuffer* data, int data_len, | 332 int WriteToEntry(int index, |
| 333 int offset, |
| 334 IOBuffer* data, |
| 335 int data_len, |
| 334 const CompletionCallback& callback); | 336 const CompletionCallback& callback); |
| 335 | 337 |
| 336 // Called to write response_ to the cache entry. |truncated| indicates if the | 338 // Called to write response_ to the cache entry. |truncated| indicates if the |
| 337 // entry should be marked as incomplete. | 339 // entry should be marked as incomplete. |
| 338 int WriteResponseInfoToEntry(bool truncated); | 340 int WriteResponseInfoToEntry(bool truncated); |
| 339 | 341 |
| 340 // Called to append response data to the cache entry. Returns a network error | 342 // Called to append response data to the cache entry. Returns a network error |
| 341 // code. | 343 // code. |
| 342 int AppendResponseDataToEntry(IOBuffer* data, int data_len, | 344 int AppendResponseDataToEntry(IOBuffer* data, |
| 345 int data_len, |
| 343 const CompletionCallback& callback); | 346 const CompletionCallback& callback); |
| 344 | 347 |
| 345 // Called when we are done writing to the cache entry. | 348 // Called when we are done writing to the cache entry. |
| 346 void DoneWritingToEntry(bool success); | 349 void DoneWritingToEntry(bool success); |
| 347 | 350 |
| 348 // Returns an error to signal the caller that the current read failed. The | 351 // 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 | 352 // current operation |result| is also logged. If |restart| is true, the |
| 350 // transaction should be restarted. | 353 // transaction should be restarted. |
| 351 int OnCacheReadError(int result, bool restart); | 354 int OnCacheReadError(int result, bool restart); |
| 352 | 355 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 396 HttpCache::ActiveEntry* new_entry_; | 399 HttpCache::ActiveEntry* new_entry_; |
| 397 scoped_ptr<HttpTransaction> network_trans_; | 400 scoped_ptr<HttpTransaction> network_trans_; |
| 398 CompletionCallback callback_; // Consumer's callback. | 401 CompletionCallback callback_; // Consumer's callback. |
| 399 HttpResponseInfo response_; | 402 HttpResponseInfo response_; |
| 400 HttpResponseInfo auth_response_; | 403 HttpResponseInfo auth_response_; |
| 401 const HttpResponseInfo* new_response_; | 404 const HttpResponseInfo* new_response_; |
| 402 std::string cache_key_; | 405 std::string cache_key_; |
| 403 Mode mode_; | 406 Mode mode_; |
| 404 State target_state_; | 407 State target_state_; |
| 405 bool reading_; // We are already reading. Never reverts to false once set. | 408 bool reading_; // We are already reading. Never reverts to false once set. |
| 406 bool invalid_range_; // We may bypass the cache for this request. | 409 bool invalid_range_; // We may bypass the cache for this request. |
| 407 bool truncated_; // We don't have all the response data. | 410 bool truncated_; // We don't have all the response data. |
| 408 bool is_sparse_; // The data is stored in sparse byte ranges. | 411 bool is_sparse_; // The data is stored in sparse byte ranges. |
| 409 bool range_requested_; // The user requested a byte range. | 412 bool range_requested_; // The user requested a byte range. |
| 410 bool handling_206_; // We must deal with this 206 response. | 413 bool handling_206_; // We must deal with this 206 response. |
| 411 bool cache_pending_; // We are waiting for the HttpCache. | 414 bool cache_pending_; // We are waiting for the HttpCache. |
| 412 bool done_reading_; // All available data was read. | 415 bool done_reading_; // All available data was read. |
| 413 bool vary_mismatch_; // The request doesn't match the stored vary data. | 416 bool vary_mismatch_; // The request doesn't match the stored vary data. |
| 414 bool couldnt_conditionalize_request_; | 417 bool couldnt_conditionalize_request_; |
| 415 scoped_refptr<IOBuffer> read_buf_; | 418 scoped_refptr<IOBuffer> read_buf_; |
| 416 int io_buf_len_; | 419 int io_buf_len_; |
| 417 int read_offset_; | 420 int read_offset_; |
| 418 int effective_load_flags_; | 421 int effective_load_flags_; |
| 419 int write_len_; | 422 int write_len_; |
| 420 scoped_ptr<PartialData> partial_; // We are dealing with range requests. | 423 scoped_ptr<PartialData> partial_; // We are dealing with range requests. |
| 421 UploadProgress final_upload_progress_; | 424 UploadProgress final_upload_progress_; |
| 422 base::WeakPtrFactory<Transaction> weak_factory_; | 425 base::WeakPtrFactory<Transaction> weak_factory_; |
| 423 CompletionCallback io_callback_; | 426 CompletionCallback io_callback_; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 443 websocket_handshake_stream_base_create_helper_; | 446 websocket_handshake_stream_base_create_helper_; |
| 444 | 447 |
| 445 BeforeNetworkStartCallback before_network_start_callback_; | 448 BeforeNetworkStartCallback before_network_start_callback_; |
| 446 | 449 |
| 447 DISALLOW_COPY_AND_ASSIGN(Transaction); | 450 DISALLOW_COPY_AND_ASSIGN(Transaction); |
| 448 }; | 451 }; |
| 449 | 452 |
| 450 } // namespace net | 453 } // namespace net |
| 451 | 454 |
| 452 #endif // NET_HTTP_HTTP_CACHE_TRANSACTION_H_ | 455 #endif // NET_HTTP_HTTP_CACHE_TRANSACTION_H_ |
| OLD | NEW |