diff options
| author | Steve Block <steveblock@google.com> | 2010-11-26 09:18:30 -0800 |
|---|---|---|
| committer | Android (Google) Code Review <android-gerrit@google.com> | 2010-11-26 09:18:30 -0800 |
| commit | 4156a8324b9277715bfc3fc0bb5b96c5e3586feb (patch) | |
| tree | afb6ed311ef31a60a84e6605d0d3aec50b8668a2 /WebKit/android | |
| parent | 9435a700986adb48c5d8f6f729e5aae7ea05f8fe (diff) | |
| parent | f4c6cc0f1becf257f68cd2681c3e21584cf7ad02 (diff) | |
| download | external_webkit-4156a8324b9277715bfc3fc0bb5b96c5e3586feb.zip external_webkit-4156a8324b9277715bfc3fc0bb5b96c5e3586feb.tar.gz external_webkit-4156a8324b9277715bfc3fc0bb5b96c5e3586feb.tar.bz2 | |
Merge "Minor code cleanup in WebCookieJar"
Diffstat (limited to 'WebKit/android')
| -rw-r--r-- | WebKit/android/WebCoreSupport/WebCookieJar.cpp | 41 | ||||
| -rw-r--r-- | WebKit/android/WebCoreSupport/WebCookieJar.h | 4 |
2 files changed, 20 insertions, 25 deletions
diff --git a/WebKit/android/WebCoreSupport/WebCookieJar.cpp b/WebKit/android/WebCoreSupport/WebCookieJar.cpp index 8abc3b2..975ce37 100644 --- a/WebKit/android/WebCoreSupport/WebCookieJar.cpp +++ b/WebKit/android/WebCoreSupport/WebCookieJar.cpp @@ -29,19 +29,6 @@ #include "JNIUtility.h" #include "WebCoreJni.h" #include "WebRequestContext.h" -#include "jni.h" - -#include <dirent.h> -#include <sys/stat.h> -#include <sys/types.h> -#include <unistd.h> -#include <wtf/text/CString.h> - -namespace { -static const char* const kCookiesDatabaseFilename = "/webviewCookiesChromium.db"; -static const char* const kCookiesDatabaseFilenamePrivateBrowsing = "/webviewCookiesChromiumPrivate.db"; -WTF::Mutex databaseDirectoryMutex; -} namespace android { @@ -49,6 +36,7 @@ const std::string& databaseDirectory() { // This method may be called on any thread, as the Java method is // synchronized. + static WTF::Mutex databaseDirectoryMutex; MutexLocker lock(databaseDirectoryMutex); static std::string databaseDirectory; if (databaseDirectory.empty()) { @@ -64,29 +52,36 @@ const std::string& databaseDirectory() WebCookieJar* WebCookieJar::get(bool isPrivateBrowsing) { + static const char* const kDatabaseFilename = "/webviewCookiesChromium.db"; + static const char* const kDatabaseFilenamePrivateBrowsing = "/webviewCookiesChromiumPrivate.db"; + static WebCookieJar* regularCookieManager = 0; static WebCookieJar* privateCookieManager = 0; if (isPrivateBrowsing) { - if (!privateCookieManager) - privateCookieManager = new WebCookieJar(true); + if (!privateCookieManager) { + std::string databaseFilePath = databaseDirectory(); + databaseFilePath.append(kDatabaseFilenamePrivateBrowsing); + privateCookieManager = new WebCookieJar(databaseFilePath); + } return privateCookieManager; - } else { - if (!regularCookieManager) - regularCookieManager = new WebCookieJar(false); - return regularCookieManager; } + + if (!regularCookieManager) { + std::string databaseFilePath = databaseDirectory(); + databaseFilePath.append(kDatabaseFilename); + regularCookieManager = new WebCookieJar(databaseFilePath); + } + return regularCookieManager; } -WebCookieJar::WebCookieJar(bool isPrivateBrowsing) +WebCookieJar::WebCookieJar(const std::string& databaseFilePath) : m_allowCookies(true) + , m_databaseFilePath(databaseFilePath) { // This is needed for the page cycler. See http://b/2944150 net::CookieMonster::EnableFileScheme(); - m_databaseFilePath = databaseDirectory(); - m_databaseFilePath.append(isPrivateBrowsing ? kCookiesDatabaseFilenamePrivateBrowsing : kCookiesDatabaseFilename); - FilePath cookiePath(m_databaseFilePath.c_str()); scoped_refptr<SQLitePersistentCookieStore> cookieDb = new SQLitePersistentCookieStore(cookiePath); m_cookieStore = new net::CookieMonster(cookieDb.get(), 0); diff --git a/WebKit/android/WebCoreSupport/WebCookieJar.h b/WebKit/android/WebCoreSupport/WebCookieJar.h index adb923a..661f3b4 100644 --- a/WebKit/android/WebCoreSupport/WebCookieJar.h +++ b/WebKit/android/WebCoreSupport/WebCookieJar.h @@ -34,7 +34,7 @@ namespace android { class WebCookieJar : public net::CookiePolicy { public: - static WebCookieJar* get(bool isPrivate); + static WebCookieJar* get(bool isPrivateBrowsing); // CookiePolicy implementation from external/chromium virtual int CanGetCookies(const GURL& url, const GURL& first_party_for_cookies, net::CompletionCallback*); @@ -50,7 +50,7 @@ public: net::CookiePolicy* cookiePolicy() { return this; } private: - WebCookieJar(bool isPrivate); + WebCookieJar(const std::string& databaseFilePath); scoped_refptr<net::CookieStore> m_cookieStore; bool m_allowCookies; |
