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 {
private:
virtual ~SystemURLRequestContext() {
AssertNoURLRequests();
#if defined(USE_NSS) || defined(OS_IOS)
net::SetURLRequestContextForNSSHttpIO(NULL);
#endif
......
......@@ -268,6 +268,7 @@ ChromeURLRequestContext::ChromeURLRequestContext()
ChromeURLRequestContext::~ChromeURLRequestContext() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
AssertNoURLRequests();
}
void ChromeURLRequestContext::CopyFrom(ChromeURLRequestContext* other) {
......
......@@ -59,7 +59,9 @@ class ExperimentURLRequestContext : public net::URLRequestContext {
storage_(this),
weak_factory_(this) {}
virtual ~ExperimentURLRequestContext() {}
virtual ~ExperimentURLRequestContext() {
AssertNoURLRequests();
}
// Creates a proxy config service for |experiment|. On success returns net::OK
// and fills |config_service| with a new pointer. Otherwise returns a network
......
......@@ -537,7 +537,9 @@ void ProfileIOData::MediaRequestContext::SetHttpTransactionFactory(
set_http_transaction_factory(http_factory_.get());
}
ProfileIOData::MediaRequestContext::~MediaRequestContext() {}
ProfileIOData::MediaRequestContext::~MediaRequestContext() {
AssertNoURLRequests();
}
ProfileIOData::AppRequestContext::AppRequestContext() {
}
......@@ -560,7 +562,9 @@ void ProfileIOData::AppRequestContext::SetJobFactory(
set_job_factory(job_factory_.get());
}
ProfileIOData::AppRequestContext::~AppRequestContext() {}
ProfileIOData::AppRequestContext::~AppRequestContext() {
AssertNoURLRequests();
}
ProfileIOData::ProfileParams::ProfileParams()
: io_thread(NULL),
......
......@@ -138,7 +138,9 @@ class TestExtensionURLRequestContext : public net::URLRequestContext {
set_cookie_store(cookie_monster);
}
virtual ~TestExtensionURLRequestContext() {}
virtual ~TestExtensionURLRequestContext() {
AssertNoURLRequests();
}
};
class TestExtensionURLRequestContextGetter
......
......@@ -24,6 +24,7 @@ MockBlobURLRequestContext::MockBlobURLRequestContext(
}
MockBlobURLRequestContext::~MockBlobURLRequestContext() {
AssertNoURLRequests();
}
ScopedTextBlob::ScopedTextBlob(
......
......@@ -85,6 +85,7 @@ class RequestContext : public URLRequestContext {
}
virtual ~RequestContext() {
AssertNoURLRequests();
}
private:
......
......@@ -501,6 +501,7 @@ SpdyURLRequestContext::SpdyURLRequestContext(NextProto protocol,
}
SpdyURLRequestContext::~SpdyURLRequestContext() {
AssertNoURLRequests();
}
bool HasSpdySession(SpdySessionPool* pool, const SpdySessionKey& key) {
......
......@@ -199,6 +199,9 @@ class NET_EXPORT URLRequestContext
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;
// Get the underlying |HttpUserAgentSettings| implementation that provides
......
......@@ -165,7 +165,9 @@ class BasicURLRequestContext : public URLRequestContext {
}
protected:
virtual ~BasicURLRequestContext() {}
virtual ~BasicURLRequestContext() {
AssertNoURLRequests();
}
private:
// Threads should be torn down last.
......
......@@ -61,6 +61,7 @@ TestURLRequestContext::TestURLRequestContext(bool delay_initialization)
TestURLRequestContext::~TestURLRequestContext() {
DCHECK(initialized_);
AssertNoURLRequests();
}
void TestURLRequestContext::Init() {
......
......@@ -20,7 +20,10 @@ namespace {
class TestURLRequestContext : public URLRequestContext {
public:
TestURLRequestContext();
virtual ~TestURLRequestContext() {}
virtual ~TestURLRequestContext() {
AssertNoURLRequests();
}
// Gets a pointer to the cache backend.
disk_cache::Backend* GetBackend();
......
......@@ -266,7 +266,9 @@ class MockURLRequestContext : public URLRequestContext {
include_subdomains);
}
virtual ~MockURLRequestContext() {}
virtual ~MockURLRequestContext() {
AssertNoURLRequests();
}
private:
TransportSecurityState transport_security_state_;
......
......@@ -167,6 +167,7 @@ HttpBridge::RequestContext::RequestContext(
}
HttpBridge::RequestContext::~RequestContext() {
AssertNoURLRequests();
DCHECK(network_task_runner_->BelongsToCurrentThread());
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