Add AssertNoURLRequests() to URLRequestContext subclass destructors.

BUG=377852

Review URL: https://codereview.chromium.org/379293002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@284556 0039d316-1c4b-4281-b951-d872f2087c98
parent 571a6711
...@@ -162,6 +162,7 @@ class SystemURLRequestContext : public net::URLRequestContext { ...@@ -162,6 +162,7 @@ class SystemURLRequestContext : public net::URLRequestContext {
private: private:
virtual ~SystemURLRequestContext() { virtual ~SystemURLRequestContext() {
AssertNoURLRequests();
#if defined(USE_NSS) || defined(OS_IOS) #if defined(USE_NSS) || defined(OS_IOS)
net::SetURLRequestContextForNSSHttpIO(NULL); net::SetURLRequestContextForNSSHttpIO(NULL);
#endif #endif
......
...@@ -268,6 +268,7 @@ ChromeURLRequestContext::ChromeURLRequestContext() ...@@ -268,6 +268,7 @@ ChromeURLRequestContext::ChromeURLRequestContext()
ChromeURLRequestContext::~ChromeURLRequestContext() { ChromeURLRequestContext::~ChromeURLRequestContext() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
AssertNoURLRequests();
} }
void ChromeURLRequestContext::CopyFrom(ChromeURLRequestContext* other) { void ChromeURLRequestContext::CopyFrom(ChromeURLRequestContext* other) {
......
...@@ -59,7 +59,9 @@ class ExperimentURLRequestContext : public net::URLRequestContext { ...@@ -59,7 +59,9 @@ class ExperimentURLRequestContext : public net::URLRequestContext {
storage_(this), storage_(this),
weak_factory_(this) {} weak_factory_(this) {}
virtual ~ExperimentURLRequestContext() {} virtual ~ExperimentURLRequestContext() {
AssertNoURLRequests();
}
// Creates a proxy config service for |experiment|. On success returns net::OK // Creates a proxy config service for |experiment|. On success returns net::OK
// and fills |config_service| with a new pointer. Otherwise returns a network // and fills |config_service| with a new pointer. Otherwise returns a network
......
...@@ -537,7 +537,9 @@ void ProfileIOData::MediaRequestContext::SetHttpTransactionFactory( ...@@ -537,7 +537,9 @@ void ProfileIOData::MediaRequestContext::SetHttpTransactionFactory(
set_http_transaction_factory(http_factory_.get()); set_http_transaction_factory(http_factory_.get());
} }
ProfileIOData::MediaRequestContext::~MediaRequestContext() {} ProfileIOData::MediaRequestContext::~MediaRequestContext() {
AssertNoURLRequests();
}
ProfileIOData::AppRequestContext::AppRequestContext() { ProfileIOData::AppRequestContext::AppRequestContext() {
} }
...@@ -560,7 +562,9 @@ void ProfileIOData::AppRequestContext::SetJobFactory( ...@@ -560,7 +562,9 @@ void ProfileIOData::AppRequestContext::SetJobFactory(
set_job_factory(job_factory_.get()); set_job_factory(job_factory_.get());
} }
ProfileIOData::AppRequestContext::~AppRequestContext() {} ProfileIOData::AppRequestContext::~AppRequestContext() {
AssertNoURLRequests();
}
ProfileIOData::ProfileParams::ProfileParams() ProfileIOData::ProfileParams::ProfileParams()
: io_thread(NULL), : io_thread(NULL),
......
...@@ -138,7 +138,9 @@ class TestExtensionURLRequestContext : public net::URLRequestContext { ...@@ -138,7 +138,9 @@ class TestExtensionURLRequestContext : public net::URLRequestContext {
set_cookie_store(cookie_monster); set_cookie_store(cookie_monster);
} }
virtual ~TestExtensionURLRequestContext() {} virtual ~TestExtensionURLRequestContext() {
AssertNoURLRequests();
}
}; };
class TestExtensionURLRequestContextGetter class TestExtensionURLRequestContextGetter
......
...@@ -24,6 +24,7 @@ MockBlobURLRequestContext::MockBlobURLRequestContext( ...@@ -24,6 +24,7 @@ MockBlobURLRequestContext::MockBlobURLRequestContext(
} }
MockBlobURLRequestContext::~MockBlobURLRequestContext() { MockBlobURLRequestContext::~MockBlobURLRequestContext() {
AssertNoURLRequests();
} }
ScopedTextBlob::ScopedTextBlob( ScopedTextBlob::ScopedTextBlob(
......
...@@ -85,6 +85,7 @@ class RequestContext : public URLRequestContext { ...@@ -85,6 +85,7 @@ class RequestContext : public URLRequestContext {
} }
virtual ~RequestContext() { virtual ~RequestContext() {
AssertNoURLRequests();
} }
private: private:
......
...@@ -501,6 +501,7 @@ SpdyURLRequestContext::SpdyURLRequestContext(NextProto protocol, ...@@ -501,6 +501,7 @@ SpdyURLRequestContext::SpdyURLRequestContext(NextProto protocol,
} }
SpdyURLRequestContext::~SpdyURLRequestContext() { SpdyURLRequestContext::~SpdyURLRequestContext() {
AssertNoURLRequests();
} }
bool HasSpdySession(SpdySessionPool* pool, const SpdySessionKey& key) { bool HasSpdySession(SpdySessionPool* pool, const SpdySessionKey& key) {
......
...@@ -199,6 +199,9 @@ class NET_EXPORT URLRequestContext ...@@ -199,6 +199,9 @@ class NET_EXPORT URLRequestContext
return url_requests_.get(); return url_requests_.get();
} }
// CHECKs that no URLRequests using this context remain. Subclasses should
// additionally call AssertNoURLRequests() within their own destructor,
// prior to implicit destruction of subclass-owned state.
void AssertNoURLRequests() const; void AssertNoURLRequests() const;
// Get the underlying |HttpUserAgentSettings| implementation that provides // Get the underlying |HttpUserAgentSettings| implementation that provides
......
...@@ -165,7 +165,9 @@ class BasicURLRequestContext : public URLRequestContext { ...@@ -165,7 +165,9 @@ class BasicURLRequestContext : public URLRequestContext {
} }
protected: protected:
virtual ~BasicURLRequestContext() {} virtual ~BasicURLRequestContext() {
AssertNoURLRequests();
}
private: private:
// Threads should be torn down last. // Threads should be torn down last.
......
...@@ -61,6 +61,7 @@ TestURLRequestContext::TestURLRequestContext(bool delay_initialization) ...@@ -61,6 +61,7 @@ TestURLRequestContext::TestURLRequestContext(bool delay_initialization)
TestURLRequestContext::~TestURLRequestContext() { TestURLRequestContext::~TestURLRequestContext() {
DCHECK(initialized_); DCHECK(initialized_);
AssertNoURLRequests();
} }
void TestURLRequestContext::Init() { void TestURLRequestContext::Init() {
......
...@@ -20,7 +20,10 @@ namespace { ...@@ -20,7 +20,10 @@ namespace {
class TestURLRequestContext : public URLRequestContext { class TestURLRequestContext : public URLRequestContext {
public: public:
TestURLRequestContext(); TestURLRequestContext();
virtual ~TestURLRequestContext() {}
virtual ~TestURLRequestContext() {
AssertNoURLRequests();
}
// Gets a pointer to the cache backend. // Gets a pointer to the cache backend.
disk_cache::Backend* GetBackend(); disk_cache::Backend* GetBackend();
......
...@@ -266,7 +266,9 @@ class MockURLRequestContext : public URLRequestContext { ...@@ -266,7 +266,9 @@ class MockURLRequestContext : public URLRequestContext {
include_subdomains); include_subdomains);
} }
virtual ~MockURLRequestContext() {} virtual ~MockURLRequestContext() {
AssertNoURLRequests();
}
private: private:
TransportSecurityState transport_security_state_; TransportSecurityState transport_security_state_;
......
...@@ -167,6 +167,7 @@ HttpBridge::RequestContext::RequestContext( ...@@ -167,6 +167,7 @@ HttpBridge::RequestContext::RequestContext(
} }
HttpBridge::RequestContext::~RequestContext() { HttpBridge::RequestContext::~RequestContext() {
AssertNoURLRequests();
DCHECK(network_task_runner_->BelongsToCurrentThread()); DCHECK(network_task_runner_->BelongsToCurrentThread());
delete http_transaction_factory(); delete http_transaction_factory();
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment