Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4306)

Unified Diff: chrome/browser/net/chrome_url_request_context_getter.cc

Issue 1124333010: Shut down Profile's URLRequestContextGetters safely. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@fetcher
Patch Set: Cleanup Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/net/chrome_url_request_context_getter.cc
diff --git a/chrome/browser/net/chrome_url_request_context_getter.cc b/chrome/browser/net/chrome_url_request_context_getter.cc
index 5f6f524c417b1114298475f5e3589e36d1d5603e..0d934927727d478d72d87f94aca86e9aab0b7434 100644
--- a/chrome/browser/net/chrome_url_request_context_getter.cc
+++ b/chrome/browser/net/chrome_url_request_context_getter.cc
@@ -170,11 +170,15 @@ class FactoryForMedia : public ChromeURLRequestContextFactory {
ChromeURLRequestContextGetter::ChromeURLRequestContextGetter(
ChromeURLRequestContextFactory* factory)
: factory_(factory),
- url_request_context_(NULL) {
+ url_request_context_(nullptr) {
DCHECK(factory);
}
-ChromeURLRequestContextGetter::~ChromeURLRequestContextGetter() {}
+ChromeURLRequestContextGetter::~ChromeURLRequestContextGetter() {
+ // NotifyContextShuttingDown() must have been called.
+ DCHECK(!factory_.get());
+ DCHECK(!url_request_context_);
+}
// Lazily create a URLRequestContext using our factory.
net::URLRequestContext*
@@ -187,17 +191,15 @@ ChromeURLRequestContextGetter::GetURLRequestContext() {
factory_.reset();
}
- // Context reference is valid, unless we're trying to use the
- // URLRequestContextGetter after the Profile has already been deleted.
- CHECK(url_request_context_);
-
return url_request_context_;
}
-void ChromeURLRequestContextGetter::Invalidate() {
+void ChromeURLRequestContextGetter::NotifyContextShuttingDown() {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
+
factory_.reset();
- url_request_context_ = NULL;
+ url_request_context_ = nullptr;
+ URLRequestContextGetter::NotifyContextShuttingDown();
}
scoped_refptr<base::SingleThreadTaskRunner>

Powered by Google App Engine
This is Rietveld 408576698