summaryrefslogtreecommitdiffstats
path: root/content/browser
diff options
context:
space:
mode:
authorerikwright@chromium.org <erikwright@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-24 17:08:24 +0000
committererikwright@chromium.org <erikwright@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-24 17:08:24 +0000
commit38ed59bd6246955fd15d7789afba78d5785d90a9 (patch)
treeba30515f9acfcb08db5c9efd21f5259d90bf91ba /content/browser
parent3e18221eff89becd6c4afce6509c62c02b28db21 (diff)
downloadchromium_src-38ed59bd6246955fd15d7789afba78d5785d90a9.zip
chromium_src-38ed59bd6246955fd15d7789afba78d5785d90a9.tar.gz
chromium_src-38ed59bd6246955fd15d7789afba78d5785d90a9.tar.bz2
Fail gracefully if InitializeResourceContext ends up calling itself recursively.
BUG=None TEST=chrome_frame_net_tests don't crash at shutdown (Note, they currently crash at startup or simply don't run without a few other patches applied - this fixes one of the crashes!). Review URL: http://codereview.chromium.org/9443033 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@123492 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/browser')
-rw-r--r--content/browser/browser_context.cc6
-rw-r--r--content/browser/resource_context_impl.cc7
-rw-r--r--content/browser/resource_context_impl.h2
3 files changed, 8 insertions, 7 deletions
diff --git a/content/browser/browser_context.cc b/content/browser/browser_context.cc
index d56e797..cabf7a2 100644
--- a/content/browser/browser_context.cc
+++ b/content/browser/browser_context.cc
@@ -79,7 +79,7 @@ void CreateQuotaManagerAndClients(BrowserContext* context) {
kAppCacheServicKeyName,
new UserDataAdapter<ChromeAppCacheService>(appcache_service));
- InitializeResourceContext(context);
+ EnsureResourceContextInitialized(context);
// Check first to avoid memory leak in unittests.
if (BrowserThread::IsMessageLoopValid(BrowserThread::IO)) {
@@ -125,9 +125,7 @@ FileSystemContext* BrowserContext::GetFileSystemContext(
}
void BrowserContext::EnsureResourceContextInitialized(BrowserContext* context) {
- if (context->GetResourceContext()->GetUserData(kWebKitContextKeyName))
- return;
- InitializeResourceContext(context);
+ content::EnsureResourceContextInitialized(context);
}
BrowserContext::~BrowserContext() {
diff --git a/content/browser/resource_context_impl.cc b/content/browser/resource_context_impl.cc
index 525a10a..8a2adfb3 100644
--- a/content/browser/resource_context_impl.cc
+++ b/content/browser/resource_context_impl.cc
@@ -79,9 +79,12 @@ HostZoomMap* GetHostZoomMapForResourceContext(ResourceContext* context) {
context->GetUserData(kHostZoomMapKeyName))->host_zoom_map();
}
-void InitializeResourceContext(BrowserContext* browser_context) {
+void EnsureResourceContextInitialized(BrowserContext* browser_context) {
ResourceContext* resource_context = browser_context->GetResourceContext();
- DCHECK(!resource_context->GetUserData(kWebKitContextKeyName));
+
+ if (resource_context->GetUserData(kWebKitContextKeyName))
+ return;
+
resource_context->SetUserData(
kWebKitContextKeyName,
new UserDataAdapter<WebKitContext>(
diff --git a/content/browser/resource_context_impl.h b/content/browser/resource_context_impl.h
index 6d914ac..984456a 100644
--- a/content/browser/resource_context_impl.h
+++ b/content/browser/resource_context_impl.h
@@ -31,7 +31,7 @@ ChromeBlobStorageContext* GetChromeBlobStorageContextForResourceContext(
HostZoomMap* GetHostZoomMapForResourceContext(ResourceContext* context);
// Initialize the above data on the ResourceContext from a given BrowserContext.
-void InitializeResourceContext(BrowserContext* browser_context);
+void EnsureResourceContextInitialized(BrowserContext* browser_context);
} // namespace content