summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorakalin@chromium.org <akalin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-23 09:59:09 +0000
committerakalin@chromium.org <akalin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-23 09:59:09 +0000
commitfa4332dc5decca49028a64d123c49cc2f3417f2d (patch)
treec1b7843034172f6c2594bb5c99fed8cef3aa2fa4
parentc7a591d04785589bba6368ca0429142b2fe2151d (diff)
downloadchromium_src-fa4332dc5decca49028a64d123c49cc2f3417f2d.zip
chromium_src-fa4332dc5decca49028a64d123c49cc2f3417f2d.tar.gz
chromium_src-fa4332dc5decca49028a64d123c49cc2f3417f2d.tar.bz2
Fixed handling of context_ in URLRequestHttpJob
This prevents crashes due to URLRequestHttpJobs hanging on past IOThread destruction. Fixed bugs in proxy script fetcher IOThread cleanup. BUG=chromium-os:8179,63692,63796 TEST=sync integration tests, chromeos browser tests Review URL: http://codereview.chromium.org/5306001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@67076 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/io_thread.cc15
-rw-r--r--net/url_request/url_request_http_job.cc5
2 files changed, 17 insertions, 3 deletions
diff --git a/chrome/browser/io_thread.cc b/chrome/browser/io_thread.cc
index 1c90b0b..a623019 100644
--- a/chrome/browser/io_thread.cc
+++ b/chrome/browser/io_thread.cc
@@ -354,8 +354,19 @@ void IOThread::CleanUp() {
// Break any cycles between the ProxyScriptFetcher and URLRequestContext.
for (ProxyScriptFetchers::const_iterator it = fetchers_.begin();
- it != fetchers_.end(); ++it) {
- (*it)->Cancel();
+ it != fetchers_.end();) {
+ ManagedProxyScriptFetcher* fetcher = *it;
+ {
+ // Hang on to the context while cancelling to avoid problems
+ // with the cancellation causing the context to be destroyed
+ // (see http://crbug.com/63796 ). Ideally, the IOThread would
+ // own the URLRequestContexts.
+ scoped_refptr<URLRequestContext> context(fetcher->GetRequestContext());
+ fetcher->Cancel();
+ }
+ // Any number of fetchers may have been deleted at this point, so
+ // use upper_bound instead of a simple increment.
+ it = fetchers_.upper_bound(fetcher);
}
// If any child processes are still running, terminate them and
diff --git a/net/url_request/url_request_http_job.cc b/net/url_request/url_request_http_job.cc
index a3e88ab..f00f490 100644
--- a/net/url_request/url_request_http_job.cc
+++ b/net/url_request/url_request_http_job.cc
@@ -77,7 +77,6 @@ URLRequestJob* URLRequestHttpJob::Factory(URLRequest* request,
URLRequestHttpJob::URLRequestHttpJob(URLRequest* request)
: URLRequestJob(request),
- context_(request->context()),
response_info_(NULL),
response_cookies_save_index_(0),
proxy_auth_state_(net::AUTH_STATE_DONT_NEED_AUTH),
@@ -609,6 +608,7 @@ void URLRequestHttpJob::DestroyTransaction() {
transaction_.reset();
response_info_ = NULL;
+ context_ = NULL;
}
void URLRequestHttpJob::StartTransaction() {
@@ -631,6 +631,9 @@ void URLRequestHttpJob::StartTransaction() {
if (rv == net::OK) {
rv = transaction_->Start(
&request_info_, &start_callback_, request_->net_log());
+ // Make sure the context is alive for the duration of the
+ // transaction.
+ context_ = request_->context();
}
}