diff options
author | Simon Hausmann <simon.hausmann@nokia.com> | 2012-03-12 14:11:15 +0100 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@nokia.com> | 2012-03-12 14:11:15 +0100 |
commit | dd91e772430dc294e3bf478c119ef8d43c0a3358 (patch) | |
tree | 6f33ce4d5872a5691e0291eb45bf6ab373a5f567 /Source/WebKit/chromium/src/AsyncFileSystemChromium.cpp | |
parent | ad0d549d4cc13433f77c1ac8f0ab379c83d93f28 (diff) | |
download | qtwebkit-dd91e772430dc294e3bf478c119ef8d43c0a3358.tar.gz |
Imported WebKit commit 3db4eb1820ac8fb03065d7ea73a4d9db1e8fea1a (http://svn.webkit.org/repository/webkit/trunk@110422)
This includes build fixes for the latest qtbase/qtdeclarative as well as the final QML2 API.
Diffstat (limited to 'Source/WebKit/chromium/src/AsyncFileSystemChromium.cpp')
-rw-r--r-- | Source/WebKit/chromium/src/AsyncFileSystemChromium.cpp | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/Source/WebKit/chromium/src/AsyncFileSystemChromium.cpp b/Source/WebKit/chromium/src/AsyncFileSystemChromium.cpp index 1f93cf93e..8d8a3fedc 100644 --- a/Source/WebKit/chromium/src/AsyncFileSystemChromium.cpp +++ b/Source/WebKit/chromium/src/AsyncFileSystemChromium.cpp @@ -34,7 +34,10 @@ #include "AsyncFileSystemCallbacks.h" #include "AsyncFileWriterChromium.h" +#include "BlobURL.h" +#include "FileMetadata.h" #include "SecurityOrigin.h" +#include "ThreadableBlobRegistry.h" #include "WebFileInfo.h" #include "WebFileSystemCallbacksImpl.h" #include "WebFileWriter.h" @@ -46,11 +49,51 @@ namespace WebCore { +namespace { + // ChromeOS-specific filesystem type. const AsyncFileSystem::Type externalType = static_cast<AsyncFileSystem::Type>(WebKit::WebFileSystem::TypeExternal); const char externalPathPrefix[] = "external"; const size_t externalPathPrefixLength = sizeof(externalPathPrefix) - 1; +// Specialized callback class for createSnapshotFileAndReadMetadata. +class SnapshotFileCallbacks : public AsyncFileSystemCallbacks { +public: + static PassOwnPtr<SnapshotFileCallbacks> create(const KURL& internalBlobURL, PassOwnPtr<WebCore::AsyncFileSystemCallbacks> callbacks) + { + return adoptPtr(new SnapshotFileCallbacks(internalBlobURL, callbacks)); + } + + virtual void didReadMetadata(const FileMetadata& metadata) + { + ASSERT(m_callbacks); + + // This will create a new File object using the metadata. + m_callbacks->didReadMetadata(metadata); + + // Now that we've registered the snapshot file, we can unregister our internalBlobURL which has played a placeholder for the file during the IPC. + ThreadableBlobRegistry::unregisterBlobURL(m_internalBlobURL); + } + + virtual void didFail(int error) + { + ASSERT(m_callbacks); + m_callbacks->didFail(error); + } + +private: + SnapshotFileCallbacks(const KURL& internalBlobURL, PassOwnPtr<WebCore::AsyncFileSystemCallbacks> callbacks) + : m_internalBlobURL(internalBlobURL) + , m_callbacks(callbacks) + { + } + + KURL m_internalBlobURL; + OwnPtr<WebCore::AsyncFileSystemCallbacks> m_callbacks; +}; + +} // namespace + // static bool AsyncFileSystem::isAvailable() { @@ -254,6 +297,15 @@ void AsyncFileSystemChromium::createWriter(AsyncFileWriterClient* client, const m_webFileSystem->readMetadata(pathAsURL, new FileWriterHelperCallbacks(client, pathAsURL, m_webFileSystem, callbacks)); } +void AsyncFileSystemChromium::createSnapshotFileAndReadMetadata(const String& path, PassOwnPtr<AsyncFileSystemCallbacks> callbacks) +{ + KURL pathAsURL = virtualPathToFileSystemURL(path); + KURL internalBlobURL = BlobURL::createInternalURL(); + + // This will create a snapshot file and register the file to a blob using the given internalBlobURL. + m_webFileSystem->createSnapshotFileAndReadMetadata(internalBlobURL, pathAsURL, new WebKit::WebFileSystemCallbacksImpl(createSnapshotFileCallback(internalBlobURL, callbacks))); +} + KURL AsyncFileSystemChromium::virtualPathToFileSystemURL(const String& virtualPath) const { ASSERT(!m_filesystemRootURL.isEmpty()); @@ -263,6 +315,11 @@ KURL AsyncFileSystemChromium::virtualPathToFileSystemURL(const String& virtualPa return url; } +PassOwnPtr<AsyncFileSystemCallbacks> AsyncFileSystemChromium::createSnapshotFileCallback(const KURL& internalBlobURL, PassOwnPtr<AsyncFileSystemCallbacks> callbacks) const +{ + return SnapshotFileCallbacks::create(internalBlobURL, callbacks); +} + } // namespace WebCore #endif |