diff options
author | Kristian Monsen <kristianm@google.com> | 2010-12-10 17:29:31 +0000 |
---|---|---|
committer | Kristian Monsen <kristianm@google.com> | 2010-12-13 14:57:19 +0000 |
commit | c63283dd6a5f037ea20a76d294405a55b5ba0b34 (patch) | |
tree | c21d6cb5986e604e23740f49728a6fd30dbcf9f1 /WebKit/android/WebCoreSupport/WebCache.cpp | |
parent | 5856a5a2cbaa2dc94902d628672a5bd76581903b (diff) | |
download | external_webkit-c63283dd6a5f037ea20a76d294405a55b5ba0b34.zip external_webkit-c63283dd6a5f037ea20a76d294405a55b5ba0b34.tar.gz external_webkit-c63283dd6a5f037ea20a76d294405a55b5ba0b34.tar.bz2 |
Make private browsing cache in-memory
This is better as private browsing data should not be written to
disk if it can be avoided.
Bug 3274225
Change-Id: I5c1832bbe26e58bc7e430ecdaa7cbd0a6ba1c384
Diffstat (limited to 'WebKit/android/WebCoreSupport/WebCache.cpp')
-rw-r--r-- | WebKit/android/WebCoreSupport/WebCache.cpp | 34 |
1 files changed, 14 insertions, 20 deletions
diff --git a/WebKit/android/WebCoreSupport/WebCache.cpp b/WebKit/android/WebCoreSupport/WebCache.cpp index 16ec70f..d606f31 100644 --- a/WebKit/android/WebCoreSupport/WebCache.cpp +++ b/WebKit/android/WebCoreSupport/WebCache.cpp @@ -55,15 +55,12 @@ static const std::string& rootDirectory() return cacheDirectory; } -static std::string storageDirectory(bool isPrivateBrowsing) +static std::string storageDirectory() { - // TODO: Where is the right place to put the db for private browsing? Should - // it be kept in memory? + // Private cache is currently in memory only static const char* const kDirectory = "/webviewCacheChromium"; - static const char* const kDirectoryPrivate = "/webviewCacheChromiumPrivate"; - std::string storageDirectory = rootDirectory(); - storageDirectory.append(isPrivateBrowsing ? kDirectoryPrivate : kDirectory); + storageDirectory.append(kDirectory); return storageDirectory; } @@ -79,7 +76,7 @@ WebCache* WebCache::get(bool isPrivateBrowsing) MutexLocker lock(instanceMutex); scoped_refptr<WebCache>* instancePtr = instance(isPrivateBrowsing); if (!instancePtr->get()) - *instancePtr = new WebCache(storageDirectory(isPrivateBrowsing)); + *instancePtr = new WebCache(isPrivateBrowsing); return instancePtr->get(); } @@ -90,16 +87,7 @@ WebCache::~WebCache() m_hostResolver.leakPtr(); } -void WebCache::cleanup(bool isPrivateBrowsing) -{ - // This is called on the UI thread. - MutexLocker lock(instanceMutex); - scoped_refptr<WebCache>* instancePtr = instance(isPrivateBrowsing); - *instancePtr = 0; - WebRequestContext::removeFileOrDirectory(storageDirectory(isPrivateBrowsing).c_str()); -} - -WebCache::WebCache(const std::string& storageDirectory) +WebCache::WebCache(bool isPrivateBrowsing) : m_doomAllEntriesCallback(this, &WebCache::doomAllEntries) , m_doneCallback(this, &WebCache::onClearDone) , m_isClearInProgress(false) @@ -108,10 +96,16 @@ WebCache::WebCache(const std::string& storageDirectory) scoped_refptr<base::MessageLoopProxy> cacheMessageLoopProxy = ioThread->message_loop_proxy(); static const int kMaximumCacheSizeBytes = 20 * 1024 * 1024; - FilePath directoryPath(storageDirectory.c_str()); - net::HttpCache::DefaultBackend* backendFactory = new net::HttpCache::DefaultBackend(net::DISK_CACHE, directoryPath, kMaximumCacheSizeBytes, cacheMessageLoopProxy); - m_hostResolver = net::CreateSystemHostResolver(net::HostResolver::kDefaultParallelism, 0, 0); + + net::HttpCache::BackendFactory* backendFactory; + if (isPrivateBrowsing) + backendFactory = net::HttpCache::DefaultBackend::InMemory(kMaximumCacheSizeBytes / 2); + else { + FilePath directoryPath(storageDirectory().c_str()); + backendFactory = new net::HttpCache::DefaultBackend(net::DISK_CACHE, directoryPath, kMaximumCacheSizeBytes, cacheMessageLoopProxy); + } + m_cache = new net::HttpCache(m_hostResolver.get(), 0, // dnsrr_resolver net::ProxyService::CreateDirect(), |