Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(492)

Unified Diff: net/http/http_cache_transaction.cc

Issue 6698009: Add request_id to HttpRequestInfo and pass it to the NetworkDelegate for events. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 500 error Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/http/http_cache_transaction.h ('k') | net/http/http_network_transaction.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/http/http_cache_transaction.cc
diff --git a/net/http/http_cache_transaction.cc b/net/http/http_cache_transaction.cc
index bf29f85956534fd4e123fcf90a613d6b55849c14..201f647006806e2fd41d0cb4cb77bb2e65d15c68 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"
@@ -486,6 +488,13 @@ int HttpCache::Transaction::DoLoop(int result) {
case STATE_ADD_TO_ENTRY_COMPLETE:
rv = DoAddToEntryComplete(rv);
break;
+ case STATE_NOTIFY_BEFORE_SEND_HEADERS:
+ DCHECK_EQ(OK, rv);
+ rv = DoNotifyBeforeSendHeaders();
+ break;
+ case STATE_NOTIFY_BEFORE_SEND_HEADERS_COMPLETE:
+ rv = DoNotifyBeforeSendHeadersComplete(rv);
+ break;
case STATE_START_PARTIAL_CACHE_VALIDATION:
DCHECK_EQ(OK, rv);
rv = DoStartPartialCacheValidation();
@@ -909,6 +918,57 @@ int HttpCache::Transaction::DoAddToEntryComplete(int result) {
return OK;
}
+int HttpCache::Transaction::DoNotifyBeforeSendHeaders() {
+ // Balanced in DoNotifyBeforeSendHeadersComplete.
+ cache_callback_->AddRef();
+ next_state_ = STATE_NOTIFY_BEFORE_SEND_HEADERS_COMPLETE;
+
+ if (cache_->GetSession() && cache_->GetSession()->network_delegate()) {
+ // TODO(mpcomplete): need to be able to modify these headers.
+ HttpRequestHeaders headers = request_->extra_headers;
+ return cache_->GetSession()->network_delegate()->NotifyBeforeSendHeaders(
+ request_->request_id, &headers, cache_callback_);
+ }
+
+ return OK;
+}
+
+int HttpCache::Transaction::DoNotifyBeforeSendHeadersComplete(int result) {
+ cache_callback_->Release(); // Balanced in DoNotifyBeforeSendHeaders.
+
+ // We now have access to the cache entry.
+ //
+ // o if we are a reader for the transaction, then we can start reading the
+ // cache entry.
+ //
+ // o if we can read or write, then we should check if the cache entry needs
+ // to be validated and then issue a network request if needed or just read
+ // from the cache if the cache entry is already valid.
+ //
+ // o if we are set to UPDATE, then we are handling an externally
+ // conditionalized request (if-modified-since / if-none-match). We check
+ // if the request headers define a validation request.
+ //
+ 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;
+}
+
// We may end up here multiple times for a given request.
int HttpCache::Transaction::DoStartPartialCacheValidation() {
if (mode_ == NONE)
@@ -1109,6 +1169,8 @@ int HttpCache::Transaction::DoCacheReadResponse() {
int HttpCache::Transaction::DoCacheReadResponseComplete(int result) {
cache_callback_->Release(); // Balance the AddRef from DoCacheReadResponse.
+ next_state_ = STATE_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,35 +1179,7 @@ int HttpCache::Transaction::DoCacheReadResponseComplete(int result) {
return ERR_CACHE_READ_FAILURE;
}
- // We now have access to the cache entry.
- //
- // o if we are a reader for the transaction, then we can start reading the
- // cache entry.
- //
- // o if we can read or write, then we should check if the cache entry needs
- // to be validated and then issue a network request if needed or just read
- // from the cache if the cache entry is already valid.
- //
- // o if we are set to UPDATE, then we are handling an externally
- // 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;
- }
- return result;
+ return OK;
}
int HttpCache::Transaction::DoCacheWriteResponse() {
« no previous file with comments | « net/http/http_cache_transaction.h ('k') | net/http/http_network_transaction.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698