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

Unified Diff: net/url_request/url_request_http_job.cc

Issue 10736066: Adding histograms showing fraction of page load times (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 5 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
Index: net/url_request/url_request_http_job.cc
===================================================================
--- net/url_request/url_request_http_job.cc (revision 145862)
+++ 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
mmenke 2012/07/19 16:12:54 Was hoping we could get rid of this class, but bec
tburkard 2012/07/19 16:36:15 Yes I think we need this. On 2012/07/19 16:12:54,
+ : 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);
+ 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_)) {
@@ -1433,4 +1472,8 @@
awaiting_callback_ = false;
}
+void URLRequestHttpJob::OnDetachRequest() {
+ http_transaction_delegate_->OnDetachRequest();
+}
+
} // namespace net

Powered by Google App Engine
This is Rietveld 408576698