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

Unified Diff: chrome/test/base/testing_profile.cc

Issue 17127002: Correctly integrate StoragePartition into TestingProfile. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address comments. merge to ToT. Murder a DB thread and more TestBrowserThreads. Created 7 years, 5 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/test/base/testing_profile.cc
diff --git a/chrome/test/base/testing_profile.cc b/chrome/test/base/testing_profile.cc
index c08433ef09a32021a1faf127f01f91a3bf1cbc6a..f47e512d5d5b41ce867fb60783f6bf29eeaae0ff 100644
--- a/chrome/test/base/testing_profile.cc
+++ b/chrome/test/base/testing_profile.cc
@@ -173,6 +173,7 @@ TestingProfile::TestingProfile()
last_session_exited_cleanly_(true),
browser_context_dependency_manager_(
BrowserContextDependencyManager::GetInstance()),
+ resource_context_(NULL),
delegate_(NULL) {
CreateTempProfileDir();
profile_path_ = temp_dir_.path();
@@ -190,6 +191,7 @@ TestingProfile::TestingProfile(const base::FilePath& path)
profile_path_(path),
browser_context_dependency_manager_(
BrowserContextDependencyManager::GetInstance()),
+ resource_context_(NULL),
delegate_(NULL) {
Init();
FinishInit();
@@ -205,6 +207,7 @@ TestingProfile::TestingProfile(const base::FilePath& path,
profile_path_(path),
browser_context_dependency_manager_(
BrowserContextDependencyManager::GetInstance()),
+ resource_context_(NULL),
delegate_(delegate) {
Init();
if (delegate_) {
@@ -231,6 +234,7 @@ TestingProfile::TestingProfile(
profile_path_(path),
browser_context_dependency_manager_(
BrowserContextDependencyManager::GetInstance()),
+ resource_context_(NULL),
delegate_(delegate) {
// If no profile path was supplied, create one.
@@ -323,6 +327,9 @@ void TestingProfile::FinishInit() {
}
TestingProfile::~TestingProfile() {
+ // Any objects holding live URLFetchers should be deleted before teardown.
+ TemplateURLFetcherFactory::ShutdownForProfile(this);
+
MaybeSendDestroyedNotification();
browser_context_dependency_manager_->DestroyBrowserContextServices(this);
@@ -334,6 +341,14 @@ TestingProfile::~TestingProfile() {
if (pref_proxy_config_tracker_.get())
pref_proxy_config_tracker_->DetachFromPrefService();
+ // Failing a post == leaks == heapcheck failure. Make that an immediate test
+ // failure.
+ if (resource_context_) {
+ CHECK(BrowserThread::DeleteSoon(BrowserThread::IO, FROM_HERE,
+ resource_context_));
+ resource_context_ = NULL;
+ content::RunAllPendingInMessageLoop(BrowserThread::IO);
+ }
}
static BrowserContextKeyedService* BuildFaviconService(
@@ -599,12 +614,13 @@ DownloadManagerDelegate* TestingProfile::GetDownloadManagerDelegate() {
}
net::URLRequestContextGetter* TestingProfile::GetRequestContext() {
- return request_context_.get();
+ return GetDefaultStoragePartition(this)->GetURLRequestContext();
}
net::URLRequestContextGetter* TestingProfile::CreateRequestContext(
content::ProtocolHandlerMap* protocol_handlers) {
- return request_context_.get();
+ return new net::TestURLRequestContextGetter(
+ BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO));
}
net::URLRequestContextGetter* TestingProfile::GetRequestContextForRenderProcess(
@@ -614,20 +630,6 @@ net::URLRequestContextGetter* TestingProfile::GetRequestContextForRenderProcess(
return rph->GetStoragePartition()->GetURLRequestContext();
}
-void TestingProfile::CreateRequestContext() {
- if (!request_context_.get())
- request_context_ = new net::TestURLRequestContextGetter(
- BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO));
-}
-
-void TestingProfile::ResetRequestContext() {
- // Any objects holding live URLFetchers should be deleted before the request
- // context is shut down.
- TemplateURLFetcherFactory::ShutdownForProfile(this);
-
- request_context_ = NULL;
-}
-
net::URLRequestContextGetter* TestingProfile::GetMediaRequestContext() {
return NULL;
}
@@ -668,9 +670,9 @@ TestingProfile::CreateRequestContextForStoragePartition(
}
content::ResourceContext* TestingProfile::GetResourceContext() {
- if (!resource_context_.get())
- resource_context_.reset(new content::MockResourceContext());
- return resource_context_.get();
+ if (!resource_context_)
+ resource_context_ = new content::MockResourceContext();
+ return resource_context_;
}
HostContentSettingsMap* TestingProfile::GetHostContentSettingsMap() {

Powered by Google App Engine
This is Rietveld 408576698