Commit f4a6f767 authored by jer.noble@apple.com's avatar jer.noble@apple.com

2011-03-23 Jer Noble <jer.noble@apple.com>

        Reviewed by Eric Carlson.

        Application Cache should save audio/ and video/ mime types as flat files
        https://bugs.webkit.org/show_bug.cgi?id=53784
        <rdar://problem/8932473>

        No new tests, as this behavior is not possible to test without changes to the MediaPlayer engines.

        Store certain mime types as flat files alongside the Application Cache database.
        This requires plumbing the saved file path from ApplicationCacheStorage through
        to ApplicationCacheResource.

        (WebCore::ApplicationCacheStorage::openDatabase): Modify the CacheResourceData schema and
            add a new DeletedCacheResources table, add a new CacheResourceDataDeleted trigger.
        (WebCore::ApplicationCacheStorage::store): Add the new path data when adding new rows in
            CacheResourceData, and store media resources as flat files.
        (WebCore::ApplicationCacheStorage::loadCache): Pull the "path" column from CacheResourceData
            when loading cache items.
        (WebCore::ApplicationCacheStorage::remove): Call checkForDeletedResources.
        (WebCore::ApplicationCacheStorage::empty): Ditto.
        (WebCore::ApplicationCacheStorage::storeCopyOfCache): Ditto.
        (WebCore::ApplicationCacheStorage::deleteCacheGroup): Ditto.
        (WebCore::ApplicationCacheStorage::checkForDeletedResources): Walk through DeletedCacheResourceData
            looking for entries with non-empty "path" columns; if found, delete.
        (WebCore::ApplicationCacheStorage::flatFileAreaSize): Walk through CacheResourceData rows
            and sum the file size of those rows with flat file storage.
        (WebCore::ApplicationCacheStorage::verifySchemaVersion): Call deleteTables() instead of
            clearAllTables() directly.
        (WebCore::ApplicationCacheStorage::deleteTables): Call empty() before deleting the tables,
            so that flat files get deleted.
        (WebCore::ApplicationCacheStorage::shouldStoreResourceAsFlatFile): Added.
        (WebCore::ApplicationCacheStorage::writeDataToUniqueFileInDirectory): Added.
        * loader/appcache/ApplicationCacheStorage.h:
        * platform/win/FileSystemWin.cpp:
        (WebCore::openFile): Implement openFile on Windows.

git-svn-id: svn://svn.chromium.org/blink/trunk@82000 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent af6685e8
2011-03-23 Jer Noble <jer.noble@apple.com>
Reviewed by Eric Carlson.
Application Cache should save audio/ and video/ mime types as flat files
https://bugs.webkit.org/show_bug.cgi?id=53784
<rdar://problem/8932473>
No new tests, as this behavior is not possible to test without changes to the MediaPlayer engines.
Store certain mime types as flat files alongside the Application Cache database.
This requires plumbing the saved file path from ApplicationCacheStorage through
to ApplicationCacheResource.
(WebCore::ApplicationCacheStorage::openDatabase): Modify the CacheResourceData schema and
add a new DeletedCacheResources table, add a new CacheResourceDataDeleted trigger.
(WebCore::ApplicationCacheStorage::store): Add the new path data when adding new rows in
CacheResourceData, and store media resources as flat files.
(WebCore::ApplicationCacheStorage::loadCache): Pull the "path" column from CacheResourceData
when loading cache items.
(WebCore::ApplicationCacheStorage::remove): Call checkForDeletedResources.
(WebCore::ApplicationCacheStorage::empty): Ditto.
(WebCore::ApplicationCacheStorage::storeCopyOfCache): Ditto.
(WebCore::ApplicationCacheStorage::deleteCacheGroup): Ditto.
(WebCore::ApplicationCacheStorage::checkForDeletedResources): Walk through DeletedCacheResourceData
looking for entries with non-empty "path" columns; if found, delete.
(WebCore::ApplicationCacheStorage::flatFileAreaSize): Walk through CacheResourceData rows
and sum the file size of those rows with flat file storage.
(WebCore::ApplicationCacheStorage::verifySchemaVersion): Call deleteTables() instead of
clearAllTables() directly.
(WebCore::ApplicationCacheStorage::deleteTables): Call empty() before deleting the tables,
so that flat files get deleted.
(WebCore::ApplicationCacheStorage::shouldStoreResourceAsFlatFile): Added.
(WebCore::ApplicationCacheStorage::writeDataToUniqueFileInDirectory): Added.
* loader/appcache/ApplicationCacheStorage.h:
* platform/win/FileSystemWin.cpp:
(WebCore::openFile): Implement openFile on Windows.
2011-03-24 David Hyatt <hyatt@apple.com>
Reviewed by Dan Bernstein.
......@@ -57,6 +57,7 @@ public:
int64_t estimatedSizeInStorage();
const String& path() const { return m_path; }
void setPath(const String& path) { m_path = path; }
#ifndef NDEBUG
static void dumpType(unsigned type);
......
......@@ -113,6 +113,9 @@ private:
bool store(ApplicationCacheResource*, unsigned cacheStorageID);
bool ensureOriginRecord(const SecurityOrigin*);
bool shouldStoreResourceAsFlatFile(ApplicationCacheResource*);
void deleteTables();
bool writeDataToUniqueFileInDirectory(SharedBuffer*, const String& directory, String& outFilename);
void loadManifestHostHashes();
......@@ -124,6 +127,8 @@ private:
bool executeSQLCommand(const String&);
void checkForMaxSizeReached();
void checkForDeletedResources();
long long flatFileAreaSize();
String m_cacheDirectory;
String m_cacheFile;
......
......@@ -233,6 +233,25 @@ CString openTemporaryFile(const char*, PlatformFileHandle& handle)
return proposedPath;
}
PlatformFileHandle openFile(const String& path, FileOpenMode mode)
{
DWORD desiredAccess = 0;
DWORD creationDisposition = 0;
switch (mode) {
case OpenForRead:
desiredAccess = GENERIC_READ;
creationDisposition = OPEN_EXISTING;
case OpenForWrite:
desiredAccess = GENERIC_WRITE;
creationDisposition = CREATE_ALWAYS;
default:
ASSERT_NOT_REACHED();
}
String destination = path;
return CreateFile(destination.charactersWithNullTermination(), desiredAccess, 0, 0, creationDisposition, FILE_ATTRIBUTE_NORMAL, 0);
}
void closeFile(PlatformFileHandle& handle)
{
if (isHandleValid(handle)) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment