Example #1
0
bool DOMFileSystemBase::crackFileSystemURL(const KURL& url, AsyncFileSystem::Type& type, String& filePath)
{
    if (!url.protocolIs("filesystem"))
        return false;

    KURL originURL(ParsedURLString, url.path());
    String path = decodeURLEscapeSequences(originURL.path());
    if (path.isEmpty() || path[0] != '/')
        return false;
    path = path.substring(1);

    if (path.startsWith(kTemporaryPathPrefix)) {
        type = AsyncFileSystem::Temporary;
        path = path.substring(kTemporaryPathPrefixLength);
    } else if (path.startsWith(kPersistentPathPrefix)) {
        type = AsyncFileSystem::Persistent;
        path = path.substring(kPersistentPathPrefixLength);
    } else if (path.startsWith(kExternalPathPrefix)) {
        type = AsyncFileSystem::External;
        path = path.substring(kExternalPathPrefixLength);
    } else
        return false;

    if (path.isEmpty() || path[0] != '/')
        return false;

    filePath.swap(path);
    return true;
}
void ApplicationCache::deleteCacheForOrigin(SecurityOrigin* origin)
{
    Vector<KURL> urls;
    if (!cacheStorage().manifestURLs(&urls)) {
        LOG_ERROR("Failed to retrieve ApplicationCache manifest URLs");
        return;
    }

    KURL originURL(KURL(), origin->toString());

    size_t count = urls.size();
    for (size_t i = 0; i < count; ++i) {
        if (protocolHostAndPortAreEqual(urls[i], originURL)) {
            ApplicationCacheGroup* group = cacheStorage().findInMemoryCacheGroup(urls[i]);
            if (group)
                group->makeObsolete();
            else
                cacheStorage().deleteCacheGroup(urls[i]);
        }
    }
}