diff options
author | mmenke@chromium.org <mmenke@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-17 22:28:11 +0000 |
---|---|---|
committer | mmenke@chromium.org <mmenke@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-17 22:28:11 +0000 |
commit | e01eaa3454ff83444190bf39b5f27303891eb279 (patch) | |
tree | 59758594bde0a8546e3383158716aba1f28ebde6 | |
parent | 0a2f3737c59387775e369264d6effbd1ca56630a (diff) | |
download | chromium_src-e01eaa3454ff83444190bf39b5f27303891eb279.zip chromium_src-e01eaa3454ff83444190bf39b5f27303891eb279.tar.gz chromium_src-e01eaa3454ff83444190bf39b5f27303891eb279.tar.bz2 |
Log errors on the URLRequestTYPE_REQUEST_ALIVE end event,
as well as on URLRequestJob's NotifyDone event.
The primary motivation of this change is to log
CONTENT_DECODING_FAILED errors to the NetLog.
BUG=89648
TEST=none
Review URL: http://codereview.chromium.org/7604043
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@97227 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | net/base/net_log_event_type_list.h | 13 | ||||
-rw-r--r-- | net/url_request/url_request.cc | 7 | ||||
-rw-r--r-- | net/url_request/url_request_job.cc | 9 | ||||
-rw-r--r-- | webkit/appcache/appcache_update_job_unittest.cc | 2 |
4 files changed, 28 insertions, 3 deletions
diff --git a/net/base/net_log_event_type_list.h b/net/base/net_log_event_type_list.h index 0035d14..c0ebe19 100644 --- a/net/base/net_log_event_type_list.h +++ b/net/base/net_log_event_type_list.h @@ -5,6 +5,10 @@ // NOTE: No header guards are used, since this file is intended to be expanded // directly into net_log.h. DO NOT include this file anywhere else. +// In the event of a failure, a many end events will have a |net_error| +// parameter with the integer error code associated with the failure. Most +// of these parameters are not individually documented. + // -------------------------------------------------------------------------- // General pseudo-events // -------------------------------------------------------------------------- @@ -13,6 +17,15 @@ // log context around it.) EVENT_TYPE(CANCELLED) +// Something failed (we determine what failed based on the log context +// around it.) +// The event has the following parameters: +// +// { +// "net_error": <The net error code integer for the failure>, +// } +EVENT_TYPE(FAILED) + // Marks the creation/destruction of a request (net::URLRequest or // SocketStream). EVENT_TYPE(REQUEST_ALIVE) diff --git a/net/url_request/url_request.cc b/net/url_request/url_request.cc index eeca035..7c94964 100644 --- a/net/url_request/url_request.cc +++ b/net/url_request/url_request.cc @@ -714,7 +714,12 @@ void URLRequest::set_context(const URLRequestContext* context) { // If the context this request belongs to has changed, update the tracker. if (prev_context != context) { - net_log_.EndEvent(NetLog::TYPE_REQUEST_ALIVE, NULL); + int net_error = OK; + // Log error only on failure, not cancellation, as even successful requests + // are "cancelled" on destruction. + if (status_.status() == URLRequestStatus::FAILED) + net_error = status_.os_error(); + net_log_.EndEventWithNetErrorCode(NetLog::TYPE_REQUEST_ALIVE, net_error); net_log_ = BoundNetLog(); if (context) { diff --git a/net/url_request/url_request_job.cc b/net/url_request/url_request_job.cc index 42c073d..4f41019 100644 --- a/net/url_request/url_request_job.cc +++ b/net/url_request/url_request_job.cc @@ -407,8 +407,15 @@ void URLRequestJob::NotifyDone(const URLRequestStatus &status) { // an error, we do not change the status back to success. To // enforce this, only set the status if the job is so far // successful. - if (request_->status().is_success()) + if (request_->status().is_success()) { + if (status.status() == URLRequestStatus::FAILED) { + request_->net_log().AddEvent( + NetLog::TYPE_FAILED, + make_scoped_refptr(new NetLogIntegerParameter("net_error", + status.os_error()))); + } request_->set_status(status); + } } // Complete this notification later. This prevents us from re-entering the diff --git a/webkit/appcache/appcache_update_job_unittest.cc b/webkit/appcache/appcache_update_job_unittest.cc index 9dd1848..d361ba5 100644 --- a/webkit/appcache/appcache_update_job_unittest.cc +++ b/webkit/appcache/appcache_update_job_unittest.cc @@ -53,7 +53,7 @@ class MockHttpServer { static net::URLRequestJob* JobFactory(net::URLRequest* request) { if (request->url().host() != "mockhost" && request->url().host() != "cross_origin_host") - return new net::URLRequestErrorJob(request, -1); + return new net::URLRequestErrorJob(request, -100); std::string headers, body; GetMockResponse(request->url().path(), &headers, &body); |