Index: WebKit/chromium/src/WorkerFileSystemCallbacksBridge.cpp |
=================================================================== |
--- WebKit/chromium/src/WorkerFileSystemCallbacksBridge.cpp (revision 140218) |
+++ WebKit/chromium/src/WorkerFileSystemCallbacksBridge.cpp (working copy) |
@@ -33,10 +33,11 @@ |
#if ENABLE(FILE_SYSTEM) && ENABLE(WORKERS) |
+#include "BlobData.h" |
#include "CrossThreadTask.h" |
#include "KURL.h" |
#include "WebCommonWorkerClient.h" |
-#include "WebFileSystemCallbacks.h" |
+#include "WebFileSystemCallbacksImpl.h" |
#include "WebFileSystemEntry.h" |
#include "WebWorkerBase.h" |
#include "WorkerContext.h" |
@@ -124,6 +125,17 @@ |
delete this; |
} |
+ virtual void didCreateSnapshotFile(const WebFileInfo& info) |
+ { |
+ // It's important to create a BlobDataHandle that refers to the platform file path prior |
+ // to return from this method so the underlying file will not be deleted. |
+ OwnPtr<BlobData> blobData = BlobData::create(); |
+ blobData->appendFile(info.platformPath); |
+ RefPtr<BlobDataHandle> snapshotBlob = BlobDataHandle::create(blobData.release(), info.length); |
+ m_bridge->didCreateSnapshotFileOnMainThread(info, m_mode, snapshotBlob); |
+ delete this; |
+ } |
+ |
virtual void didReadDirectory(const WebVector<WebFileSystemEntry>& entries, bool hasMore) |
{ |
m_bridge->didReadDirectoryOnMainThread(entries, hasMore, m_mode); |
@@ -289,13 +301,13 @@ |
this, mode)); |
} |
-void WorkerFileSystemCallbacksBridge::postCreateSnapshotFileToMainThread(WebFileSystem* fileSystem, const KURL& internalBlobURL, const KURL& path, const String& mode) |
+void WorkerFileSystemCallbacksBridge::postCreateSnapshotFileToMainThread(WebFileSystem* fileSystem, const KURL& path, const String& mode) |
{ |
ASSERT(fileSystem); |
dispatchTaskToMainThread( |
createCallbackTask(&createSnapshotFileOnMainThread, |
AllowCrossThreadAccess(fileSystem), |
- internalBlobURL, path, this, mode)); |
+ path, this, mode)); |
} |
void WorkerFileSystemCallbacksBridge::openFileSystemOnMainThread(ScriptExecutionContext*, WebCommonWorkerClient* commonClient, WebFileSystem::Type type, long long size, bool create, PassRefPtr<WorkerFileSystemCallbacksBridge> bridge, const String& mode) |
@@ -357,9 +369,9 @@ |
fileSystem->readDirectory(path, MainThreadFileSystemCallbacks::createLeakedPtr(bridge, mode)); |
} |
-void WorkerFileSystemCallbacksBridge::createSnapshotFileOnMainThread(WebCore::ScriptExecutionContext*, WebFileSystem* fileSystem, const KURL& internalBlobURL, const KURL& path, PassRefPtr<WorkerFileSystemCallbacksBridge> bridge, const String& mode) |
+void WorkerFileSystemCallbacksBridge::createSnapshotFileOnMainThread(WebCore::ScriptExecutionContext*, WebFileSystem* fileSystem, const KURL& path, PassRefPtr<WorkerFileSystemCallbacksBridge> bridge, const String& mode) |
{ |
- fileSystem->createSnapshotFileAndReadMetadata(internalBlobURL, path, MainThreadFileSystemCallbacks::createLeakedPtr(bridge, mode)); |
+ fileSystem->createSnapshotFileAndReadMetadata(path, MainThreadFileSystemCallbacks::createLeakedPtr(bridge, mode)); |
} |
void WorkerFileSystemCallbacksBridge::didFailOnMainThread(WebFileError error, const String& mode) |
@@ -383,6 +395,11 @@ |
mayPostTaskToWorker(createCallbackTask(&didReadMetadataOnWorkerThread, this, info), mode); |
} |
+void WorkerFileSystemCallbacksBridge::didCreateSnapshotFileOnMainThread(const WebFileInfo& info, const String& mode, PassRefPtr<BlobDataHandle> snapshotBlob) |
+{ |
+ mayPostTaskToWorker(createCallbackTask(&didCreateSnapshotFileOnWorkerThread, this, info, snapshotBlob), mode); |
+} |
+ |
void WorkerFileSystemCallbacksBridge::didReadDirectoryOnMainThread(const WebVector<WebFileSystemEntry>& entries, bool hasMore, const String& mode) |
{ |
mayPostTaskToWorker( |
@@ -390,7 +407,7 @@ |
this, entries, hasMore), mode); |
} |
-WorkerFileSystemCallbacksBridge::WorkerFileSystemCallbacksBridge(WebCore::WorkerLoaderProxy* workerLoaderProxy, ScriptExecutionContext* scriptExecutionContext, WebFileSystemCallbacks* callbacks) |
+WorkerFileSystemCallbacksBridge::WorkerFileSystemCallbacksBridge(WebCore::WorkerLoaderProxy* workerLoaderProxy, ScriptExecutionContext* scriptExecutionContext, WebFileSystemCallbacksImpl* callbacks) |
: m_workerLoaderProxy(workerLoaderProxy) |
, m_workerContext(scriptExecutionContext) |
, m_workerContextObserver(WorkerFileSystemContextObserver::create(static_cast<WorkerContext*>(m_workerContext), this).leakPtr()) |
@@ -424,6 +441,11 @@ |
bridge->m_callbacksOnWorkerThread->didReadMetadata(info); |
} |
+void WorkerFileSystemCallbacksBridge::didCreateSnapshotFileOnWorkerThread(ScriptExecutionContext*, PassRefPtr<WorkerFileSystemCallbacksBridge> bridge, const WebFileInfo& info, PassRefPtr<BlobDataHandle> snapshotBlob) |
+{ |
+ bridge->m_callbacksOnWorkerThread->didCreateSnapshotFile(info, snapshotBlob); |
+} |
+ |
void WorkerFileSystemCallbacksBridge::didReadDirectoryOnWorkerThread(ScriptExecutionContext*, PassRefPtr<WorkerFileSystemCallbacksBridge> bridge, const WebVector<WebFileSystemEntry>& entries, bool hasMore) |
{ |
bridge->m_callbacksOnWorkerThread->didReadDirectory(entries, hasMore); |