summaryrefslogtreecommitdiffstats
path: root/WebKit/android/WebCoreSupport/WebCookieJar.cpp
diff options
context:
space:
mode:
authorSteve Block <steveblock@google.com>2010-11-26 14:31:37 +0000
committerSteve Block <steveblock@google.com>2010-11-26 16:13:12 +0000
commitf4c6cc0f1becf257f68cd2681c3e21584cf7ad02 (patch)
tree8087944d39d7de26a093fc313cb33d3d3a096bb0 /WebKit/android/WebCoreSupport/WebCookieJar.cpp
parent8a5f8b64a112f92833cd718f9b401c996918081b (diff)
downloadexternal_webkit-f4c6cc0f1becf257f68cd2681c3e21584cf7ad02.zip
external_webkit-f4c6cc0f1becf257f68cd2681c3e21584cf7ad02.tar.gz
external_webkit-f4c6cc0f1becf257f68cd2681c3e21584cf7ad02.tar.bz2
Minor code cleanup in WebCookieJar
Change-Id: Ia68bac6bd93b0afeff049a9ac0f056191d92d2a0
Diffstat (limited to 'WebKit/android/WebCoreSupport/WebCookieJar.cpp')
-rw-r--r--WebKit/android/WebCoreSupport/WebCookieJar.cpp41
1 files changed, 18 insertions, 23 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);