diff options
author | Steve Block <steveblock@google.com> | 2011-01-07 07:42:47 -0800 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2011-01-07 07:42:47 -0800 |
commit | c9df0ca67d91d0ea87a1646b5cf6da382ce15109 (patch) | |
tree | ace94c4f1fa4fba5114570a8d0f19bd1cd3082d9 /WebKit/android/WebCoreSupport | |
parent | 9ac7ecaba0b11e8d497f140cbc566efafb88c4dc (diff) | |
parent | 691f420dd0a859196c7dbcd514af42bcc945145c (diff) | |
download | external_webkit-c9df0ca67d91d0ea87a1646b5cf6da382ce15109.zip external_webkit-c9df0ca67d91d0ea87a1646b5cf6da382ce15109.tar.gz external_webkit-c9df0ca67d91d0ea87a1646b5cf6da382ce15109.tar.bz2 |
Merge "Adds an optimization to cache the WebCache backend" into honeycomb
Diffstat (limited to 'WebKit/android/WebCoreSupport')
-rw-r--r-- | WebKit/android/WebCoreSupport/WebCache.cpp | 47 | ||||
-rw-r--r-- | WebKit/android/WebCoreSupport/WebCache.h | 4 |
2 files changed, 25 insertions, 26 deletions
diff --git a/WebKit/android/WebCoreSupport/WebCache.cpp b/WebKit/android/WebCoreSupport/WebCache.cpp index 778d492..c5705dd 100644 --- a/WebKit/android/WebCoreSupport/WebCache.cpp +++ b/WebKit/android/WebCoreSupport/WebCache.cpp @@ -33,18 +33,19 @@ using namespace WTF; using namespace net; +using namespace std; namespace android { static WTF::Mutex instanceMutex; -static const std::string& rootDirectory() +static const string& rootDirectory() { // This method may be called on any thread, as the Java method is // synchronized. static WTF::Mutex mutex; MutexLocker lock(mutex); - static std::string cacheDirectory; + static string cacheDirectory; if (cacheDirectory.empty()) { JNIEnv* env = JSC::Bindings::getJNIEnv(); jclass bridgeClass = env->FindClass("android/webkit/JniUtil"); @@ -55,11 +56,11 @@ static const std::string& rootDirectory() return cacheDirectory; } -static std::string storageDirectory() +static string storageDirectory() { // Private cache is currently in memory only static const char* const kDirectory = "/webviewCacheChromium"; - std::string storageDirectory = rootDirectory(); + string storageDirectory = rootDirectory(); storageDirectory.append(kDirectory); return storageDirectory; } @@ -89,8 +90,9 @@ void WebCache::cleanup(bool isPrivateBrowsing) WebCache::WebCache(bool isPrivateBrowsing) : m_doomAllEntriesCallback(this, &WebCache::doomAllEntries) - , m_doneCallback(this, &WebCache::onClearDone) + , m_onClearDoneCallback(this, &WebCache::onClearDone) , m_isClearInProgress(false) + , m_cacheBackend(0) { base::Thread* ioThread = WebUrlLoaderClient::ioThread(); scoped_refptr<base::MessageLoopProxy> cacheMessageLoopProxy = ioThread->message_loop_proxy(); @@ -119,25 +121,27 @@ WebCache::WebCache(bool isPrivateBrowsing) void WebCache::clear() { - base::Thread* thread = WebUrlLoaderClient::ioThread(); - if (thread) - thread->message_loop()->PostTask(FROM_HERE, NewRunnableMethod(this, &WebCache::doClear)); + base::Thread* thread = WebUrlLoaderClient::ioThread(); + if (thread) + thread->message_loop()->PostTask(FROM_HERE, NewRunnableMethod(this, &WebCache::clearImpl)); } -void WebCache::doClear() +void WebCache::clearImpl() { if (m_isClearInProgress) return; m_isClearInProgress = true; - int code = m_cache->GetBackend(&m_cacheBackend, &m_doomAllEntriesCallback); - // Code ERR_IO_PENDING indicates that the operation is still in progress and - // the supplied callback will be invoked when it completes. - if (code == ERR_IO_PENDING) - return; - else if (code != OK) { - m_isClearInProgress = false; - return; + if (!m_cacheBackend) { + int code = m_cache->GetBackend(&m_cacheBackend, &m_doomAllEntriesCallback); + // Code ERR_IO_PENDING indicates that the operation is still in progress and + // the supplied callback will be invoked when it completes. + if (code == ERR_IO_PENDING) + return; + else if (code != OK) { + onClearDone(0 /*unused*/); + return; + } } doomAllEntries(0 /*unused*/); } @@ -145,19 +149,14 @@ void WebCache::doClear() void WebCache::doomAllEntries(int) { if (!m_cacheBackend) { - m_isClearInProgress = false; + onClearDone(0 /*unused*/); return; } - int code = m_cacheBackend->DoomAllEntries(&m_doneCallback); // Code ERR_IO_PENDING indicates that the operation is still in progress and // the supplied callback will be invoked when it completes. - if (code == ERR_IO_PENDING) - return; - else if (code != OK) { - m_isClearInProgress = false; + if (m_cacheBackend->DoomAllEntries(&m_onClearDoneCallback) == ERR_IO_PENDING) return; - } onClearDone(0 /*unused*/); } diff --git a/WebKit/android/WebCoreSupport/WebCache.h b/WebKit/android/WebCoreSupport/WebCache.h index be6c968..d04a594 100644 --- a/WebKit/android/WebCoreSupport/WebCache.h +++ b/WebKit/android/WebCoreSupport/WebCache.h @@ -49,7 +49,7 @@ private: WebCache(bool isPrivateBrowsing); // For clear() - void doClear(); + void clearImpl(); void doomAllEntries(int); void onClearDone(int); @@ -61,7 +61,7 @@ private: // For clear() net::CompletionCallbackImpl<WebCache> m_doomAllEntriesCallback; - net::CompletionCallbackImpl<WebCache> m_doneCallback; + net::CompletionCallbackImpl<WebCache> m_onClearDoneCallback; disk_cache::Backend* m_cacheBackend; bool m_isClearInProgress; }; |