diff options
author | Kristian Monsen <kristianm@google.com> | 2010-07-14 16:08:30 +0100 |
---|---|---|
committer | Kristian Monsen <kristianm@google.com> | 2010-07-20 11:19:54 +0100 |
commit | f43eabc081f7ce6af24b9df4953498a3cd6ca24d (patch) | |
tree | 7727b8cbf7e5b2b366f7c2807ed52d22fc1b2812 | |
parent | 459cc6ac10bd670746ba34168f88fe1050e5ad52 (diff) | |
download | external_webkit-f43eabc081f7ce6af24b9df4953498a3cd6ca24d.zip external_webkit-f43eabc081f7ce6af24b9df4953498a3cd6ca24d.tar.gz external_webkit-f43eabc081f7ce6af24b9df4953498a3cd6ca24d.tar.bz2 |
Chrome http: Persistent cookies and cache.
Sharing one RequestContex. Adding a persistent cookie store and on disk cache to that request.
Change-Id: I7f45cda3803340672585e5b0f84eb0d5e2fd6b75
-rw-r--r-- | Android.mk | 3 | ||||
-rw-r--r-- | WebKit/android/WebCoreSupport/WebRequestContext.cpp | 30 | ||||
-rw-r--r-- | WebKit/android/WebCoreSupport/WebRequestContext.h | 3 |
3 files changed, 20 insertions, 16 deletions
@@ -242,7 +242,8 @@ WEBKIT_SRC_FILES += $(addprefix $d/,$(LOCAL_SRC_FILES)) ifeq ($(HTTP_STACK),chrome) LOCAL_C_INCLUDES := $(LOCAL_C_INCLUDES) \ $(LOCAL_PATH)/WebKit/chromium/public \ - external/chromium + external/chromium \ + external/chromium/android endif # HTTP_STACK == chrome # Redefine LOCAL_PATH here so the build system is not confused diff --git a/WebKit/android/WebCoreSupport/WebRequestContext.cpp b/WebKit/android/WebCoreSupport/WebRequestContext.cpp index ecd083b..2adbbf9 100644 --- a/WebKit/android/WebCoreSupport/WebRequestContext.cpp +++ b/WebKit/android/WebCoreSupport/WebRequestContext.cpp @@ -28,6 +28,7 @@ #include "WebRequestContext.h" #include "JNIUtility.h" +#include "app/sqlite_persistent_cookie_store.h" #include "jni.h" #include "net/base/cookie_monster.h" #include "net/base/ssl_config_service.h" @@ -41,8 +42,7 @@ namespace { namespace android { -std::string* WebRequestContext::s_dataDirectory = 0; -net::HttpCache* WebRequestContext::s_cache = 0; +std::string* WebRequestContext::s_dataDirectory(0); WebRequestContext::WebRequestContext() { @@ -75,18 +75,24 @@ const std::string* WebRequestContext::GetDataDirectory() return s_dataDirectory; } -// Some of the members of the RequestContext will be deleted when the URLRequest -// is deleted as they are scoped pointers. Documented in WebRequestContext.h WebRequestContext* WebRequestContext::GetAndroidContext() { - WebRequestContext* androidContext = new WebRequestContext(); - androidContext->host_resolver_ = net::CreateSystemHostResolver(0); - androidContext->cookie_store_ = new net::CookieMonster(0); - - // In memory cache - if (!s_cache) - s_cache = new net::HttpCache(0, androidContext->host_resolver(), 0, net::SSLConfigService::CreateSystemSSLConfigService(), 0); - androidContext->http_transaction_factory_ = s_cache; + static scoped_refptr<WebRequestContext> androidContext(0); + if (!androidContext) { + std::string cookieString(*GetDataDirectory()); + cookieString.append("/chromecookies.db"); + FilePath cookiePath(cookieString.c_str()); + std::string cacheString(*GetDataDirectory()); + cacheString.append("/chromecache"); + FilePath cachePath(cacheString.c_str()); + + androidContext = new WebRequestContext(); + androidContext->host_resolver_ = net::CreateSystemHostResolver(0); + androidContext->http_transaction_factory_ = new net::HttpCache(0, androidContext->host_resolver(), 0, net::SSLConfigService::CreateSystemSSLConfigService(), cachePath, 0); + + scoped_refptr<SQLitePersistentCookieStore> cookieDb = new SQLitePersistentCookieStore(cookiePath); + androidContext->cookie_store_ = new net::CookieMonster(cookieDb.get()); + } return androidContext; } diff --git a/WebKit/android/WebCoreSupport/WebRequestContext.h b/WebKit/android/WebCoreSupport/WebRequestContext.h index 65a0865..c2f0aaf 100644 --- a/WebKit/android/WebCoreSupport/WebRequestContext.h +++ b/WebKit/android/WebCoreSupport/WebRequestContext.h @@ -42,9 +42,6 @@ private: // Caching this query from java static std::string* s_dataDirectory; - - // Not deleted on deletion of URLRequest - static net::HttpCache* s_cache; }; } // namespace android |