| 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 #pragma once | 10 #pragma once |
| 11 | 11 |
| 12 #include <string> | 12 #include <string> |
| 13 | 13 |
| 14 #include "base/time.h" | 14 #include "base/time.h" |
| 15 #include "net/base/completion_callback.h" | 15 #include "net/base/completion_callback.h" |
| 16 #include "net/base/net_log.h" | 16 #include "net/base/net_log.h" |
| 17 #include "net/http/http_cache.h" | 17 #include "net/http/http_cache.h" |
| 18 #include "net/http/http_response_info.h" | 18 #include "net/http/http_response_info.h" |
| 19 #include "net/http/http_request_headers.h" | 19 #include "net/http/http_request_headers.h" |
| 20 #include "net/http/http_transaction.h" | 20 #include "net/http/http_transaction.h" |
| 21 | 21 |
| 22 namespace net { | 22 namespace net { |
| 23 | 23 |
| 24 class PartialData; | 24 class PartialData; |
| 25 struct HttpRequestInfo; | 25 struct HttpRequestInfo; |
| 26 class HttpTransactionDelegate; |
| 26 | 27 |
| 27 // This is the transaction that is returned by the HttpCache transaction | 28 // This is the transaction that is returned by the HttpCache transaction |
| 28 // factory. | 29 // factory. |
| 29 class HttpCache::Transaction : public HttpTransaction { | 30 class HttpCache::Transaction : public HttpTransaction { |
| 30 public: | 31 public: |
| 31 // The transaction has the following modes, which apply to how it may access | 32 // The transaction has the following modes, which apply to how it may access |
| 32 // its cache entry. | 33 // its cache entry. |
| 33 // | 34 // |
| 34 // o If the mode of the transaction is NONE, then it is in "pass through" | 35 // o If the mode of the transaction is NONE, then it is in "pass through" |
| 35 // mode and all methods just forward to the inner network transaction. | 36 // mode and all methods just forward to the inner network transaction. |
| (...skipping 14 matching lines...) Expand all Loading... |
| 50 enum Mode { | 51 enum Mode { |
| 51 NONE = 0, | 52 NONE = 0, |
| 52 READ_META = 1 << 0, | 53 READ_META = 1 << 0, |
| 53 READ_DATA = 1 << 1, | 54 READ_DATA = 1 << 1, |
| 54 READ = READ_META | READ_DATA, | 55 READ = READ_META | READ_DATA, |
| 55 WRITE = 1 << 2, | 56 WRITE = 1 << 2, |
| 56 READ_WRITE = READ | WRITE, | 57 READ_WRITE = READ | WRITE, |
| 57 UPDATE = READ_META | WRITE, // READ_WRITE & ~READ_DATA | 58 UPDATE = READ_META | WRITE, // READ_WRITE & ~READ_DATA |
| 58 }; | 59 }; |
| 59 | 60 |
| 60 explicit Transaction(HttpCache* cache); | 61 explicit Transaction(HttpCache* cache, HttpTransactionDelegate* delegate); |
| 61 virtual ~Transaction(); | 62 virtual ~Transaction(); |
| 62 | 63 |
| 63 Mode mode() const { return mode_; } | 64 Mode mode() const { return mode_; } |
| 64 | 65 |
| 65 const std::string& key() const { return cache_key_; } | 66 const std::string& key() const { return cache_key_; } |
| 66 | 67 |
| 67 // 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 |
| 68 // HTTP cache entry that backs this transaction (if any). | 69 // HTTP cache entry that backs this transaction (if any). |
| 69 // 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 |
| 70 // operation cannot complete immediately, returns ERR_IO_PENDING, grabs a | 71 // operation cannot complete immediately, returns ERR_IO_PENDING, grabs a |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 328 int DoPartialCacheReadCompleted(int result); | 329 int DoPartialCacheReadCompleted(int result); |
| 329 | 330 |
| 330 // Returns true if we should bother attempting to resume this request if it | 331 // Returns true if we should bother attempting to resume this request if it |
| 331 // is aborted while in progress. If |has_data| is true, the size of the stored | 332 // is aborted while in progress. If |has_data| is true, the size of the stored |
| 332 // data is considered for the result. | 333 // data is considered for the result. |
| 333 bool CanResume(bool has_data); | 334 bool CanResume(bool has_data); |
| 334 | 335 |
| 335 // Called to signal completion of asynchronous IO. | 336 // Called to signal completion of asynchronous IO. |
| 336 void OnIOComplete(int result); | 337 void OnIOComplete(int result); |
| 337 | 338 |
| 339 void ReportCacheActionStart(); |
| 340 void ReportCacheActionFinish(); |
| 341 |
| 338 State next_state_; | 342 State next_state_; |
| 339 const HttpRequestInfo* request_; | 343 const HttpRequestInfo* request_; |
| 340 BoundNetLog net_log_; | 344 BoundNetLog net_log_; |
| 341 scoped_ptr<HttpRequestInfo> custom_request_; | 345 scoped_ptr<HttpRequestInfo> custom_request_; |
| 342 HttpRequestHeaders request_headers_copy_; | 346 HttpRequestHeaders request_headers_copy_; |
| 343 // If extra_headers specified a "if-modified-since" or "if-none-match", | 347 // If extra_headers specified a "if-modified-since" or "if-none-match", |
| 344 // |external_validation_| contains the value of those headers. | 348 // |external_validation_| contains the value of those headers. |
| 345 ValidationHeaders external_validation_; | 349 ValidationHeaders external_validation_; |
| 346 base::WeakPtr<HttpCache> cache_; | 350 base::WeakPtr<HttpCache> cache_; |
| 347 HttpCache::ActiveEntry* entry_; | 351 HttpCache::ActiveEntry* entry_; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 365 bool done_reading_; | 369 bool done_reading_; |
| 366 scoped_refptr<IOBuffer> read_buf_; | 370 scoped_refptr<IOBuffer> read_buf_; |
| 367 int io_buf_len_; | 371 int io_buf_len_; |
| 368 int read_offset_; | 372 int read_offset_; |
| 369 int effective_load_flags_; | 373 int effective_load_flags_; |
| 370 int write_len_; | 374 int write_len_; |
| 371 scoped_ptr<PartialData> partial_; // We are dealing with range requests. | 375 scoped_ptr<PartialData> partial_; // We are dealing with range requests. |
| 372 uint64 final_upload_progress_; | 376 uint64 final_upload_progress_; |
| 373 base::WeakPtrFactory<Transaction> weak_factory_; | 377 base::WeakPtrFactory<Transaction> weak_factory_; |
| 374 CompletionCallback io_callback_; | 378 CompletionCallback io_callback_; |
| 379 HttpTransactionDelegate* delegate_; |
| 375 }; | 380 }; |
| 376 | 381 |
| 377 } // namespace net | 382 } // namespace net |
| 378 | 383 |
| 379 #endif // NET_HTTP_HTTP_CACHE_TRANSACTION_H_ | 384 #endif // NET_HTTP_HTTP_CACHE_TRANSACTION_H_ |
| OLD | NEW |