1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112
|
/*
* Copyright (C) 2012 Research In Motion Limited. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA
*/
#ifndef WorkerPlatformAsyncFileSystemCallbacks_h
#define WorkerPlatformAsyncFileSystemCallbacks_h
#if ENABLE(FILE_SYSTEM) && ENABLE(WORKERS)
#include "CrossThreadCopier.h"
#include "PlatformAsyncFileSystemCallbacks.h"
#include "ScriptExecutionContext.h"
#include "WorkerGlobalScope.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, WorkerGlobalScope*> : public CrossThreadCopierPassThrough<WorkerGlobalScope*> {
};
template<> struct CrossThreadCopierBase<false, false, AsyncFileWriterClient*> : public CrossThreadCopierPassThrough<AsyncFileWriterClient*> {
};
void postTaskToMainThread(PassOwnPtr<ScriptExecutionContext::Task>);
class KURL;
class WorkerPlatformAsyncFileSystemCallbacks: public PlatformAsyncFileSystemCallbacks, public WorkerGlobalScope::Observer {
public:
WorkerPlatformAsyncFileSystemCallbacks(PassOwnPtr<AsyncFileSystemCallbacks> callbacks, WorkerGlobalScope* context, const String& mode, const KURL& rootURL = KURL())
: PlatformAsyncFileSystemCallbacks(callbacks, rootURL)
, WorkerGlobalScope::Observer(context)
, m_context(context)
, m_mode(mode)
{
}
// For createWriter.
WorkerPlatformAsyncFileSystemCallbacks(PassOwnPtr<AsyncFileSystemCallbacks> callbacks, AsyncFileWriterClient* client, WorkerGlobalScope* context, const String& mode)
: PlatformAsyncFileSystemCallbacks(callbacks, client)
, WorkerGlobalScope::Observer(context)
, m_context(context)
, m_mode(mode)
{
}
void postTaskToWorkerThread(PassOwnPtr<ScriptExecutionContext::Task>);
// From WorkerGlobalScope::Observer. This will be called on worker thread.
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);
WorkerGlobalScope* m_context;
String m_mode;
WTF::Mutex m_mutex;
};
} // namespace WebCore
#endif
#endif
|