diff options
-rw-r--r-- | WebKit/android/WebCoreSupport/WebRequestContext.cpp | 3 | ||||
-rw-r--r-- | WebKit/android/WebCoreSupport/WebRequestContext.h | 3 | ||||
-rw-r--r-- | WebKit/android/jni/CookieManager.cpp | 10 |
3 files changed, 16 insertions, 0 deletions
diff --git a/WebKit/android/WebCoreSupport/WebRequestContext.cpp b/WebKit/android/WebCoreSupport/WebRequestContext.cpp index 87b6893..5484979 100644 --- a/WebKit/android/WebCoreSupport/WebRequestContext.cpp +++ b/WebKit/android/WebCoreSupport/WebRequestContext.cpp @@ -171,7 +171,10 @@ WebRequestContext* WebRequestContext::getContextForPath(const char* cookieFilena WebRequestContext* WebRequestContext::getRegularContext() { + static WTF::Mutex regularContextMutex; static scoped_refptr<WebRequestContext> regularContext(0); + + MutexLocker lock(regularContextMutex); if (!regularContext) regularContext = getContextForPath(kCookiesDatabaseFilename, kCacheDirectory); return regularContext; diff --git a/WebKit/android/WebCoreSupport/WebRequestContext.h b/WebKit/android/WebCoreSupport/WebRequestContext.h index 3f5631f..788998e 100644 --- a/WebKit/android/WebCoreSupport/WebRequestContext.h +++ b/WebKit/android/WebCoreSupport/WebRequestContext.h @@ -38,6 +38,9 @@ public: virtual const std::string& GetAcceptLanguage() const; // Lazily create the relevant context. This class holds a reference. + // This may be called on any thread. The context returned, however, is not + // threadsafe, and should only be used on a single thread (the network stack + // IO thread), with the exception of the methods below. static WebRequestContext* get(bool isPrivateBrowsing); // These methods are threadsafe. diff --git a/WebKit/android/jni/CookieManager.cpp b/WebKit/android/jni/CookieManager.cpp index f16ffd7..34e2cb6 100644 --- a/WebKit/android/jni/CookieManager.cpp +++ b/WebKit/android/jni/CookieManager.cpp @@ -46,6 +46,16 @@ static bool useChromiumHttpStack(JNIEnv*, jobject) { static void removeAllCookie(JNIEnv*, jobject) { #if USE(CHROME_NETWORK_STACK) + // Though WebRequestContext::get() is threadsafe, the context itself, in + // general, is not. The context is generally used on the HTTP stack IO + // thread, but this call is on the UI thread. However, the cookie_store() + // getter just returns a pointer which is only set when the context is first + // constructed. The CookieMonster is threadsafe, so the call below is safe + // overall. + // + // TODO: It's possible that this call is made before the WebKit thread has + // started up and the settings have been synced to the BrowserFrame. This + // will cause creation of the context to fail. WebRequestContext::get(false)->cookie_store()->GetCookieMonster()->DeleteAllCreatedAfter(Time(), true); // This will lazily create a new private browsing context. However, if the // context doesn't already exist, there's no need to create it, as cookies |