#include "ApplicationCacheHost.h"
#include "ApplicationCacheResource.h"
#include "FileSystem.h"
-#include "URL.h"
#include "NotImplemented.h"
+#include "SQLiteDatabaseTracker.h"
#include "SQLiteStatement.h"
#include "SQLiteTransaction.h"
#include "SecurityOrigin.h"
+#include "URL.h"
#include "UUID.h"
-#include <wtf/text/CString.h>
#include <wtf/StdLibExtras.h>
#include <wtf/StringExtras.h>
+#include <wtf/text/CString.h>
#include <wtf/text/StringBuilder.h>
-#if PLATFORM(IOS)
-#include "SQLiteDatabaseTracker.h"
-#endif
-
namespace WebCore {
static const char flatFileSubdirectory[] = "ApplicationCache";
ApplicationCacheGroup* ApplicationCacheStorage::loadCacheGroup(const URL& manifestURL)
{
-#if PLATFORM(IOS)
- // FIXME: Move the PLATFORM(IOS)-guards inside the constructor and destructor of SQLiteTransactionInProgressAutoCounter.
SQLiteTransactionInProgressAutoCounter transactionCounter;
-#endif
+
openDatabase(false);
if (!m_database.isOpen())
return 0;
// to avoid trying to open the database over and over if it doesn't exist.
hasLoadedHashes = true;
-#if PLATFORM(IOS)
- // FIXME: Move the PLATFORM(IOS)-guards inside the constructor and destructor of SQLiteTransactionInProgressAutoCounter.
SQLiteTransactionInProgressAutoCounter transactionCounter;
-#endif
+
openDatabase(false);
if (!m_database.isOpen())
return;
if (!m_database.isOpen())
return 0;
-#if PLATFORM(IOS)
- // FIXME: Move the PLATFORM(IOS)-guards inside the constructor and destructor of SQLiteTransactionInProgressAutoCounter.
SQLiteTransactionInProgressAutoCounter transactionCounter;
-#endif
// Check the database. Look for all cache groups with a newest cache.
SQLiteStatement statement(m_database, "SELECT id, manifestURL, newestCache FROM CacheGroups WHERE newestCache IS NOT NULL");
ApplicationCacheGroup* ApplicationCacheStorage::fallbackCacheGroupForURL(const URL& url)
{
-#if PLATFORM(IOS)
- // FIXME: Move the PLATFORM(IOS)-guards inside the constructor and destructor of SQLiteTransactionInProgressAutoCounter.
SQLiteTransactionInProgressAutoCounter transactionCounter;
-#endif
+
ASSERT(!url.hasFragmentIdentifier());
// Check if an appropriate cache already exists in memory.
bool ApplicationCacheStorage::calculateQuotaForOrigin(const SecurityOrigin* origin, int64_t& quota)
{
-#if PLATFORM(IOS)
- // FIXME: Move the PLATFORM(IOS)-guards inside the constructor and destructor of SQLiteTransactionInProgressAutoCounter.
SQLiteTransactionInProgressAutoCounter transactionCounter;
-#endif
+
// If an Origin record doesn't exist, then the COUNT will be 0 and quota will be 0.
// Using the count to determine if a record existed or not is a safe way to determine
// if a quota of 0 is real, from the record, or from null.
bool ApplicationCacheStorage::calculateUsageForOrigin(const SecurityOrigin* origin, int64_t& usage)
{
-#if PLATFORM(IOS)
- // FIXME: Move the PLATFORM(IOS)-guards inside the constructor and destructor of SQLiteTransactionInProgressAutoCounter.
SQLiteTransactionInProgressAutoCounter transactionCounter;
-#endif
+
// If an Origins record doesn't exist, then the SUM will be null,
// which will become 0, as expected, when converting to a number.
SQLiteStatement statement(m_database, "SELECT SUM(Caches.size)"
bool ApplicationCacheStorage::calculateRemainingSizeForOriginExcludingCache(const SecurityOrigin* origin, ApplicationCache* cache, int64_t& remainingSize)
{
-#if PLATFORM(IOS)
- // FIXME: Move the PLATFORM(IOS)-guards inside the constructor and destructor of SQLiteTransactionInProgressAutoCounter.
SQLiteTransactionInProgressAutoCounter transactionCounter;
-#endif
+
openDatabase(false);
if (!m_database.isOpen())
return false;
bool ApplicationCacheStorage::storeUpdatedQuotaForOrigin(const SecurityOrigin* origin, int64_t quota)
{
-#if PLATFORM(IOS)
- // FIXME: Move the PLATFORM(IOS)-guards inside the constructor and destructor of SQLiteTransactionInProgressAutoCounter.
SQLiteTransactionInProgressAutoCounter transactionCounter;
-#endif
+
openDatabase(true);
if (!m_database.isOpen())
return false;
void ApplicationCacheStorage::openDatabase(bool createIfDoesNotExist)
{
-#if PLATFORM(IOS)
- // FIXME: Move the PLATFORM(IOS)-guards inside the constructor and destructor of SQLiteTransactionInProgressAutoCounter.
SQLiteTransactionInProgressAutoCounter transactionCounter;
-#endif
+
if (m_database.isOpen())
return;
bool ApplicationCacheStorage::storeUpdatedType(ApplicationCacheResource* resource, ApplicationCache* cache)
{
-#if PLATFORM(IOS)
- // FIXME: Move the PLATFORM(IOS)-guards inside the constructor and destructor of SQLiteTransactionInProgressAutoCounter.
SQLiteTransactionInProgressAutoCounter transactionCounter;
-#endif
+
ASSERT_UNUSED(cache, cache->storageID());
ASSERT(resource->storageID());
bool ApplicationCacheStorage::store(ApplicationCacheResource* resource, ApplicationCache* cache)
{
-#if PLATFORM(IOS)
- // FIXME: Move the PLATFORM(IOS)-guards inside the constructor and destructor of SQLiteTransactionInProgressAutoCounter.
SQLiteTransactionInProgressAutoCounter transactionCounter;
-#endif
+
ASSERT(cache->storageID());
openDatabase(true);
void ApplicationCacheStorage::remove(ApplicationCache* cache)
{
-#if PLATFORM(IOS)
- // FIXME: Move the PLATFORM(IOS)-guards inside the constructor and destructor of SQLiteTransactionInProgressAutoCounter.
SQLiteTransactionInProgressAutoCounter transactionCounter;
-#endif
+
if (!cache->storageID())
return;
void ApplicationCacheStorage::empty()
{
-#if PLATFORM(IOS)
- // FIXME: Move the PLATFORM(IOS)-guards inside the constructor and destructor of SQLiteTransactionInProgressAutoCounter.
SQLiteTransactionInProgressAutoCounter transactionCounter;
-#endif
+
openDatabase(false);
if (!m_database.isOpen())
bool ApplicationCacheStorage::storeCopyOfCache(const String& cacheDirectory, ApplicationCacheHost* cacheHost)
{
-#if PLATFORM(IOS)
- // FIXME: Move the PLATFORM(IOS)-guards inside the constructor and destructor of SQLiteTransactionInProgressAutoCounter.
SQLiteTransactionInProgressAutoCounter transactionCounter;
-#endif
+
ApplicationCache* cache = cacheHost->applicationCache();
if (!cache)
return true;
bool ApplicationCacheStorage::manifestURLs(Vector<URL>* urls)
{
-#if PLATFORM(IOS)
- // FIXME: Move the PLATFORM(IOS)-guards inside the constructor and destructor of SQLiteTransactionInProgressAutoCounter.
SQLiteTransactionInProgressAutoCounter transactionCounter;
-#endif
+
ASSERT(urls);
openDatabase(false);
if (!m_database.isOpen())
bool ApplicationCacheStorage::cacheGroupSize(const String& manifestURL, int64_t* size)
{
-#if PLATFORM(IOS)
- // FIXME: Move the PLATFORM(IOS)-guards inside the constructor and destructor of SQLiteTransactionInProgressAutoCounter.
SQLiteTransactionInProgressAutoCounter transactionCounter;
-#endif
+
ASSERT(size);
openDatabase(false);
if (!m_database.isOpen())
bool ApplicationCacheStorage::deleteCacheGroup(const String& manifestURL)
{
-#if PLATFORM(IOS)
- // FIXME: Move the PLATFORM(IOS)-guards inside the constructor and destructor of SQLiteTransactionInProgressAutoCounter.
SQLiteTransactionInProgressAutoCounter transactionCounter;
-#endif
+
SQLiteTransaction deleteTransaction(m_database);
// Check to see if the group is in memory.
ApplicationCacheGroup* group = m_cachesInMemory.get(manifestURL);
void ApplicationCacheStorage::vacuumDatabaseFile()
{
-#if PLATFORM(IOS)
- // FIXME: Move the PLATFORM(IOS)-guards inside the constructor and destructor of SQLiteTransactionInProgressAutoCounter.
SQLiteTransactionInProgressAutoCounter transactionCounter;
-#endif
+
openDatabase(false);
if (!m_database.isOpen())
return;