WorkerPlatformFileWriterClient.cpp [plain text]
#include "config.h"
#if ENABLE(FILE_SYSTEM) && ENABLE(WORKERS)
#include "WorkerPlatformFileWriterClient.h"
#include "AsyncFileWriterBlackBerry.h"
#include "AsyncFileWriterClient.h"
#include "CrossThreadTask.h"
#include "FileError.h"
#include "WorkerContext.h"
#include "WorkerLoaderProxy.h"
#include "WorkerThread.h"
namespace WebCore {
template<> struct CrossThreadCopierBase<false, false, WorkerPlatformFileWriterClient*> : public CrossThreadCopierPassThrough<WorkerPlatformFileWriterClient*> {
};
void WorkerPlatformFileWriterClient::notifyWriteOnWorkerThread(ScriptExecutionContext*, WorkerPlatformFileWriterClient* platformClient, long long bytes, bool complete)
{
platformClient->PlatformFileWriterClient::notifyWrite(bytes, complete);
}
void WorkerPlatformFileWriterClient::notifyFailOnWorkerThread(ScriptExecutionContext*, WorkerPlatformFileWriterClient* platformClient, BlackBerry::Platform::WebFileError error)
{
platformClient->PlatformFileWriterClient::notifyFail(error);
}
void WorkerPlatformFileWriterClient::notifyTruncateOnWorkerThread(ScriptExecutionContext*, WorkerPlatformFileWriterClient* platformClient)
{
platformClient->PlatformFileWriterClient::notifyTruncate();
}
void WorkerPlatformFileWriterClient::notifyWrite(long long bytes, bool complete)
{
postTaskToWorkerThreadIfNeeded(createCallbackTask(¬ifyWriteOnWorkerThread, this, bytes, complete));
}
void WorkerPlatformFileWriterClient::notifyTruncate()
{
postTaskToWorkerThreadIfNeeded(createCallbackTask(¬ifyTruncateOnWorkerThread, this));
}
void WorkerPlatformFileWriterClient::notifyFail(BlackBerry::Platform::WebFileError error)
{
postTaskToWorkerThreadIfNeeded(createCallbackTask(¬ifyFailOnWorkerThread, this, error));
}
void WorkerPlatformFileWriterClient::postTaskToWorkerThreadIfNeeded(PassOwnPtr<ScriptExecutionContext::Task> task)
{
WTF::MutexLocker locker(m_mutex);
if (!m_context)
return;
m_context->thread()->workerLoaderProxy().postTaskForModeToWorkerContext(task, m_mode);
}
}
#endif