Diff
Modified: trunk/Source/WebCore/ChangeLog (87000 => 87001)
--- trunk/Source/WebCore/ChangeLog 2011-05-20 23:38:11 UTC (rev 87000)
+++ trunk/Source/WebCore/ChangeLog 2011-05-20 23:48:46 UTC (rev 87001)
@@ -1,3 +1,21 @@
+2011-05-20 Michael Nordman <[email protected]>
+
+ Reviewed by Darin Fisher.
+
+ [Chromium] Support the new webkit apis so the WebDatabase system participates
+ in the unified quota management system.
+ https://bugs.webkit.org/show_bug.cgi?id=60985
+
+ No change in functionality, no new tests.
+
+ * platform/chromium/PlatformBridge.h:
+ * storage/chromium/QuotaTracker.cpp:
+ (WebCore::QuotaTracker::getDatabaseSizeAndSpaceAvailableToOrigin):
+ (WebCore::QuotaTracker::updateDatabaseSize):
+ (WebCore::QuotaTracker::updateSpaceAvailableToOrigin):
+ (WebCore::QuotaTracker::resetSpaceAvailableToOrigin):
+ * storage/chromium/QuotaTracker.h:
+
2011-05-20 Andy Estes <[email protected]>
Reviewed by Darin Adler.
Modified: trunk/Source/WebCore/platform/chromium/PlatformBridge.h (87000 => 87001)
--- trunk/Source/WebCore/platform/chromium/PlatformBridge.h 2011-05-20 23:38:11 UTC (rev 87000)
+++ trunk/Source/WebCore/platform/chromium/PlatformBridge.h 2011-05-20 23:48:46 UTC (rev 87001)
@@ -168,6 +168,8 @@
static long databaseGetFileAttributes(const String& vfsFileName);
// Returns the size of the DB file
static long long databaseGetFileSize(const String& vfsFileName);
+ // Returns the space available for the origin
+ static long long databaseGetSpaceAvailableForOrigin(const String& originIdentifier);
// IndexedDB ----------------------------------------------------------
static PassRefPtr<IDBFactoryBackendInterface> idbFactory();
Modified: trunk/Source/WebCore/storage/chromium/QuotaTracker.cpp (87000 => 87001)
--- trunk/Source/WebCore/storage/chromium/QuotaTracker.cpp 2011-05-20 23:38:11 UTC (rev 87000)
+++ trunk/Source/WebCore/storage/chromium/QuotaTracker.cpp 2011-05-20 23:48:46 UTC (rev 87001)
@@ -30,6 +30,7 @@
#include "config.h"
#include "QuotaTracker.h"
+#include "PlatformBridge.h"
#if ENABLE(DATABASE)
@@ -47,26 +48,45 @@
const String& originIdentifier, const String& databaseName,
unsigned long long* databaseSize, unsigned long long* spaceAvailable)
{
- MutexLocker lockData(m_dataGuard);
- ASSERT(m_databaseSizes.contains(originIdentifier));
- HashMap<String, SizeMap>::const_iterator it = m_databaseSizes.find(originIdentifier);
- ASSERT(it->second.contains(databaseName));
- *databaseSize = it->second.get(databaseName);
+ // Extra scope to unlock prior to potentially calling PlatformBridge.
+ {
+ MutexLocker lockData(m_dataGuard);
+ ASSERT(m_databaseSizes.contains(originIdentifier));
+ HashMap<String, SizeMap>::const_iterator it = m_databaseSizes.find(originIdentifier);
+ ASSERT(it->second.contains(databaseName));
+ *databaseSize = it->second.get(databaseName);
- ASSERT(m_spaceAvailableToOrigins.contains(originIdentifier));
- *spaceAvailable = m_spaceAvailableToOrigins.get(originIdentifier);
+ if (m_spaceAvailableToOrigins.contains(originIdentifier)) {
+ *spaceAvailable = m_spaceAvailableToOrigins.get(originIdentifier);
+ return;
+ }
+ }
+
+ // The embedder hasn't pushed this value to us, so we pull it as needed.
+ *spaceAvailable = PlatformBridge::databaseGetSpaceAvailableForOrigin(originIdentifier);
}
-void QuotaTracker::updateDatabaseSizeAndSpaceAvailableToOrigin(
+void QuotaTracker::updateDatabaseSize(
const String& originIdentifier, const String& databaseName,
- unsigned long long databaseSize, unsigned long long spaceAvailable)
+ unsigned long long databaseSize)
{
MutexLocker lockData(m_dataGuard);
- m_spaceAvailableToOrigins.set(originIdentifier, spaceAvailable);
HashMap<String, SizeMap>::iterator it = m_databaseSizes.add(originIdentifier, SizeMap()).first;
it->second.set(databaseName, databaseSize);
}
+void QuotaTracker::updateSpaceAvailableToOrigin(const String& originIdentifier, unsigned long long spaceAvailable)
+{
+ MutexLocker lockData(m_dataGuard);
+ m_spaceAvailableToOrigins.set(originIdentifier, spaceAvailable);
}
+void QuotaTracker::resetSpaceAvailableToOrigin(const String& originIdentifier)
+{
+ MutexLocker lockData(m_dataGuard);
+ m_spaceAvailableToOrigins.remove(originIdentifier);
+}
+
+} // namespace WebCore
+
#endif // ENABLE(DATABASE)
Modified: trunk/Source/WebCore/storage/chromium/QuotaTracker.h (87000 => 87001)
--- trunk/Source/WebCore/storage/chromium/QuotaTracker.h 2011-05-20 23:38:11 UTC (rev 87000)
+++ trunk/Source/WebCore/storage/chromium/QuotaTracker.h 2011-05-20 23:48:46 UTC (rev 87001)
@@ -47,9 +47,11 @@
void getDatabaseSizeAndSpaceAvailableToOrigin(
const String& originIdentifier, const String& databaseName,
unsigned long long* databaseSize, unsigned long long* spaceAvailable);
- void updateDatabaseSizeAndSpaceAvailableToOrigin(
+ void updateDatabaseSize(
const String& originIdentifier, const String& databaseName,
- unsigned long long databaseSize, unsigned long long spaceAvailable);
+ unsigned long long databaseSize);
+ void updateSpaceAvailableToOrigin(const String& originIdentifier, unsigned long long spaceAvailable);
+ void resetSpaceAvailableToOrigin(const String& originIdentifier);
private:
QuotaTracker() { }
Modified: trunk/Source/WebKit/chromium/ChangeLog (87000 => 87001)
--- trunk/Source/WebKit/chromium/ChangeLog 2011-05-20 23:38:11 UTC (rev 87000)
+++ trunk/Source/WebKit/chromium/ChangeLog 2011-05-20 23:48:46 UTC (rev 87001)
@@ -1,3 +1,35 @@
+2011-05-20 Michael Nordman <[email protected]>
+
+ Reviewed by Darin Fisher.
+
+ Changes to allow the WebDatabase system to participate in Chrome's unified quota
+ management system. Now that changes outside of the database system affect the space
+ available to the database system, we need new ways of getting the limit to renderers.
+
+ Split WebDatabase::updateDatabaseSizeAndSpaceAvailable() into three methods.
+ - WebDatabase::updateDatababaseSize()
+ - WebDatabase::updateSpaceAvailable()
+ - WebDatabase::resetSpaceAvailable()
+ The WebDatabase methods are used to 'push' size and space available info into renderers.
+ The space available can change independently of a database having changed size.
+
+ Also provide a means for the renderer to 'pull' the space available from the main
+ process if that value has not been pushed into it.
+ - WebCore::PlatformBridge::databaseGetSpaceAvailableForOrigin()
+ - WebKit::WebKitClient::databaseGetSpaceAvailableForOrigin()
+
+ https://bugs.webkit.org/show_bug.cgi?id=60985
+
+ * public/WebDatabase.h:
+ * public/WebKitClient.h:
+ (WebKit::WebKitClient::databaseGetSpaceAvailableForOrigin):
+ * src/PlatformBridge.cpp:
+ (WebCore::PlatformBridge::databaseGetSpaceAvailableForOrigin):
+ * src/WebDatabase.cpp:
+ (WebKit::WebDatabase::updateDatabaseSize):
+ (WebKit::WebDatabase::updateSpaceAvailable):
+ (WebKit::WebDatabase::resetSpaceAvailable):
+
2011-05-20 Simon Fraser <[email protected]>
Reviewed by Sam Weinig.
Modified: trunk/Source/WebKit/chromium/public/WebDatabase.h (87000 => 87001)
--- trunk/Source/WebKit/chromium/public/WebDatabase.h 2011-05-20 23:38:11 UTC (rev 87000)
+++ trunk/Source/WebKit/chromium/public/WebDatabase.h 2011-05-20 23:48:46 UTC (rev 87001)
@@ -52,11 +52,20 @@
WEBKIT_API static WebDatabaseObserver* observer();
WEBKIT_API static void updateDatabaseSize(
- const WebString& originIdentifier, const WebString& databaseName,
- unsigned long long databaseSize, unsigned long long spaceAvailable);
+ const WebString& originIdentifier, const WebString& name, long long size);
+ WEBKIT_API static void updateSpaceAvailable(
+ const WebString& originIdentifier, long long spaceAvailable);
+ WEBKIT_API static void resetSpaceAvailable(
+ const WebString& originIdentifier);
+
WEBKIT_API static void closeDatabaseImmediately(
const WebString& originIdentifier, const WebString& databaseName);
+ // DEPRECATED - to be removed soon
+ WEBKIT_API static void updateDatabaseSize(
+ const WebString& originIdentifier, const WebString& databaseName,
+ long long databaseSize, long long spaceAvailable);
+
#if WEBKIT_IMPLEMENTATION
WebDatabase(const WebCore::AbstractDatabase*);
#endif
Modified: trunk/Source/WebKit/chromium/public/WebKitClient.h (87000 => 87001)
--- trunk/Source/WebKit/chromium/public/WebKitClient.h 2011-05-20 23:38:11 UTC (rev 87000)
+++ trunk/Source/WebKit/chromium/public/WebKitClient.h 2011-05-20 23:48:46 UTC (rev 87001)
@@ -139,6 +139,8 @@
// Returns the size of the given database file
virtual long long databaseGetFileSize(const WebString& vfsFileName) { return 0; }
+ // Returns the space available for the given origin
+ virtual long long databaseGetSpaceAvailableForOrigin(const WebKit::WebString& originIdentifier) { return 0; }
// Indexed Database ----------------------------------------------------
Modified: trunk/Source/WebKit/chromium/src/PlatformBridge.cpp (87000 => 87001)
--- trunk/Source/WebKit/chromium/src/PlatformBridge.cpp 2011-05-20 23:38:11 UTC (rev 87000)
+++ trunk/Source/WebKit/chromium/src/PlatformBridge.cpp 2011-05-20 23:48:46 UTC (rev 87001)
@@ -500,6 +500,11 @@
return webKitClient()->databaseGetFileSize(WebString(vfsFileName));
}
+long long PlatformBridge::databaseGetSpaceAvailableForOrigin(const String& originIdentifier)
+{
+ return webKitClient()->databaseGetSpaceAvailableForOrigin(originIdentifier);
+}
+
// Indexed Database -----------------------------------------------------------
PassRefPtr<IDBFactoryBackendInterface> PlatformBridge::idbFactory()
Modified: trunk/Source/WebKit/chromium/src/WebDatabase.cpp (87000 => 87001)
--- trunk/Source/WebKit/chromium/src/WebDatabase.cpp 2011-05-20 23:38:11 UTC (rev 87000)
+++ trunk/Source/WebKit/chromium/src/WebDatabase.cpp 2011-05-20 23:48:46 UTC (rev 87001)
@@ -92,13 +92,35 @@
return databaseObserver;
}
+void WebDatabase::updateDatabaseSize(const WebString& originIdentifier, const WebString& name, long long size)
+{
+#if ENABLE(DATABASE)
+ QuotaTracker::instance().updateDatabaseSize(originIdentifier, name, size);
+#endif // ENABLE(DATABASE)
+}
+
+void WebDatabase::updateSpaceAvailable(const WebString& originIdentifier, long long spaceAvailable)
+{
+#if ENABLE(DATABASE)
+ QuotaTracker::instance().updateSpaceAvailableToOrigin(originIdentifier, spaceAvailable);
+#endif // ENABLE(DATABASE)
+}
+
+void WebDatabase::resetSpaceAvailable(const WebString& originIdentifier)
+{
+#if ENABLE(DATABASE)
+ QuotaTracker::instance().resetSpaceAvailableToOrigin(originIdentifier);
+#endif // ENABLE(DATABASE)
+}
+
+// FIXME: This is deprecated, delete after rolling DEPs and chrome is using the new methods.
void WebDatabase::updateDatabaseSize(
const WebString& originIdentifier, const WebString& databaseName,
- unsigned long long databaseSize, unsigned long long spaceAvailable)
+ long long databaseSize, long long spaceAvailable)
{
#if ENABLE(DATABASE)
- WebCore::QuotaTracker::instance().updateDatabaseSizeAndSpaceAvailableToOrigin(
- originIdentifier, databaseName, databaseSize, spaceAvailable);
+ updateDatabaseSize(originIdentifier, databaseName, databaseSize);
+ updateSpaceAvailable(originIdentifier, spaceAvailable);
#endif // ENABLE(DATABASE)
}