diff options
author | ericroman@google.com <ericroman@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-02-06 01:13:22 +0000 |
---|---|---|
committer | ericroman@google.com <ericroman@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-02-06 01:13:22 +0000 |
commit | 083b0a6ce42c67ca904b025bef0c72b70e2de7b1 (patch) | |
tree | af9f84674193c70315abcaa774f0c783dd033284 /net | |
parent | a31a86f053c3ff09f3cd047b165aef1d29749ea6 (diff) | |
download | chromium_src-083b0a6ce42c67ca904b025bef0c72b70e2de7b1.zip chromium_src-083b0a6ce42c67ca904b025bef0c72b70e2de7b1.tar.gz chromium_src-083b0a6ce42c67ca904b025bef0c72b70e2de7b1.tar.bz2 |
Add a constraint on how many requests can be outstanding for any given render process (browser-side).
Once the constraint is reached, subsequent requests will fail with net::ERR_INSUFFICIENT_RESOURCES.
The bound is defined as "25 MB", which represents the amount of private bytes we expect the pending requests to consume in the browser. This number translates into around 6000 typical requests.
Note that the upload data of a request is not currently considered part of the request's in-memory cost -- more data is needed on the average/maximum upload sizes of users before deciding what a compatible limit is.
BUG=5688
Review URL: http://codereview.chromium.org/18541
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@9298 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r-- | net/base/net_error_list.h | 3 | ||||
-rw-r--r-- | net/url_request/url_request.cc | 10 | ||||
-rw-r--r-- | net/url_request/url_request.h | 5 | ||||
-rw-r--r-- | net/url_request/url_request_test_job.cc | 8 |
4 files changed, 15 insertions, 11 deletions
diff --git a/net/base/net_error_list.h b/net/base/net_error_list.h index c7c66c0..49ca641 100644 --- a/net/base/net_error_list.h +++ b/net/base/net_error_list.h @@ -41,6 +41,9 @@ NET_ERROR(ACCESS_DENIED, -10) // The operation failed because of unimplemented functionality. NET_ERROR(NOT_IMPLEMENTED, -11) +// There were not enough resources to complete the operation. +NET_ERROR(INSUFFICIENT_RESOURCES, -12) + // A connection was closed (corresponding to a TCP FIN). NET_ERROR(CONNECTION_CLOSED, -100) diff --git a/net/url_request/url_request.cc b/net/url_request/url_request.cc index 19c9810..0a510d8 100644 --- a/net/url_request/url_request.cc +++ b/net/url_request/url_request.cc @@ -234,10 +234,6 @@ void URLRequest::Cancel() { void URLRequest::CancelWithError(int os_error) { DCHECK(os_error < 0); - // There's nothing to do if we are not waiting on a Job. - if (!is_pending_ || !job_) - return; - // If the URL request already has an error status, then canceling is a no-op. // Plus, we don't want to change the error status once it has been set. if (status_.is_success()) { @@ -245,6 +241,10 @@ void URLRequest::CancelWithError(int os_error) { status_.set_os_error(os_error); } + // There's nothing to do if we are not waiting on a Job. + if (!is_pending_ || !job_) + return; + job_->Kill(); // The Job will call our NotifyDone method asynchronously. This is done so @@ -350,7 +350,7 @@ int URLRequest::Redirect(const GURL& location, int http_status_code) { method_ = "GET"; } url_ = location; - upload_ = 0; + upload_ = NULL; status_ = URLRequestStatus(); --redirect_limit_; diff --git a/net/url_request/url_request.h b/net/url_request/url_request.h index f697362..008d304 100644 --- a/net/url_request/url_request.h +++ b/net/url_request/url_request.h @@ -252,6 +252,9 @@ class URLRequest { // Set the upload data directly. void set_upload(net::UploadData* upload) { upload_ = upload; } + // Get the upload data directly. + net::UploadData* get_upload() { return upload_.get(); } + // Returns true if the request has a non-empty message body to upload. bool has_upload() const { return upload_ != NULL; } @@ -268,6 +271,8 @@ class URLRequest { // call it later. void SetExtraRequestHeaders(const std::string& headers); + const std::string& extra_request_headers() { return extra_request_headers_; } + // Returns the current load state for the request. net::LoadState GetLoadState() const; diff --git a/net/url_request/url_request_test_job.cc b/net/url_request/url_request_test_job.cc index eda77a7..baefc3d 100644 --- a/net/url_request/url_request_test_job.cc +++ b/net/url_request/url_request_test_job.cc @@ -129,12 +129,8 @@ void URLRequestTestJob::GetResponseInfo(net::HttpResponseInfo* info) { } void URLRequestTestJob::Kill() { - if (request_) { - // Note that this state will still cause a NotifyDone to get called - // in ProcessNextOperation, which is required for jobs. - stage_ = ALL_DATA; - pending_jobs.push_back(scoped_refptr<URLRequestTestJob>(this)); - } + stage_ = DONE; + URLRequestJob::Kill(); } bool URLRequestTestJob::ProcessNextOperation() { |