summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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();
}
}