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..1234f327e76f751902501e07d381340a1cfed695 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,9 @@ int HttpCache::Transaction::DoLoop(int result) { |
| case STATE_CACHE_READ_RESPONSE_COMPLETE: |
| rv = DoCacheReadResponseComplete(rv); |
| break; |
| + case STATE_CACHE_BEFORE_WRITE_RESPONSE: |
| + rv = DoCacheBeforeWriteResponse(rv); |
| + break; |
| case STATE_CACHE_WRITE_RESPONSE: |
| DCHECK_EQ(OK, rv); |
| rv = DoCacheWriteResponse(); |
| @@ -1096,6 +1101,7 @@ int HttpCache::Transaction::DoPartialHeadersReceived() { |
| int HttpCache::Transaction::DoCacheReadResponse() { |
| DCHECK(entry_); |
| + |
|
rvargas (doing something else)
2011/03/17 19:40:20
nit: remove
Matt Perry
2011/03/22 21:11:43
Done.
|
| next_state_ = STATE_CACHE_READ_RESPONSE_COMPLETE; |
| io_buf_len_ = entry_->disk_entry->GetDataSize(kResponseInfoIndex); |
| @@ -1117,6 +1123,24 @@ int HttpCache::Transaction::DoCacheReadResponseComplete(int result) { |
| return ERR_CACHE_READ_FAILURE; |
| } |
| + next_state_ = STATE_CACHE_BEFORE_WRITE_RESPONSE; |
|
rvargas (doing something else)
2011/03/17 19:40:20
This should be related to the actual action perfor
Matt Perry
2011/03/22 21:11:43
Done.
|
| + |
| + cache_callback_->AddRef(); // Balanced in DoCacheBeforeWriteResponse. |
|
rvargas (doing something else)
2011/03/17 19:40:20
I don't think you want to use this callback. This
Matt Perry
2011/03/22 21:11:43
I need a cancelable callback since the network del
|
| + if (cache_->GetSession()->network_delegate()) { |
| + // TODO(mpcomplete): Does it make sense to pass request headers here? Where |
| + // do we get them? |
|
rvargas (doing something else)
2011/03/17 19:40:20
request_->extra_headers
Matt Perry
2011/03/22 21:11:43
Done.
|
| + HttpRequestHeaders empty_headers; |
| + if (cache_->GetSession()->network_delegate()->NotifyBeforeHttpRequest( |
| + request_->request_id, &empty_headers, cache_callback_)) |
| + return ERR_IO_PENDING; |
| + } |
| + |
| + return OK; |
| +} |
| + |
| +int HttpCache::Transaction::DoCacheBeforeWriteResponse(int result) { |
| + cache_callback_->Release(); // balanced in DoCacheReadResponseComplete |
| + |
| // 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 +1154,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; |
| } |