LocalFileSystem.cpp [plain text]
#include "config.h"
#include "LocalFileSystem.h"
#if PLATFORM(CHROMIUM)
#error "Chromium should not compile this file and instead define its own version of these factories."
#endif
#if ENABLE(FILE_SYSTEM)
#include "CrossThreadTask.h"
#include "DOMFileSystem.h"
#include "ErrorCallback.h"
#include "ExceptionCode.h"
#include "FileError.h"
#include "FileSystemCallback.h"
#include "FileSystemCallbacks.h"
#include "ScriptExecutionContext.h"
#include "SecurityOrigin.h"
#include <wtf/PassRefPtr.h>
namespace WebCore {
LocalFileSystem* LocalFileSystem::s_instance = 0;
void LocalFileSystem::initializeLocalFileSystem(const String& basePath)
{
ASSERT(isMainThread());
ASSERT(!s_instance);
if (s_instance)
return;
OwnPtr<LocalFileSystem> localFileSystem = adoptPtr(new LocalFileSystem(basePath));
s_instance = localFileSystem.leakPtr();
}
LocalFileSystem& LocalFileSystem::localFileSystem()
{
ASSERT(s_instance);
return *s_instance;
}
String LocalFileSystem::fileSystemBasePath() const
{
return m_basePath;
}
static void openFileSystem(ScriptExecutionContext*, const String& basePath, const String& identifier, AsyncFileSystem::Type type, bool create, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
{
AsyncFileSystem::openFileSystem(basePath, identifier, type, create, callbacks);
}
void LocalFileSystem::readFileSystem(ScriptExecutionContext* context, AsyncFileSystem::Type type, PassOwnPtr<AsyncFileSystemCallbacks> callbacks, bool)
{
context->postTask(createCallbackTask(&openFileSystem, fileSystemBasePath(), context->securityOrigin()->databaseIdentifier(), type, false, callbacks));
}
void LocalFileSystem::requestFileSystem(ScriptExecutionContext* context, AsyncFileSystem::Type type, long long, PassOwnPtr<AsyncFileSystemCallbacks> callbacks, bool)
{
context->postTask(createCallbackTask(&openFileSystem, fileSystemBasePath(), context->securityOrigin()->databaseIdentifier(), type, true, callbacks));
}
}
#endif // ENABLE(FILE_SYSTEM)