diff options
author | Steve Block <steveblock@google.com> | 2011-05-24 10:19:30 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2011-05-24 10:19:30 -0700 |
commit | 7ea198c3fc3833a4e36ada065dcd4ed47a50b030 (patch) | |
tree | c566ab9f20be8d17c054d4d708b9fe1f9b2e9423 | |
parent | 99231f8e5c2dfae0faab1efc56462f750832f3c8 (diff) | |
parent | 63da3f053ab8a3590e4dcd4a51056cb2d277a7d8 (diff) | |
download | external_webkit-7ea198c3fc3833a4e36ada065dcd4ed47a50b030.zip external_webkit-7ea198c3fc3833a4e36ada065dcd4ed47a50b030.tar.gz external_webkit-7ea198c3fc3833a4e36ada065dcd4ed47a50b030.tar.bz2 |
Merge "Use the correct type for the new quota for HTML5 Database and AppCache"
-rw-r--r-- | Source/WebKit/android/WebCoreSupport/ChromeClientAndroid.cpp | 27 | ||||
-rw-r--r-- | Source/WebKit/android/WebCoreSupport/ChromeClientAndroid.h | 5 |
2 files changed, 17 insertions, 15 deletions
diff --git a/Source/WebKit/android/WebCoreSupport/ChromeClientAndroid.cpp b/Source/WebKit/android/WebCoreSupport/ChromeClientAndroid.cpp index 24eb945..c3732e7 100644 --- a/Source/WebKit/android/WebCoreSupport/ChromeClientAndroid.cpp +++ b/Source/WebKit/android/WebCoreSupport/ChromeClientAndroid.cpp @@ -361,8 +361,7 @@ void ChromeClientAndroid::exceededDatabaseQuota(Frame* frame, const String& name SecurityOrigin* origin = frame->document()->securityOrigin(); DatabaseTracker& tracker = WebCore::DatabaseTracker::tracker(); - // We want to wait on a new quota from the UI thread. Reset the m_newQuota variable to represent we haven't received a new quota. - m_newQuota = -1; + m_isNewQuotaSet = false; // This origin is being tracked and has exceeded it's quota. Call into // the Java side of things to inform the user. @@ -380,15 +379,19 @@ void ChromeClientAndroid::exceededDatabaseQuota(Frame* frame, const String& name // We've sent notification to the browser so now wait for it to come back. m_quotaThreadLock.lock(); - while (m_newQuota == -1) { + while (!m_isNewQuotaSet) { m_quotaThreadCondition.wait(m_quotaThreadLock); } m_quotaThreadLock.unlock(); - // If new quota is unavailable, we may be able to resolve the situation by shrinking the quota of an origin that asked for a lot but is only using a little. - // If we find such a site, shrink it's quota and ask Java to try again. + if (m_newQuota < currentQuota) + m_newQuota = currentQuota; - if ((unsigned long long) m_newQuota == currentQuota && !m_triedToReclaimDBQuota) { + // If new quota is unavailable, we may be able to resolve the situation by + // shrinking the quota of an origin that asked for a lot but is only using a + // little. If we find such a site, shrink it's quota and ask Java to try + // again. + if (m_newQuota == currentQuota && !m_triedToReclaimDBQuota) { m_triedToReclaimDBQuota = true; // we should only try this once per quota overflow. unsigned long long reclaimedQuotaBytes = tryToReclaimDatabaseQuota(origin); @@ -435,10 +438,7 @@ static unsigned long long tryToReclaimDatabaseQuota(SecurityOrigin* originNeedin #if ENABLE(OFFLINE_WEB_APPLICATIONS) void ChromeClientAndroid::reachedMaxAppCacheSize(int64_t spaceNeeded) { - // Set m_newQuota before calling into the Java side. If we do this after, - // we could overwrite the result passed from the Java side and deadlock in the - // wait call below. - m_newQuota = -1; + m_isNewQuotaSet = false; Page* page = m_webFrame->page(); Frame* mainFrame = page->mainFrame(); FrameView* view = mainFrame->view(); @@ -446,7 +446,7 @@ void ChromeClientAndroid::reachedMaxAppCacheSize(int64_t spaceNeeded) // We've sent notification to the browser so now wait for it to come back. m_quotaThreadLock.lock(); - while (m_newQuota == -1) { + while (!m_isNewQuotaSet) { m_quotaThreadCondition.wait(m_quotaThreadLock); } m_quotaThreadLock.unlock(); @@ -516,9 +516,10 @@ void ChromeClientAndroid::setCursor(const Cursor&) notImplemented(); } -void ChromeClientAndroid::wakeUpMainThreadWithNewQuota(long newQuota) { +void ChromeClientAndroid::wakeUpMainThreadWithNewQuota(long long newQuota) { MutexLocker locker(m_quotaThreadLock); - m_newQuota = newQuota; + m_newQuota = newQuota < 0 ? 0 : newQuota; + m_isNewQuotaSet = true; m_quotaThreadCondition.signal(); } diff --git a/Source/WebKit/android/WebCoreSupport/ChromeClientAndroid.h b/Source/WebKit/android/WebCoreSupport/ChromeClientAndroid.h index d49cec8..81b3d49 100644 --- a/Source/WebKit/android/WebCoreSupport/ChromeClientAndroid.h +++ b/Source/WebKit/android/WebCoreSupport/ChromeClientAndroid.h @@ -165,7 +165,7 @@ namespace android { // Android-specific void setWebFrame(android::WebFrame* webframe); android::WebFrame* webFrame() { return m_webFrame; } - void wakeUpMainThreadWithNewQuota(long newQuota); + void wakeUpMainThreadWithNewQuota(long long newQuota); #if USE(ACCELERATED_COMPOSITING) virtual void attachRootGraphicsLayer(WebCore::Frame*, WebCore::GraphicsLayer* g); @@ -207,7 +207,8 @@ namespace android { #endif WTF::ThreadCondition m_quotaThreadCondition; WTF::Mutex m_quotaThreadLock; - long m_newQuota; + unsigned long long m_newQuota; + bool m_isNewQuotaSet; bool m_triedToReclaimDBQuota; }; |