summaryrefslogtreecommitdiffstats
path: root/content/browser/browser_context.cc
diff options
context:
space:
mode:
authorjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-24 18:10:36 +0000
committerjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-24 18:10:36 +0000
commit6e2d3d229024a3a0038c8a5c169bfd948a5c4939 (patch)
treeb9f37d0c4fc5758e2c0d4b4c407c3059ca59dd68 /content/browser/browser_context.cc
parentaee7b0822009cda31b7aea2922263a0b5adc6c9a (diff)
downloadchromium_src-6e2d3d229024a3a0038c8a5c169bfd948a5c4939.zip
chromium_src-6e2d3d229024a3a0038c8a5c169bfd948a5c4939.tar.gz
chromium_src-6e2d3d229024a3a0038c8a5c169bfd948a5c4939.tar.bz2
Remove usage of WebKitContext from chrome. This also cleans up the chrome code so that it only calls profile-wide operations (i.e. saving session/purging memory/clearing local state on exit) on the BrowserContext. The content layer takes care of calling the necessary objects on the right thread.
WebKitContext now does almost nothing and I'll remove it completely in the next change. BUG=98716 Review URL: https://chromiumcodereview.appspot.com/9462007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@123509 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/browser/browser_context.cc')
-rw-r--r--content/browser/browser_context.cc90
1 files changed, 89 insertions, 1 deletions
diff --git a/content/browser/browser_context.cc b/content/browser/browser_context.cc
index cabf7a2..4bfc9e7 100644
--- a/content/browser/browser_context.cc
+++ b/content/browser/browser_context.cc
@@ -6,10 +6,15 @@
#include "content/browser/appcache/chrome_appcache_service.h"
#include "content/browser/file_system/browser_file_system_helper.h"
+#include "content/browser/in_process_webkit/dom_storage_context_impl.h"
+#include "content/browser/in_process_webkit/indexed_db_context_impl.h"
#include "content/browser/in_process_webkit/webkit_context.h"
#include "content/browser/resource_context_impl.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/common/content_constants.h"
+#include "net/base/cookie_monster.h"
+#include "net/base/cookie_store.h"
+#include "net/url_request/url_request_context.h"
#include "webkit/database/database_tracker.h"
#include "webkit/quota/quota_manager.h"
@@ -67,7 +72,7 @@ void CreateQuotaManagerAndClients(BrowserContext* context) {
scoped_refptr<WebKitContext> webkit_context = new WebKitContext(
context->IsOffTheRecord(), context->GetPath(),
- context->GetSpecialStoragePolicy(), false, quota_manager->proxy(),
+ context->GetSpecialStoragePolicy(), quota_manager->proxy(),
BrowserThread::GetMessageLoopProxyForThread(
BrowserThread::WEBKIT_DEPRECATED));
context->SetUserData(kWebKitContextKeyName,
@@ -94,6 +99,29 @@ void CreateQuotaManagerAndClients(BrowserContext* context) {
}
}
+void SaveSessionStateOnIOThread(ResourceContext* resource_context) {
+ resource_context->GetRequestContext()->cookie_store()->GetCookieMonster()->
+ SaveSessionCookies();
+ ResourceContext::GetAppCacheService(resource_context)->set_save_session_state(
+ true);
+}
+
+void SaveSessionStateOnWebkitThread(
+ scoped_refptr<DOMStorageContextImpl> dom_storage_context,
+ scoped_refptr<IndexedDBContextImpl> indexed_db_context) {
+ dom_storage_context->SaveSessionState();
+ indexed_db_context->SaveSessionState();
+}
+
+void PurgeMemoryOnIOThread(ResourceContext* resource_context) {
+ ResourceContext::GetAppCacheService(resource_context)->PurgeMemory();
+}
+
+void PurgeMemoryOnWebkitThread(
+ scoped_refptr<DOMStorageContextImpl> dom_storage_context) {
+ dom_storage_context->PurgeMemory();
+}
+
QuotaManager* BrowserContext::GetQuotaManager(BrowserContext* context) {
CreateQuotaManagerAndClients(context);
return UserDataAdapter<QuotaManager>::Get(context, kQuotaManagerKeyName);
@@ -128,6 +156,66 @@ void BrowserContext::EnsureResourceContextInitialized(BrowserContext* context) {
content::EnsureResourceContextInitialized(context);
}
+void BrowserContext::SaveSessionState(BrowserContext* browser_context) {
+ GetDatabaseTracker(browser_context)->SaveSessionState();
+
+ if (BrowserThread::IsMessageLoopValid(BrowserThread::IO)) {
+ BrowserThread::PostTask(
+ BrowserThread::IO, FROM_HERE,
+ base::Bind(&SaveSessionStateOnIOThread,
+ browser_context->GetResourceContext()));
+ }
+
+ if (BrowserThread::IsMessageLoopValid(BrowserThread::WEBKIT_DEPRECATED)) {
+ DOMStorageContextImpl* dom_context = static_cast<DOMStorageContextImpl*>(
+ DOMStorageContextImpl::GetForBrowserContext(browser_context));
+ IndexedDBContextImpl* indexed_db = static_cast<IndexedDBContextImpl*>(
+ IndexedDBContext::GetForBrowserContext(browser_context));
+ BrowserThread::PostTask(
+ BrowserThread::WEBKIT_DEPRECATED, FROM_HERE,
+ base::Bind(&SaveSessionStateOnWebkitThread,
+ make_scoped_refptr(dom_context),
+ make_scoped_refptr(indexed_db)));
+ }
+}
+
+void BrowserContext::ClearLocalOnDestruction(BrowserContext* browser_context) {
+ DOMStorageContextImpl* dom_context = static_cast<DOMStorageContextImpl*>(
+ DOMStorageContextImpl::GetForBrowserContext(browser_context));
+ dom_context->set_clear_local_state_on_exit(true);
+
+ IndexedDBContextImpl* indexed_db = static_cast<IndexedDBContextImpl*>(
+ IndexedDBContext::GetForBrowserContext(browser_context));
+ indexed_db->set_clear_local_state_on_exit(true);
+
+ GetDatabaseTracker(browser_context)->SetClearLocalStateOnExit(true);
+
+ if (BrowserThread::IsMessageLoopValid(BrowserThread::IO)) {
+ BrowserThread::PostTask(
+ BrowserThread::IO, FROM_HERE,
+ base::Bind(&appcache::AppCacheService::set_clear_local_state_on_exit,
+ base::Unretained(GetAppCacheService(browser_context)), true));
+ }
+}
+
+void BrowserContext::PurgeMemory(BrowserContext* browser_context) {
+ if (BrowserThread::IsMessageLoopValid(BrowserThread::IO)) {
+ BrowserThread::PostTask(
+ BrowserThread::IO, FROM_HERE,
+ base::Bind(&PurgeMemoryOnIOThread,
+ browser_context->GetResourceContext()));
+ }
+
+ if (BrowserThread::IsMessageLoopValid(BrowserThread::WEBKIT_DEPRECATED)) {
+ DOMStorageContextImpl* dom_context = static_cast<DOMStorageContextImpl*>(
+ DOMStorageContextImpl::GetForBrowserContext(browser_context));
+ BrowserThread::PostTask(
+ BrowserThread::WEBKIT_DEPRECATED, FROM_HERE,
+ base::Bind(&PurgeMemoryOnWebkitThread,
+ make_scoped_refptr(dom_context)));
+ }
+}
+
BrowserContext::~BrowserContext() {
if (GetUserData(kDatabaseTrackerKeyName) &&
BrowserThread::IsMessageLoopValid(BrowserThread::FILE)) {