diff options
author | willchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-07-26 06:48:44 +0000 |
---|---|---|
committer | willchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-07-26 06:48:44 +0000 |
commit | d98261678787d9f149316e3049b56b278f6c5c8c (patch) | |
tree | e88a135bdfc438c2e2e6cb5b99fc56485c05a9ce /chrome/browser/io_thread.cc | |
parent | 5fc549f0469b301169a17a28b725c8ea20d80673 (diff) | |
download | chromium_src-d98261678787d9f149316e3049b56b278f6c5c8c.zip chromium_src-d98261678787d9f149316e3049b56b278f6c5c8c.tar.gz chromium_src-d98261678787d9f149316e3049b56b278f6c5c8c.tar.bz2 |
Make Profile own ProfileIOData.
Notably this makes ChromeURLRequestContextGetter not own its ChromeURLRequestContext, and instead it keeps a base::WeakPtr. If anything is holding onto a ChromeURLRequestContextGetter longer than it should, and tries to use it, then it will crash. Currently no tests fail with this assumption, so hopefully this will prevent regressions. All ChromeURLRequestContextGetters should not outlive the Profile to which they belong.
Note that this will cause problems if there are any URLRequests which outlive the Profile to which they belong, as they will reference URLRequestContexts which point to deleted memory. AFAICT this never happens, and I will enforce this later on by making URLRequests acquire weak pointers to URLRequestContexts. After that, I can stop refcounting URLRequestContext.
I'm hopeful this changelist will fix a large number of leaks in browser_tests. Removing the refcounting of ProfileIOData will bring sanity to the lifecycle management of ProfileIOData and a large number of objects it owns. I've used base::WeakPtr in a number of places in order to prevent use-after-free bugs and force them to be NULL dereferences (crashes). In previous changelists, I've flushed out bugs revealed by this behavior. So currently, this changelist is clean on the trybots, although it's possible new code paths will be discovered via crash reports.
Next steps:
* URLRequests use base::WeakPtr<URLRequestContext>
* Fix all other URLRequestContextGetters not to acquire references to URLRequestContext.
* Stop refcounting URLRequestContext.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/7432002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@94047 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/io_thread.cc')
-rw-r--r-- | chrome/browser/io_thread.cc | 38 |
1 files changed, 0 insertions, 38 deletions
diff --git a/chrome/browser/io_thread.cc b/chrome/browser/io_thread.cc index 85c7e2a..4d716da 100644 --- a/chrome/browser/io_thread.cc +++ b/chrome/browser/io_thread.cc @@ -401,30 +401,6 @@ void IOThread::InitNetworkPredictor( startup_urls, referral_list, preconnect_enabled)); } -void IOThread::RegisterURLRequestContextGetter( - ChromeURLRequestContextGetter* url_request_context_getter) { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); - std::list<ChromeURLRequestContextGetter*>::const_iterator it = - std::find(url_request_context_getters_.begin(), - url_request_context_getters_.end(), - url_request_context_getter); - DCHECK(it == url_request_context_getters_.end()); - url_request_context_getters_.push_back(url_request_context_getter); -} - -void IOThread::UnregisterURLRequestContextGetter( - ChromeURLRequestContextGetter* url_request_context_getter) { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); - std::list<ChromeURLRequestContextGetter*>::iterator it = - std::find(url_request_context_getters_.begin(), - url_request_context_getters_.end(), - url_request_context_getter); - DCHECK(it != url_request_context_getters_.end()); - // This does not scale, but we shouldn't have many URLRequestContextGetters in - // the first place, so this should be fine. - url_request_context_getters_.erase(it); -} - void IOThread::ChangedToOnTheRecord() { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); message_loop()->PostTask( @@ -532,20 +508,6 @@ void IOThread::CleanUp() { // IO thread only resources they are referencing. BrowserChildProcessHost::TerminateAll(); - std::list<ChromeURLRequestContextGetter*> url_request_context_getters; - url_request_context_getters.swap(url_request_context_getters_); - for (std::list<ChromeURLRequestContextGetter*>::iterator it = - url_request_context_getters.begin(); - it != url_request_context_getters.end(); ++it) { - ChromeURLRequestContextGetter* getter = *it; - // Stop all pending certificate provenance check uploads - net::DnsCertProvenanceChecker* checker = - getter->GetURLRequestContext()->dns_cert_checker(); - if (checker) - checker->Shutdown(); - getter->ReleaseURLRequestContext(); - } - system_url_request_context_getter_ = NULL; // Step 2: Release objects that the net::URLRequestContext could have been |