WorkerPlatformAsyncFileSystemCallbacks.h [plain text]
#ifndef WorkerPlatformAsyncFileSystemCallbacks_h
#define WorkerPlatformAsyncFileSystemCallbacks_h
#if ENABLE(FILE_SYSTEM) && ENABLE(WORKERS)
#include "CrossThreadCopier.h"
#include "PlatformAsyncFileSystemCallbacks.h"
#include "ScriptExecutionContext.h"
#include "WorkerContext.h"
#include <BlackBerryPlatformWebFileSystemFileWriter.h>
#include <BlackBerryPlatformWebFileSystemPrimitives.h>
#include <wtf/Threading.h>
#include <wtf/text/WTFString.h>
namespace WebCore {
template<> struct CrossThreadCopierBase<false, false, BlackBerry::Platform::WebFileSystem*> : public CrossThreadCopierPassThrough<BlackBerry::Platform::WebFileSystem*> {
};
template<> struct CrossThreadCopierBase<false, false, BlackBerry::Platform::WebFileWriter*> : public CrossThreadCopierPassThrough<BlackBerry::Platform::WebFileWriter*> {
};
class WorkerPlatformAsyncFileSystemCallbacks;
template<> struct CrossThreadCopierBase<false, false, WorkerPlatformAsyncFileSystemCallbacks*> : public CrossThreadCopierPassThrough<WorkerPlatformAsyncFileSystemCallbacks*> {
};
template<> struct CrossThreadCopierBase<false, false, Blob*> : public CrossThreadCopierPassThrough<Blob*> {
};
template<> struct CrossThreadCopierBase<false, false, WorkerContext*> : public CrossThreadCopierPassThrough<WorkerContext*> {
};
template<> struct CrossThreadCopierBase<false, false, AsyncFileWriterClient*> : public CrossThreadCopierPassThrough<AsyncFileWriterClient*> {
};
void postTaskToMainThread(PassOwnPtr<ScriptExecutionContext::Task>);
class KURL;
class WorkerPlatformAsyncFileSystemCallbacks: public PlatformAsyncFileSystemCallbacks, public WorkerContext::Observer {
public:
WorkerPlatformAsyncFileSystemCallbacks(PassOwnPtr<AsyncFileSystemCallbacks> callbacks, WorkerContext* context, const String& mode, const KURL& rootURL = KURL())
: PlatformAsyncFileSystemCallbacks(callbacks, rootURL)
, WorkerContext::Observer(context)
, m_context(context)
, m_mode(mode)
{
}
WorkerPlatformAsyncFileSystemCallbacks(PassOwnPtr<AsyncFileSystemCallbacks> callbacks, AsyncFileWriterClient* client, WorkerContext* context, const String& mode)
: PlatformAsyncFileSystemCallbacks(callbacks, client)
, WorkerContext::Observer(context)
, m_context(context)
, m_mode(mode)
{
}
void postTaskToWorkerThread(PassOwnPtr<ScriptExecutionContext::Task>);
virtual void notifyStop();
virtual void notifyOpenFileSystem(BlackBerry::Platform::WebFileSystem* platformFileSystem);
virtual void notifySucceed();
virtual void notifyFail(BlackBerry::Platform::WebFileError);
virtual void notifyReadMetadata(const BlackBerry::Platform::WebFileInfo&);
virtual void notifyCreateSnapshotFileAndReadMetadata(const BlackBerry::Platform::WebFileInfo&);
virtual void notifyReadDirectory(const std::vector<BlackBerry::Platform::WebFileSystemEntry>& entries, bool hasMore);
virtual void notifyCreateFileWriter(BlackBerry::Platform::WebFileWriter* platformWriter, long long length);
virtual PassOwnPtr<AsyncFileSystem> createAsyncFileSystem(PassOwnPtr<BlackBerry::Platform::WebFileSystem> platformFileSystem);
virtual PassOwnPtr<AsyncFileWriter> createAsyncFileWriter(PassOwnPtr<BlackBerry::Platform::WebFileWriter> platformWriter);
virtual void deleteMe();
private:
~WorkerPlatformAsyncFileSystemCallbacks() { }
static void notifyOpenFileSystemOnWorkerThread(ScriptExecutionContext*, WorkerPlatformAsyncFileSystemCallbacks*, BlackBerry::Platform::WebFileSystem* platformFileSystem);
static void notifySucceedOnWorkerThread(ScriptExecutionContext*, WorkerPlatformAsyncFileSystemCallbacks*);
static void notifyFailOnWorkerThread(ScriptExecutionContext*, WorkerPlatformAsyncFileSystemCallbacks*, BlackBerry::Platform::WebFileError);
static void notifyReadMetadataOnWorkerThread(ScriptExecutionContext*, WorkerPlatformAsyncFileSystemCallbacks*, const BlackBerry::Platform::WebFileInfo&);
static void notifyCreateSnapshotFileAndReadMetadataOnWorkerThread(ScriptExecutionContext*, WorkerPlatformAsyncFileSystemCallbacks*, const BlackBerry::Platform::WebFileInfo&);
static void notifyReadDirectoryEntryOnWorkerThread(ScriptExecutionContext*, WorkerPlatformAsyncFileSystemCallbacks*, const std::vector<BlackBerry::Platform::WebFileSystemEntry>& entries, bool hasMore);
static void notifyCreateFileWriterOnWorkerThread(ScriptExecutionContext*, WorkerPlatformAsyncFileSystemCallbacks*, BlackBerry::Platform::WebFileWriter* platformWriter, long long length);
WorkerContext* m_context;
String m_mode;
WTF::Mutex m_mutex;
};
} #endif
#endif