Chromium Code Reviews| Index: net/http/http_cache_transaction.cc |
| diff --git a/net/http/http_cache_transaction.cc b/net/http/http_cache_transaction.cc |
| index 6665d5ff404661c09502d469b815db7a506dc255..610a729f5292af1fbe06c101c9f88128323cc14d 100644 |
| --- a/net/http/http_cache_transaction.cc |
| +++ b/net/http/http_cache_transaction.cc |
| @@ -23,10 +23,12 @@ |
| #include "net/base/load_flags.h" |
| #include "net/base/net_errors.h" |
| #include "net/base/net_log.h" |
| +#include "net/base/network_delegate.h" |
| #include "net/base/ssl_cert_request_info.h" |
| #include "net/base/ssl_config_service.h" |
| #include "net/disk_cache/disk_cache.h" |
| #include "net/http/disk_cache_based_ssl_host_info.h" |
| +#include "net/http/http_network_session.h" |
| #include "net/http/http_request_info.h" |
| #include "net/http/http_response_headers.h" |
| #include "net/http/http_transaction.h" |
| @@ -529,6 +531,12 @@ int HttpCache::Transaction::DoLoop(int result) { |
| case STATE_CACHE_READ_RESPONSE_COMPLETE: |
| rv = DoCacheReadResponseComplete(rv); |
| break; |
| + case STATE_CACHE_NOTIFY_BEFORE_SEND_HEADERS: |
| + rv = DoCacheNotifyBeforeSendHeaders(rv); |
| + break; |
| + case STATE_CACHE_NOTIFY_BEFORE_SEND_HEADERS_COMPLETE: |
| + rv = DoCacheNotifyBeforeSendHeadersComplete(rv); |
| + break; |
| case STATE_CACHE_WRITE_RESPONSE: |
| DCHECK_EQ(OK, rv); |
| rv = DoCacheWriteResponse(); |
| @@ -1109,6 +1117,8 @@ int HttpCache::Transaction::DoCacheReadResponse() { |
| int HttpCache::Transaction::DoCacheReadResponseComplete(int result) { |
| cache_callback_->Release(); // Balance the AddRef from DoCacheReadResponse. |
| + next_state_ = STATE_CACHE_NOTIFY_BEFORE_SEND_HEADERS; |
| + |
| net_log_.EndEventWithNetErrorCode(NetLog::TYPE_HTTP_CACHE_READ_INFO, result); |
| if (result != io_buf_len_ || |
| !HttpCache::ParseResponseInfo(read_buf_->data(), io_buf_len_, |
| @@ -1117,6 +1127,28 @@ int HttpCache::Transaction::DoCacheReadResponseComplete(int result) { |
| return ERR_CACHE_READ_FAILURE; |
| } |
| + return OK; |
| +} |
| + |
| +int HttpCache::Transaction::DoCacheNotifyBeforeSendHeaders(int result) { |
|
rvargas (doing something else)
2011/03/23 00:54:35
nit: no need for the argument.
Matt Perry
2011/03/24 00:11:25
Done.
|
| + // Balanced in DoCacheNotifyBeforeSendHeadersComplete. |
| + cache_callback_->AddRef(); |
| + next_state_ = STATE_CACHE_NOTIFY_BEFORE_SEND_HEADERS_COMPLETE; |
| + |
| + if (cache_->GetSession()->network_delegate()) { |
| + // TODO(mpcomplete): need to e able to modify these headers. |
|
rvargas (doing something else)
2011/03/23 00:54:35
nit: to be able.
Matt Perry
2011/03/24 00:11:25
Done.
|
| + HttpRequestHeaders headers = request_->extra_headers; |
| + if (cache_->GetSession()->network_delegate()->NotifyBeforeSendHeaders( |
|
rvargas (doing something else)
2011/03/23 00:54:35
I forgot to mention that it is possible to go thro
Matt Perry
2011/03/24 00:11:25
We will actually only respond to the first notific
|
| + request_->request_id, &headers, cache_callback_)) |
| + return ERR_IO_PENDING; |
| + } |
| + |
| + return OK; |
| +} |
| + |
| +int HttpCache::Transaction::DoCacheNotifyBeforeSendHeadersComplete(int result) { |
|
rvargas (doing something else)
2011/03/23 00:54:35
Result should be related to the return value of No
Matt Perry
2011/03/24 00:11:25
The result from the callback is either net::OK, or
rvargas (doing something else)
2011/03/24 18:16:02
Just to double check, an error code here means tha
Matt Perry
2011/03/24 20:39:37
Right.
|
| + cache_callback_->Release(); // Balanced in DoCacheNotifyBeforeSendHeaders. |
| + |
| // We now have access to the cache entry. |
| // |
| // o if we are a reader for the transaction, then we can start reading the |
| @@ -1130,20 +1162,22 @@ int HttpCache::Transaction::DoCacheReadResponseComplete(int result) { |
| // conditionalized request (if-modified-since / if-none-match). We check |
| // if the request headers define a validation request. |
| // |
| - switch (mode_) { |
| - case READ: |
| - result = BeginCacheRead(); |
| - break; |
| - case READ_WRITE: |
| - result = BeginPartialCacheValidation(); |
| - break; |
| - case UPDATE: |
| - result = BeginExternallyConditionalizedRequest(); |
| - break; |
| - case WRITE: |
| - default: |
| - NOTREACHED(); |
| - result = ERR_FAILED; |
| + if (result == net::OK) { |
| + switch (mode_) { |
| + case READ: |
| + result = BeginCacheRead(); |
| + break; |
| + case READ_WRITE: |
| + result = BeginPartialCacheValidation(); |
| + break; |
| + case UPDATE: |
| + result = BeginExternallyConditionalizedRequest(); |
| + break; |
| + case WRITE: |
| + default: |
| + NOTREACHED(); |
| + result = ERR_FAILED; |
| + } |
| } |
| return result; |
| } |