Chromium Code Reviews| Index: net/url_request/url_request_http_job.cc |
| =================================================================== |
| --- net/url_request/url_request_http_job.cc (revision 147723) |
| +++ net/url_request/url_request_http_job.cc (working copy) |
| @@ -34,6 +34,7 @@ |
| #include "net/http/http_response_info.h" |
| #include "net/http/http_status_code.h" |
| #include "net/http/http_transaction.h" |
| +#include "net/http/http_transaction_delegate.h" |
| #include "net/http/http_transaction_factory.h" |
| #include "net/http/http_util.h" |
| #include "net/url_request/fraudulent_certificate_reporter.h" |
| @@ -74,6 +75,43 @@ |
| DISALLOW_COPY_AND_ASSIGN(HttpFilterContext); |
| }; |
| +class URLRequestHttpJob::HttpTransactionDelegateImpl |
| + : public HttpTransactionDelegate { |
| + public: |
| + HttpTransactionDelegateImpl(URLRequest* request) |
| + : request_(request), |
| + network_delegate_(request->context()->network_delegate()) { |
| + } |
| + virtual ~HttpTransactionDelegateImpl() { |
| + OnDetachRequest(); |
| + } |
| + void OnDetachRequest() { |
| + if (request_ == NULL || network_delegate_ == NULL) |
| + return; |
| + network_delegate_->NotifyCacheWaitStateChange( |
| + *request_, |
| + NetworkDelegate::CACHE_WAIT_STATE_DONE); |
|
rvargas (doing something else)
2012/07/23 22:22:36
This generates a notification when the first job g
tburkard
2012/07/24 01:03:12
Excellent comment -- I was not aware that a reques
mmenke
2012/07/24 01:21:25
I actually thought about this, surprisingly ;). W
rvargas (doing something else)
2012/07/24 03:10:38
Isn't _STATE_DONE supposed to indicate that all pr
tburkard
2012/07/24 22:23:26
Done.
|
| + request_ = NULL; |
| + } |
| + virtual void OnCacheActionStart() OVERRIDE { |
| + if (request_ == NULL || network_delegate_ == NULL) |
| + return; |
| + network_delegate_->NotifyCacheWaitStateChange( |
| + *request_, |
| + NetworkDelegate::CACHE_WAIT_STATE_START); |
| + } |
| + virtual void OnCacheActionFinish() OVERRIDE { |
| + if (request_ == NULL || network_delegate_ == NULL) |
| + return; |
| + network_delegate_->NotifyCacheWaitStateChange( |
| + *request_, |
| + NetworkDelegate::CACHE_WAIT_STATE_FINISH); |
| + } |
| + private: |
| + URLRequest* request_; |
| + NetworkDelegate* network_delegate_; |
| +}; |
| + |
| URLRequestHttpJob::HttpFilterContext::HttpFilterContext(URLRequestHttpJob* job) |
| : job_(job) { |
| DCHECK(job_); |
| @@ -178,7 +216,8 @@ |
| ALLOW_THIS_IN_INITIALIZER_LIST(on_headers_received_callback_( |
| base::Bind(&URLRequestHttpJob::OnHeadersReceivedCallback, |
| base::Unretained(this)))), |
| - awaiting_callback_(false) { |
| + awaiting_callback_(false), |
| + http_transaction_delegate_(new HttpTransactionDelegateImpl(request)) { |
| URLRequestThrottlerManager* manager = request->context()->throttler_manager(); |
| if (manager) |
| throttling_entry_ = manager->RegisterRequestUrl(request->url()); |
| @@ -306,7 +345,7 @@ |
| DCHECK(request_->context()->http_transaction_factory()); |
| rv = request_->context()->http_transaction_factory()->CreateTransaction( |
| - &transaction_); |
| + &transaction_, http_transaction_delegate_.get()); |
| if (rv == OK) { |
| if (!throttling_entry_ || |
| !throttling_entry_->ShouldRejectRequest(*request_)) { |
| @@ -1437,4 +1476,8 @@ |
| awaiting_callback_ = false; |
| } |
| +void URLRequestHttpJob::OnDetachRequest() { |
| + http_transaction_delegate_->OnDetachRequest(); |
| +} |
| + |
| } // namespace net |