[BlackBerry] Upstream the filesystem code
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 11 Apr 2013 23:09:49 +0000 (23:09 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 11 Apr 2013 23:09:49 +0000 (23:09 +0000)
https://bugs.webkit.org/show_bug.cgi?id=114437

Patch by Alberto Garcia <agarcia@igalia.com> on 2013-04-11
Reviewed by Rob Buis.

This patch contains contributions from many members of the
BlackBerry WebKit team.

* platform/blackberry/AsyncFileWriterBlackBerry.cpp: Added.
(WebCore):
(WebCore::AsyncFileWriterBlackBerry::write):
* platform/blackberry/AsyncFileWriterBlackBerry.h: Added.
(WTF):
(WTF::BlackBerry::Platform::WebFileWriter):
(WebCore):
* platform/blackberry/DOMFileSystemBlackBerry.cpp: Added.
(WebCore):
(WebCore::DOMFileSystemBase::createFileSystemURL):
(WebCore::DOMFileSystemBase::crackFileSystemURL):
(WebCore::DOMFileSystemBase::supportsToURL):
(WebCore::DOMFileSystemBase::isValidType):
* platform/blackberry/LocalFileSystemBlackBerry.cpp: Added.
(WebCore):
(WebCore::fileSystemTypeString):
(WebCore::openFileSystem):
(WebCore::LocalFileSystem::deleteFileSystem):
(WebCore::LocalFileSystem::readFileSystem):
(WebCore::LocalFileSystem::requestFileSystem):
* platform/blackberry/PlatformAsyncFileSystemCallbacks.cpp: Added.
(WebCore):
(WebCore::PlatformAsyncFileSystemCallbacks::notifyOpenFileSystem):
(WebCore::PlatformAsyncFileSystemCallbacks::notifySucceed):
(WebCore::PlatformAsyncFileSystemCallbacks::notifyFail):
(WebCore::getFileMetadata):
(WebCore::PlatformAsyncFileSystemCallbacks::notifyReadMetadata):
(WebCore::PlatformAsyncFileSystemCallbacks::notifyCreateSnapshotFileAndReadMetadata):
(WebCore::PlatformAsyncFileSystemCallbacks::notifyReadDirectory):
(WebCore::PlatformAsyncFileSystemCallbacks::notifyCreateFileWriter):
(WebCore::PlatformAsyncFileSystemCallbacks::createAsyncFileSystem):
(WebCore::PlatformAsyncFileSystemCallbacks::createAsyncFileWriter):
(WebCore::PlatformAsyncFileSystemCallbacks::deleteMe):
* platform/blackberry/PlatformAsyncFileSystemCallbacks.h: Added.
(WebCore):
* platform/blackberry/PlatformBlob.cpp: Added.
(WebCore):
(WebCore::PlatformBlob::nextDataItem):
* platform/blackberry/PlatformBlob.h: Added.
(WebCore):
* platform/blackberry/PlatformFileWriterClient.cpp: Added.
(WebCore):
(WebCore::PlatformFileWriterClient::notifyWrite):
(WebCore::PlatformFileWriterClient::notifyTruncate):
(WebCore::PlatformFileWriterClient::notifyFail):
* platform/blackberry/PlatformFileWriterClient.h: Added.
(WebCore):
(WTF):
(WTF::WebCore::PlatformFileWriterClient):
* platform/blackberry/WorkerAsyncFileSystemBlackBerry.cpp: Added.
(WebCore):
(WebCore::WorkerAsyncFileSystemBlackBerry::WorkerAsyncFileSystemBlackBerry):
(WebCore::WorkerAsyncFileSystemBlackBerry::~WorkerAsyncFileSystemBlackBerry):
(WebCore::WorkerAsyncFileSystemBlackBerry::waitForOperationToComplete):
(WebCore::WorkerAsyncFileSystemBlackBerry::openFileSystemOnMainThread):
(WebCore::WorkerAsyncFileSystemBlackBerry::deleteFileSystemOnMainThread):
(WebCore::WorkerAsyncFileSystemBlackBerry::moveOnMainThread):
(WebCore::WorkerAsyncFileSystemBlackBerry::copyOnMainThread):
(WebCore::WorkerAsyncFileSystemBlackBerry::removeOnMainThread):
(WebCore::WorkerAsyncFileSystemBlackBerry::removeRecursivelyOnMainThread):
(WebCore::WorkerAsyncFileSystemBlackBerry::readMetadataOnMainThread):
(WebCore::WorkerAsyncFileSystemBlackBerry::createFileOnMainThread):
(WebCore::WorkerAsyncFileSystemBlackBerry::createDirectoryOnMainThread):
(WebCore::WorkerAsyncFileSystemBlackBerry::fileExistsOnMainThread):
(WebCore::WorkerAsyncFileSystemBlackBerry::directoryExistsOnMainThread):
(WebCore::WorkerAsyncFileSystemBlackBerry::readDirectoryOnMainThread):
(WebCore::WorkerAsyncFileSystemBlackBerry::createWriterOnMainThread):
(WebCore::WorkerAsyncFileSystemBlackBerry::createSnapshotFileAndReadMetadataOnMainThread):
(WebCore::WorkerAsyncFileSystemBlackBerry::openFileSystem):
(WebCore::WorkerAsyncFileSystemBlackBerry::deleteFileSystem):
(WebCore::WorkerAsyncFileSystemBlackBerry::move):
(WebCore::WorkerAsyncFileSystemBlackBerry::copy):
(WebCore::WorkerAsyncFileSystemBlackBerry::remove):
(WebCore::WorkerAsyncFileSystemBlackBerry::removeRecursively):
(WebCore::WorkerAsyncFileSystemBlackBerry::readMetadata):
(WebCore::WorkerAsyncFileSystemBlackBerry::createFile):
(WebCore::WorkerAsyncFileSystemBlackBerry::createDirectory):
(WebCore::WorkerAsyncFileSystemBlackBerry::fileExists):
(WebCore::WorkerAsyncFileSystemBlackBerry::directoryExists):
(WebCore::WorkerAsyncFileSystemBlackBerry::readDirectory):
(WebCore::WorkerAsyncFileSystemBlackBerry::createWriter):
(WebCore::WorkerAsyncFileSystemBlackBerry::createSnapshotFileAndReadMetadata):
* platform/blackberry/WorkerAsyncFileSystemBlackBerry.h: Added.
(WebCore):
(WorkerAsyncFileSystemBlackBerry):
(WebCore::WorkerAsyncFileSystemBlackBerry::create):
* platform/blackberry/WorkerAsyncFileWriterBlackBerry.cpp: Added.
(WebCore):
(WebCore::WorkerAsyncFileWriterBlackBerry::writeOnMainThread):
(WebCore::WorkerAsyncFileWriterBlackBerry::truncateOnMainThread):
(WebCore::WorkerAsyncFileWriterBlackBerry::abortOnMainThread):
(WebCore::WorkerAsyncFileWriterBlackBerry::write):
(WebCore::WorkerAsyncFileWriterBlackBerry::truncate):
(WebCore::WorkerAsyncFileWriterBlackBerry::abort):
(WebCore::WorkerAsyncFileWriterBlackBerry::waitForOperationToComplete):
(WebCore::WorkerAsyncFileWriterBlackBerry::platformWriterClient):
* platform/blackberry/WorkerAsyncFileWriterBlackBerry.h: Added.
(WebCore):
* platform/blackberry/WorkerPlatformAsyncFileSystemCallbacks.cpp: Added.
(WebCore):
(WebCore::performTaskOnMainThread):
(WebCore::postTaskToMainThread):
(WebCore::WorkerPlatformAsyncFileSystemCallbacks::notifyStop):
(WebCore::WorkerPlatformAsyncFileSystemCallbacks::notifyOpenFileSystem):
(WebCore::WorkerPlatformAsyncFileSystemCallbacks::notifySucceed):
(WebCore::WorkerPlatformAsyncFileSystemCallbacks::notifyFail):
(WebCore::WorkerPlatformAsyncFileSystemCallbacks::notifyReadMetadata):
(WebCore::WorkerPlatformAsyncFileSystemCallbacks::notifyReadDirectory):
(WebCore::WorkerPlatformAsyncFileSystemCallbacks::notifyCreateFileWriter):
(WebCore::WorkerPlatformAsyncFileSystemCallbacks::createAsyncFileSystem):
(WebCore::WorkerPlatformAsyncFileSystemCallbacks::createAsyncFileWriter):
(WebCore::WorkerPlatformAsyncFileSystemCallbacks::deleteMe):
(WebCore::WorkerPlatformAsyncFileSystemCallbacks::postTaskToWorkerThread):
(WebCore::WorkerPlatformAsyncFileSystemCallbacks::notifyOpenFileSystemOnWorkerThread):
(WebCore::WorkerPlatformAsyncFileSystemCallbacks::notifySucceedOnWorkerThread):
(WebCore::WorkerPlatformAsyncFileSystemCallbacks::notifyFailOnWorkerThread):
(WebCore::WorkerPlatformAsyncFileSystemCallbacks::notifyReadMetadataOnWorkerThread):
(WebCore::WorkerPlatformAsyncFileSystemCallbacks::notifyReadDirectoryEntryOnWorkerThread):
(WebCore::WorkerPlatformAsyncFileSystemCallbacks::notifyCreateFileWriterOnWorkerThread):
* platform/blackberry/WorkerPlatformAsyncFileSystemCallbacks.h: Added.
(WebCore):
* platform/blackberry/WorkerPlatformFileWriterClient.cpp: Added.
(WebCore):
(WebCore::WorkerPlatformFileWriterClient::notifyWriteOnWorkerThread):
(WebCore::WorkerPlatformFileWriterClient::notifyFailOnWorkerThread):
(WebCore::WorkerPlatformFileWriterClient::notifyTruncateOnWorkerThread):
(WebCore::WorkerPlatformFileWriterClient::notifyWrite):
(WebCore::WorkerPlatformFileWriterClient::notifyTruncate):
(WebCore::WorkerPlatformFileWriterClient::notifyFail):
(WebCore::WorkerPlatformFileWriterClient::postTaskToWorkerThreadIfNeeded):
* platform/blackberry/WorkerPlatformFileWriterClient.h: Added.
(WebCore):
(WTF):
(WTF::WebCore::WorkerPlatformFileWriterClient):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@148242 268f45cc-cd09-0410-ab3c-d52691b4dbfc

19 files changed:
Source/WebCore/ChangeLog
Source/WebCore/platform/blackberry/AsyncFileWriterBlackBerry.cpp [new file with mode: 0644]
Source/WebCore/platform/blackberry/AsyncFileWriterBlackBerry.h [new file with mode: 0644]
Source/WebCore/platform/blackberry/DOMFileSystemBlackBerry.cpp [new file with mode: 0644]
Source/WebCore/platform/blackberry/LocalFileSystemBlackBerry.cpp [new file with mode: 0644]
Source/WebCore/platform/blackberry/PlatformAsyncFileSystemCallbacks.cpp [new file with mode: 0644]
Source/WebCore/platform/blackberry/PlatformAsyncFileSystemCallbacks.h [new file with mode: 0644]
Source/WebCore/platform/blackberry/PlatformBlob.cpp [new file with mode: 0644]
Source/WebCore/platform/blackberry/PlatformBlob.h [new file with mode: 0644]
Source/WebCore/platform/blackberry/PlatformFileWriterClient.cpp [new file with mode: 0644]
Source/WebCore/platform/blackberry/PlatformFileWriterClient.h [new file with mode: 0644]
Source/WebCore/platform/blackberry/WorkerAsyncFileSystemBlackBerry.cpp [new file with mode: 0644]
Source/WebCore/platform/blackberry/WorkerAsyncFileSystemBlackBerry.h [new file with mode: 0644]
Source/WebCore/platform/blackberry/WorkerAsyncFileWriterBlackBerry.cpp [new file with mode: 0644]
Source/WebCore/platform/blackberry/WorkerAsyncFileWriterBlackBerry.h [new file with mode: 0644]
Source/WebCore/platform/blackberry/WorkerPlatformAsyncFileSystemCallbacks.cpp [new file with mode: 0644]
Source/WebCore/platform/blackberry/WorkerPlatformAsyncFileSystemCallbacks.h [new file with mode: 0644]
Source/WebCore/platform/blackberry/WorkerPlatformFileWriterClient.cpp [new file with mode: 0644]
Source/WebCore/platform/blackberry/WorkerPlatformFileWriterClient.h [new file with mode: 0644]

index d6b659d..13e28c1 100644 (file)
@@ -1,3 +1,148 @@
+2013-04-11  Alberto Garcia  <agarcia@igalia.com>
+
+        [BlackBerry] Upstream the filesystem code
+        https://bugs.webkit.org/show_bug.cgi?id=114437
+
+        Reviewed by Rob Buis.
+
+        This patch contains contributions from many members of the
+        BlackBerry WebKit team.
+
+        * platform/blackberry/AsyncFileWriterBlackBerry.cpp: Added.
+        (WebCore):
+        (WebCore::AsyncFileWriterBlackBerry::write):
+        * platform/blackberry/AsyncFileWriterBlackBerry.h: Added.
+        (WTF):
+        (WTF::BlackBerry::Platform::WebFileWriter):
+        (WebCore):
+        * platform/blackberry/DOMFileSystemBlackBerry.cpp: Added.
+        (WebCore):
+        (WebCore::DOMFileSystemBase::createFileSystemURL):
+        (WebCore::DOMFileSystemBase::crackFileSystemURL):
+        (WebCore::DOMFileSystemBase::supportsToURL):
+        (WebCore::DOMFileSystemBase::isValidType):
+        * platform/blackberry/LocalFileSystemBlackBerry.cpp: Added.
+        (WebCore):
+        (WebCore::fileSystemTypeString):
+        (WebCore::openFileSystem):
+        (WebCore::LocalFileSystem::deleteFileSystem):
+        (WebCore::LocalFileSystem::readFileSystem):
+        (WebCore::LocalFileSystem::requestFileSystem):
+        * platform/blackberry/PlatformAsyncFileSystemCallbacks.cpp: Added.
+        (WebCore):
+        (WebCore::PlatformAsyncFileSystemCallbacks::notifyOpenFileSystem):
+        (WebCore::PlatformAsyncFileSystemCallbacks::notifySucceed):
+        (WebCore::PlatformAsyncFileSystemCallbacks::notifyFail):
+        (WebCore::getFileMetadata):
+        (WebCore::PlatformAsyncFileSystemCallbacks::notifyReadMetadata):
+        (WebCore::PlatformAsyncFileSystemCallbacks::notifyCreateSnapshotFileAndReadMetadata):
+        (WebCore::PlatformAsyncFileSystemCallbacks::notifyReadDirectory):
+        (WebCore::PlatformAsyncFileSystemCallbacks::notifyCreateFileWriter):
+        (WebCore::PlatformAsyncFileSystemCallbacks::createAsyncFileSystem):
+        (WebCore::PlatformAsyncFileSystemCallbacks::createAsyncFileWriter):
+        (WebCore::PlatformAsyncFileSystemCallbacks::deleteMe):
+        * platform/blackberry/PlatformAsyncFileSystemCallbacks.h: Added.
+        (WebCore):
+        * platform/blackberry/PlatformBlob.cpp: Added.
+        (WebCore):
+        (WebCore::PlatformBlob::nextDataItem):
+        * platform/blackberry/PlatformBlob.h: Added.
+        (WebCore):
+        * platform/blackberry/PlatformFileWriterClient.cpp: Added.
+        (WebCore):
+        (WebCore::PlatformFileWriterClient::notifyWrite):
+        (WebCore::PlatformFileWriterClient::notifyTruncate):
+        (WebCore::PlatformFileWriterClient::notifyFail):
+        * platform/blackberry/PlatformFileWriterClient.h: Added.
+        (WebCore):
+        (WTF):
+        (WTF::WebCore::PlatformFileWriterClient):
+        * platform/blackberry/WorkerAsyncFileSystemBlackBerry.cpp: Added.
+        (WebCore):
+        (WebCore::WorkerAsyncFileSystemBlackBerry::WorkerAsyncFileSystemBlackBerry):
+        (WebCore::WorkerAsyncFileSystemBlackBerry::~WorkerAsyncFileSystemBlackBerry):
+        (WebCore::WorkerAsyncFileSystemBlackBerry::waitForOperationToComplete):
+        (WebCore::WorkerAsyncFileSystemBlackBerry::openFileSystemOnMainThread):
+        (WebCore::WorkerAsyncFileSystemBlackBerry::deleteFileSystemOnMainThread):
+        (WebCore::WorkerAsyncFileSystemBlackBerry::moveOnMainThread):
+        (WebCore::WorkerAsyncFileSystemBlackBerry::copyOnMainThread):
+        (WebCore::WorkerAsyncFileSystemBlackBerry::removeOnMainThread):
+        (WebCore::WorkerAsyncFileSystemBlackBerry::removeRecursivelyOnMainThread):
+        (WebCore::WorkerAsyncFileSystemBlackBerry::readMetadataOnMainThread):
+        (WebCore::WorkerAsyncFileSystemBlackBerry::createFileOnMainThread):
+        (WebCore::WorkerAsyncFileSystemBlackBerry::createDirectoryOnMainThread):
+        (WebCore::WorkerAsyncFileSystemBlackBerry::fileExistsOnMainThread):
+        (WebCore::WorkerAsyncFileSystemBlackBerry::directoryExistsOnMainThread):
+        (WebCore::WorkerAsyncFileSystemBlackBerry::readDirectoryOnMainThread):
+        (WebCore::WorkerAsyncFileSystemBlackBerry::createWriterOnMainThread):
+        (WebCore::WorkerAsyncFileSystemBlackBerry::createSnapshotFileAndReadMetadataOnMainThread):
+        (WebCore::WorkerAsyncFileSystemBlackBerry::openFileSystem):
+        (WebCore::WorkerAsyncFileSystemBlackBerry::deleteFileSystem):
+        (WebCore::WorkerAsyncFileSystemBlackBerry::move):
+        (WebCore::WorkerAsyncFileSystemBlackBerry::copy):
+        (WebCore::WorkerAsyncFileSystemBlackBerry::remove):
+        (WebCore::WorkerAsyncFileSystemBlackBerry::removeRecursively):
+        (WebCore::WorkerAsyncFileSystemBlackBerry::readMetadata):
+        (WebCore::WorkerAsyncFileSystemBlackBerry::createFile):
+        (WebCore::WorkerAsyncFileSystemBlackBerry::createDirectory):
+        (WebCore::WorkerAsyncFileSystemBlackBerry::fileExists):
+        (WebCore::WorkerAsyncFileSystemBlackBerry::directoryExists):
+        (WebCore::WorkerAsyncFileSystemBlackBerry::readDirectory):
+        (WebCore::WorkerAsyncFileSystemBlackBerry::createWriter):
+        (WebCore::WorkerAsyncFileSystemBlackBerry::createSnapshotFileAndReadMetadata):
+        * platform/blackberry/WorkerAsyncFileSystemBlackBerry.h: Added.
+        (WebCore):
+        (WorkerAsyncFileSystemBlackBerry):
+        (WebCore::WorkerAsyncFileSystemBlackBerry::create):
+        * platform/blackberry/WorkerAsyncFileWriterBlackBerry.cpp: Added.
+        (WebCore):
+        (WebCore::WorkerAsyncFileWriterBlackBerry::writeOnMainThread):
+        (WebCore::WorkerAsyncFileWriterBlackBerry::truncateOnMainThread):
+        (WebCore::WorkerAsyncFileWriterBlackBerry::abortOnMainThread):
+        (WebCore::WorkerAsyncFileWriterBlackBerry::write):
+        (WebCore::WorkerAsyncFileWriterBlackBerry::truncate):
+        (WebCore::WorkerAsyncFileWriterBlackBerry::abort):
+        (WebCore::WorkerAsyncFileWriterBlackBerry::waitForOperationToComplete):
+        (WebCore::WorkerAsyncFileWriterBlackBerry::platformWriterClient):
+        * platform/blackberry/WorkerAsyncFileWriterBlackBerry.h: Added.
+        (WebCore):
+        * platform/blackberry/WorkerPlatformAsyncFileSystemCallbacks.cpp: Added.
+        (WebCore):
+        (WebCore::performTaskOnMainThread):
+        (WebCore::postTaskToMainThread):
+        (WebCore::WorkerPlatformAsyncFileSystemCallbacks::notifyStop):
+        (WebCore::WorkerPlatformAsyncFileSystemCallbacks::notifyOpenFileSystem):
+        (WebCore::WorkerPlatformAsyncFileSystemCallbacks::notifySucceed):
+        (WebCore::WorkerPlatformAsyncFileSystemCallbacks::notifyFail):
+        (WebCore::WorkerPlatformAsyncFileSystemCallbacks::notifyReadMetadata):
+        (WebCore::WorkerPlatformAsyncFileSystemCallbacks::notifyReadDirectory):
+        (WebCore::WorkerPlatformAsyncFileSystemCallbacks::notifyCreateFileWriter):
+        (WebCore::WorkerPlatformAsyncFileSystemCallbacks::createAsyncFileSystem):
+        (WebCore::WorkerPlatformAsyncFileSystemCallbacks::createAsyncFileWriter):
+        (WebCore::WorkerPlatformAsyncFileSystemCallbacks::deleteMe):
+        (WebCore::WorkerPlatformAsyncFileSystemCallbacks::postTaskToWorkerThread):
+        (WebCore::WorkerPlatformAsyncFileSystemCallbacks::notifyOpenFileSystemOnWorkerThread):
+        (WebCore::WorkerPlatformAsyncFileSystemCallbacks::notifySucceedOnWorkerThread):
+        (WebCore::WorkerPlatformAsyncFileSystemCallbacks::notifyFailOnWorkerThread):
+        (WebCore::WorkerPlatformAsyncFileSystemCallbacks::notifyReadMetadataOnWorkerThread):
+        (WebCore::WorkerPlatformAsyncFileSystemCallbacks::notifyReadDirectoryEntryOnWorkerThread):
+        (WebCore::WorkerPlatformAsyncFileSystemCallbacks::notifyCreateFileWriterOnWorkerThread):
+        * platform/blackberry/WorkerPlatformAsyncFileSystemCallbacks.h: Added.
+        (WebCore):
+        * platform/blackberry/WorkerPlatformFileWriterClient.cpp: Added.
+        (WebCore):
+        (WebCore::WorkerPlatformFileWriterClient::notifyWriteOnWorkerThread):
+        (WebCore::WorkerPlatformFileWriterClient::notifyFailOnWorkerThread):
+        (WebCore::WorkerPlatformFileWriterClient::notifyTruncateOnWorkerThread):
+        (WebCore::WorkerPlatformFileWriterClient::notifyWrite):
+        (WebCore::WorkerPlatformFileWriterClient::notifyTruncate):
+        (WebCore::WorkerPlatformFileWriterClient::notifyFail):
+        (WebCore::WorkerPlatformFileWriterClient::postTaskToWorkerThreadIfNeeded):
+        * platform/blackberry/WorkerPlatformFileWriterClient.h: Added.
+        (WebCore):
+        (WTF):
+        (WTF::WebCore::WorkerPlatformFileWriterClient):
+
 2013-04-11  Ryosuke Niwa  <rniwa@webkit.org>
 
         Mac Lion build fix attempt after r148197.
diff --git a/Source/WebCore/platform/blackberry/AsyncFileWriterBlackBerry.cpp b/Source/WebCore/platform/blackberry/AsyncFileWriterBlackBerry.cpp
new file mode 100644 (file)
index 0000000..9d15e52
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * 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
+ */
+
+#include "config.h"
+#if ENABLE(FILE_SYSTEM)
+#include "AsyncFileWriterBlackBerry.h"
+
+#include "PlatformBlob.h"
+
+#include <wtf/text/CString.h>
+
+namespace WebCore {
+
+void AsyncFileWriterBlackBerry::write(long long position, Blob* blob)
+{
+    ASSERT(blob);
+
+    beginWriteOrTruncate();
+
+    // Platform writer will take the ownership of the platform blob and will destroy it on the thread in which we are running.
+    PlatformBlob* platformBlob = new PlatformBlob(blob);
+    m_platformWriter->write(position, platformBlob);
+}
+
+} // namespace WebCore
+#endif
diff --git a/Source/WebCore/platform/blackberry/AsyncFileWriterBlackBerry.h b/Source/WebCore/platform/blackberry/AsyncFileWriterBlackBerry.h
new file mode 100644 (file)
index 0000000..8a31c6a
--- /dev/null
@@ -0,0 +1,122 @@
+/*
+ * 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 AsyncFileWriterBlackBerry_h
+#define AsyncFileWriterBlackBerry_h
+
+#if ENABLE(FILE_SYSTEM)
+#include "AsyncFileWriter.h"
+#include "PlatformFileWriterClient.h"
+
+#include <BlackBerryPlatformWebFileSystemFileWriter.h>
+#include <wtf/Assertions.h>
+#include <wtf/OwnPtr.h>
+#include <wtf/PassOwnPtr.h>
+#include <wtf/RefPtr.h>
+
+namespace WTF {
+
+template <> inline void deleteOwnedPtr<BlackBerry::Platform::WebFileWriter>(BlackBerry::Platform::WebFileWriter* ptr)
+{
+    BlackBerry::Platform::deleteGuardedObject(ptr);
+}
+
+}
+
+namespace WebCore {
+
+class AsyncFileWriterBlackBerry: public AsyncFileWriter {
+public:
+    static PassOwnPtr<AsyncFileWriterBlackBerry> create(PassOwnPtr<BlackBerry::Platform::WebFileWriter> platformWriter, AsyncFileWriterClient* client)
+    {
+        return adoptPtr(new AsyncFileWriterBlackBerry(platformWriter, client));
+    }
+
+    virtual void write(long long position, Blob*);
+
+    virtual void truncate(long long length)
+    {
+        beginWriteOrTruncate();
+        m_platformWriter->truncate(length);
+    }
+
+    virtual void abort()
+    {
+        beginAbort();
+        m_platformWriter->abort();
+    }
+
+    virtual bool waitForOperationToComplete()
+    {
+        return m_platformWriter->waitForOperationToComplete();
+    }
+
+    bool isAborting() const
+    {
+        return m_isAborting;
+    }
+
+    bool isOperationInProgress() const
+    {
+        return m_isOperationInProgress;
+    }
+
+    void finishOperation()
+    {
+        m_isOperationInProgress = false;
+    }
+
+    virtual PlatformFileWriterClient* platformWriterClient()
+    {
+        if (!m_platformWriterClient)
+            m_platformWriterClient = PlatformFileWriterClient::create(m_client, this);
+        return m_platformWriterClient.get();
+    }
+
+protected:
+    AsyncFileWriterBlackBerry(PassOwnPtr<BlackBerry::Platform::WebFileWriter> platformWriter, AsyncFileWriterClient* client)
+        : m_platformWriter(platformWriter)
+        , m_client(client)
+        , m_isAborting(false)
+        , m_isOperationInProgress(false)
+    {
+    }
+
+    void beginWriteOrTruncate()
+    {
+        m_isAborting = false;
+        m_isOperationInProgress = true;
+    }
+
+    void beginAbort()
+    {
+        m_isAborting = true;
+        m_isOperationInProgress = true;
+    }
+
+    OwnPtr<BlackBerry::Platform::WebFileWriter> m_platformWriter;
+    OwnPtr<PlatformFileWriterClient> m_platformWriterClient;
+    AsyncFileWriterClient* m_client;
+    bool m_isAborting;
+    bool m_isOperationInProgress;
+};
+
+} // namespace WebCore
+#endif
+#endif
diff --git a/Source/WebCore/platform/blackberry/DOMFileSystemBlackBerry.cpp b/Source/WebCore/platform/blackberry/DOMFileSystemBlackBerry.cpp
new file mode 100644 (file)
index 0000000..c2a2b24
--- /dev/null
@@ -0,0 +1,92 @@
+/*
+ * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
+ * Copyright (C) 2012 Google Inc. 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
+ */
+
+#include "config.h"
+#if ENABLE(FILE_SYSTEM)
+#include "DOMFileSystem.h"
+
+#include "DOMFilePath.h"
+#include "ScriptExecutionContext.h"
+
+#include <wtf/text/WTFString.h>
+
+namespace WebCore {
+
+KURL DOMFileSystemBase::createFileSystemURL(const String& fullPath) const
+{
+    ASSERT(DOMFilePath::isAbsolute(fullPath));
+
+    // For regular types we can just append the entry's fullPath to the m_filesystemRootURL that should look like 'filesystem:<origin>/<typePrefix>'.
+    ASSERT(!m_filesystemRootURL.isEmpty());
+    return m_context->completeURL(m_filesystemRootURL.string() + encodeWithURLEscapeSequences(fullPath));
+}
+
+bool DOMFileSystemBase::crackFileSystemURL(const KURL& url, FileSystemType& type, String& filePath)
+{
+    if (!url.protocolIs("filesystem"))
+        return false;
+
+    if (url.innerURL()) {
+        String typeString = url.innerURL()->path().substring(1);
+        if (typeString == temporaryPathPrefix)
+            type = FileSystemTypeTemporary;
+        else if (typeString == persistentPathPrefix)
+            type = FileSystemTypePersistent;
+        else
+            return false;
+
+        filePath = decodeURLEscapeSequences(url.path());
+    } else {
+        KURL originURL(ParsedURLString, url.path());
+        String path = decodeURLEscapeSequences(originURL.path());
+        if (path.isEmpty() || path[0] != '/')
+            return false;
+        path = path.substring(1);
+
+        if (path.startsWith(temporaryPathPrefix)) {
+            type = FileSystemTypeTemporary;
+            path = path.substring(temporaryPathPrefixLength);
+        } else if (path.startsWith(persistentPathPrefix)) {
+            type = FileSystemTypePersistent;
+            path = path.substring(persistentPathPrefixLength);
+        } else
+            return false;
+
+        if (path.isEmpty() || path[0] != '/')
+            return false;
+
+        filePath.swap(path);
+    }
+    return true;
+}
+
+bool DOMFileSystemBase::supportsToURL() const
+{
+    return true;
+}
+
+bool DOMFileSystemBase::isValidType(FileSystemType type)
+{
+    return type == FileSystemTypeTemporary || type == FileSystemTypePersistent;
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(FILE_SYSTEM)
diff --git a/Source/WebCore/platform/blackberry/LocalFileSystemBlackBerry.cpp b/Source/WebCore/platform/blackberry/LocalFileSystemBlackBerry.cpp
new file mode 100644 (file)
index 0000000..f88447e
--- /dev/null
@@ -0,0 +1,149 @@
+/*
+ * 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
+ */
+
+#include "config.h"
+#if ENABLE(FILE_SYSTEM)
+#include "LocalFileSystem.h"
+
+#include "AsyncFileSystemBlackBerry.h"
+#include "AsyncFileSystemCallbacks.h"
+#include "Chrome.h"
+#include "ChromeClient.h"
+#include "CrossThreadTask.h"
+#include "DOMFileSystem.h"
+#include "Document.h"
+#include "ErrorCallback.h"
+#include "ExceptionCode.h"
+#include "FileError.h"
+#include "FileSystemCallback.h"
+#include "FileSystemCallbacks.h"
+#include "FileSystemType.h"
+#include "KURL.h"
+#include "Page.h"
+#include "PageClientBlackBerry.h"
+#include "SecurityOrigin.h"
+#include "Settings.h"
+#include "WorkerAsyncFileSystemBlackBerry.h"
+#include "WorkerContext.h"
+#include "WorkerThread.h"
+
+#include <wtf/MainThread.h>
+#include <wtf/PassRefPtr.h>
+#include <wtf/text/StringBuilder.h>
+#include <wtf/text/WTFString.h>
+
+namespace WebCore {
+
+#if ENABLE(WORKERS)
+static const char openFileSystemMode[] = "openFileSystemMode";
+static const char deleteFileSystemMode[] = "deleteFileSystemMode";
+#endif
+
+static const char* fileSystemTypeString(FileSystemType type)
+{
+    switch (type) {
+    case FileSystemTypePersistent:
+        return DOMFileSystemBase::persistentPathPrefix;
+    case FileSystemTypeTemporary:
+        return DOMFileSystemBase::temporaryPathPrefix;
+    case FileSystemTypeIsolated:
+        return DOMFileSystemBase::isolatedPathPrefix;
+    }
+    ASSERT_NOT_REACHED();
+    return 0;
+}
+
+static void openFileSystem(ScriptExecutionContext* context, const String& basePath, FileSystemType type, long long size, bool create, PassOwnPtr<AsyncFileSystemCallbacks> callbacks, FileSystemSynchronousType synchronousType)
+{
+    ASSERT(context);
+    ASSERT(type != FileSystemTypeIsolated);
+    if (type == FileSystemTypeIsolated)
+        return;
+
+    KURL url = context->url();
+    if (url.hasFragmentIdentifier())
+        url.removeFragmentIdentifier();
+    url.setQuery(String());
+    url.setPath("/");
+    StringBuilder builder;
+    builder.append("filesystem:");
+    builder.append(url.string());
+    builder.append(fileSystemTypeString(type));
+    KURL rootURL = context->completeURL(builder.toString());
+    ASSERT(rootURL.isValid());
+
+    // TODO: Ask user for file system permission.
+
+    if (context->isDocument()) {
+        int playerId = 0;
+        Page* page = static_cast<Document*>(context)->page();
+        if (page)
+            playerId = page->chrome()->client()->platformPageClient()->playerID();
+        AsyncFileSystemBlackBerry::openFileSystem(rootURL, basePath, context->securityOrigin()->databaseIdentifier(), type, size, create, playerId, callbacks);
+    } else {
+#if ENABLE(WORKERS)
+        WorkerContext* workerContext = static_cast<WorkerContext*>(context);
+        String mode = openFileSystemMode;
+        mode.append(String::number(workerContext->thread()->runLoop().createUniqueId()));
+        WorkerAsyncFileSystemBlackBerry::openFileSystem(workerContext, rootURL, mode, basePath, context->securityOrigin()->databaseIdentifier(), type, size, create, callbacks);
+        if (synchronousType == SynchronousFileSystem)
+            workerContext->thread()->runLoop().runInMode(workerContext, mode);
+#else
+        ASSERT_NOT_REACHED();
+#endif
+    }
+}
+
+void LocalFileSystem::deleteFileSystem(ScriptExecutionContext* context, FileSystemType type, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
+{
+    ASSERT(context);
+    ASSERT(type != FileSystemTypeIsolated);
+    if (type == FileSystemTypeIsolated)
+        return;
+
+    // TODO: Ask user for file system permission.
+
+    if (context->isDocument())
+        AsyncFileSystemBlackBerry::deleteFileSystem(fileSystemBasePath(), context->securityOrigin()->databaseIdentifier(), type, callbacks);
+    else {
+#if ENABLE(WORKERS)
+        WorkerContext* workerContext = static_cast<WorkerContext*>(context);
+        String mode = deleteFileSystemMode;
+        mode.append(String::number(workerContext->thread()->runLoop().createUniqueId()));
+        WorkerAsyncFileSystemBlackBerry::deleteFileSystem(workerContext, mode, fileSystemBasePath(), context->securityOrigin()->databaseIdentifier(), type, callbacks);
+#else
+        ASSERT_NOT_REACHED();
+#endif
+    }
+}
+
+
+void LocalFileSystem::readFileSystem(ScriptExecutionContext* context, FileSystemType type, PassOwnPtr<AsyncFileSystemCallbacks> callbacks, FileSystemSynchronousType synchronousType)
+{
+    openFileSystem(context, fileSystemBasePath(), type, 0, false, callbacks, synchronousType);
+}
+
+void LocalFileSystem::requestFileSystem(ScriptExecutionContext* context, FileSystemType type, long long size, PassOwnPtr<AsyncFileSystemCallbacks> callbacks, FileSystemSynchronousType synchronousType)
+{
+    openFileSystem(context, fileSystemBasePath(), type, size, true, callbacks, synchronousType);
+}
+
+} // namespace WebCore
+
+#endif
diff --git a/Source/WebCore/platform/blackberry/PlatformAsyncFileSystemCallbacks.cpp b/Source/WebCore/platform/blackberry/PlatformAsyncFileSystemCallbacks.cpp
new file mode 100644 (file)
index 0000000..1682689
--- /dev/null
@@ -0,0 +1,113 @@
+/*
+ * 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
+ */
+
+#include "config.h"
+#if ENABLE(FILE_SYSTEM)
+#include "PlatformAsyncFileSystemCallbacks.h"
+
+#include "Assertions.h"
+#include "AsyncFileSystem.h"
+#include "AsyncFileSystemBlackBerry.h"
+#include "AsyncFileWriterBlackBerry.h"
+#include "AsyncFileWriterClient.h"
+#include "FileError.h"
+#include "FileMetadata.h"
+
+#include <GuardedPointerDeleter.h>
+
+namespace WebCore {
+
+void PlatformAsyncFileSystemCallbacks::notifyOpenFileSystem(BlackBerry::Platform::WebFileSystem* platformFileSystem)
+{
+    ASSERT(platformFileSystem);
+    m_callbacks->didOpenFileSystem(String::fromUTF8(platformFileSystem->name().c_str()), m_rootURL, createAsyncFileSystem(adoptPtr(platformFileSystem)));
+    deleteMe();
+}
+
+void PlatformAsyncFileSystemCallbacks::notifySucceed()
+{
+    m_callbacks->didSucceed();
+    deleteMe();
+}
+
+void PlatformAsyncFileSystemCallbacks::notifyFail(BlackBerry::Platform::WebFileError error)
+{
+    m_callbacks->didFail(static_cast<FileError::ErrorCode>(error));
+    deleteMe();
+}
+
+static inline void getFileMetadata(const BlackBerry::Platform::WebFileInfo& fileInfo, FileMetadata& fileMetadata)
+{
+    fileMetadata.modificationTime = fileInfo.m_modificationTime;
+    fileMetadata.length = fileInfo.m_length;
+    fileMetadata.type = static_cast<FileMetadata::Type>(fileInfo.m_type);
+    fileMetadata.platformPath = String::fromUTF8(fileInfo.m_platformPath.c_str());
+}
+
+void PlatformAsyncFileSystemCallbacks::notifyReadMetadata(const BlackBerry::Platform::WebFileInfo& fileInfo)
+{
+    FileMetadata fileMetadata;
+    getFileMetadata(fileInfo, fileMetadata);
+    m_callbacks->didReadMetadata(fileMetadata);
+    deleteMe();
+}
+
+void PlatformAsyncFileSystemCallbacks::notifyCreateSnapshotFileAndReadMetadata(const BlackBerry::Platform::WebFileInfo& fileInfo)
+{
+    FileMetadata fileMetadata;
+    getFileMetadata(fileInfo, fileMetadata);
+    m_callbacks->didCreateSnapshotFile(fileMetadata, 0);
+    deleteMe();
+}
+
+void PlatformAsyncFileSystemCallbacks::notifyReadDirectory(const std::vector<BlackBerry::Platform::WebFileSystemEntry>& entries, bool hasMore)
+{
+    for (size_t i = 0; i < entries.size(); ++i)
+        m_callbacks->didReadDirectoryEntry(String::fromUTF8(entries[i].m_name.c_str()), entries[i].m_isDirectory);
+    m_callbacks->didReadDirectoryEntries(hasMore);
+    deleteMe();
+}
+
+void PlatformAsyncFileSystemCallbacks::notifyCreateFileWriter(BlackBerry::Platform::WebFileWriter* platformWriter, long long length)
+{
+    m_callbacks->didCreateFileWriter(createAsyncFileWriter(adoptPtr(platformWriter)), length);
+    deleteMe();
+}
+
+PassOwnPtr<AsyncFileSystem> PlatformAsyncFileSystemCallbacks::createAsyncFileSystem(PassOwnPtr<BlackBerry::Platform::WebFileSystem> platformFileSystem)
+{
+    return AsyncFileSystemBlackBerry::create(platformFileSystem);
+}
+
+PassOwnPtr<AsyncFileWriter> PlatformAsyncFileSystemCallbacks::createAsyncFileWriter(PassOwnPtr<BlackBerry::Platform::WebFileWriter> platformWriter)
+{
+    ASSERT(m_writerClient);
+    BlackBerry::Platform::WebFileWriter* platformWriterPtr = platformWriter.get();
+    OwnPtr<AsyncFileWriterBlackBerry> writer = AsyncFileWriterBlackBerry::create(platformWriter, m_writerClient);
+    platformWriterPtr->setClient(writer->platformWriterClient());
+    return writer.release();
+}
+
+void PlatformAsyncFileSystemCallbacks::deleteMe()
+{
+    BlackBerry::Platform::GuardedPointerDeleter::deleteOnThread(BlackBerry::Platform::webKitThreadMessageClient(), this);
+}
+
+} // namespace WebCore
+#endif
diff --git a/Source/WebCore/platform/blackberry/PlatformAsyncFileSystemCallbacks.h b/Source/WebCore/platform/blackberry/PlatformAsyncFileSystemCallbacks.h
new file mode 100644 (file)
index 0000000..1afb5f5
--- /dev/null
@@ -0,0 +1,78 @@
+/*
+ * 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 PlatformAsyncFileSystemCallbacks_h
+#define PlatformAsyncFileSystemCallbacks_h
+
+#if ENABLE(FILE_SYSTEM)
+#include "AsyncFileSystemCallbacks.h"
+#include "KURL.h"
+
+#include <BlackBerryPlatformWebFileSystem.h>
+#include <wtf/OwnPtr.h>
+#include <wtf/PassOwnPtr.h>
+#include <wtf/text/WTFString.h>
+
+namespace WebCore {
+
+String platformFileSystemTypeToString(BlackBerry::Platform::WebFileSystem::Type);
+
+class AsyncFileSystem;
+class AsyncFileWriter;
+class AsyncFileWriterClient;
+
+class PlatformAsyncFileSystemCallbacks: public BlackBerry::Platform::WebFileSystemCallbacks {
+public:
+    PlatformAsyncFileSystemCallbacks(PassOwnPtr<AsyncFileSystemCallbacks> callbacks, const KURL& rootURL = KURL())
+        : m_callbacks(callbacks)
+        , m_writerClient(0)
+        , m_rootURL(rootURL)
+    {
+    }
+
+    // For createWriter.
+    PlatformAsyncFileSystemCallbacks(PassOwnPtr<AsyncFileSystemCallbacks> callbacks, AsyncFileWriterClient* client)
+        : m_callbacks(callbacks)
+        , m_writerClient(client)
+    {
+    }
+
+    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 void deleteMe();
+    virtual PassOwnPtr<AsyncFileSystem> createAsyncFileSystem(PassOwnPtr<BlackBerry::Platform::WebFileSystem> platformFileSystem);
+    virtual PassOwnPtr<AsyncFileWriter> createAsyncFileWriter(PassOwnPtr<BlackBerry::Platform::WebFileWriter> platformWriter);
+
+protected:
+    ~PlatformAsyncFileSystemCallbacks() { }
+    OwnPtr<AsyncFileSystemCallbacks> m_callbacks;
+    AsyncFileWriterClient* m_writerClient;
+
+private:
+    KURL m_rootURL;
+};
+
+} // namespace WebCore
+#endif
+#endif
diff --git a/Source/WebCore/platform/blackberry/PlatformBlob.cpp b/Source/WebCore/platform/blackberry/PlatformBlob.cpp
new file mode 100644 (file)
index 0000000..28a2123
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * 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
+ */
+
+#include "config.h"
+#if ENABLE(FILE_SYSTEM)
+#include "PlatformBlob.h"
+
+namespace WebCore {
+
+BlackBerry::Platform::WebBlobDataItem* PlatformBlob::nextDataItem()
+{
+    if (!m_blobData || m_currentItem >= m_blobData->items().size())
+        return 0;
+
+    const BlobDataItem& item = m_blobData->items()[m_currentItem++];
+    ASSERT(item.type == BlobDataItem::Data || item.type == BlobDataItem::File);
+    m_platformBlobItem.m_isData = item.type == BlobDataItem::Data;
+    m_platformBlobItem.m_buffer = m_platformBlobItem.m_isData ? item.data->data() + static_cast<int>(item.offset) : 0;
+    m_platformBlobItem.m_bufferLength = m_platformBlobItem.m_isData ? static_cast<size_t>(item.length) : 0;
+    m_platformBlobItem.m_fileName = m_platformBlobItem.m_isData ? std::string() : item.path.utf8().data();
+    m_platformBlobItem.m_fileStart = m_platformBlobItem.m_isData ? 0 : item.offset;
+    m_platformBlobItem.m_fileLength = m_platformBlobItem.m_isData ? 0 : item.length;
+    m_platformBlobItem.m_expectedFileModificationTime = m_platformBlobItem.m_isData ? BlackBerry::Platform::WebBlobDataItem::DONOTCHECKFILECHANGE : item.expectedModificationTime;
+
+    return &m_platformBlobItem;
+}
+
+} // namespace WebCore
+#endif
diff --git a/Source/WebCore/platform/blackberry/PlatformBlob.h b/Source/WebCore/platform/blackberry/PlatformBlob.h
new file mode 100644 (file)
index 0000000..ff4cd03
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ * 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 PlatformBlob_h
+#define PlatformBlob_h
+
+#if ENABLE(FILE_SYSTEM)
+#include "Assertions.h"
+#include "Blob.h"
+#include "BlobRegistryImpl.h"
+#include "BlobStorageData.h"
+
+#include <BlackBerryPlatformWebFileSystemFileWriter.h>
+#include <wtf/RefPtr.h>
+
+namespace WebCore {
+
+class Blob;
+
+class PlatformBlob: public BlackBerry::Platform::WebBlob {
+public:
+    PlatformBlob(Blob* blob)
+        : m_currentItem(0)
+    {
+        ASSERT(blob);
+        m_blobData = static_cast<BlobRegistryImpl&>(blobRegistry()).getBlobDataFromURL(blob->url());
+    }
+
+    virtual BlackBerry::Platform::WebBlobDataItem* nextDataItem();
+
+private:
+    RefPtr<BlobStorageData> m_blobData;
+    BlackBerry::Platform::WebBlobDataItem m_platformBlobItem;
+    unsigned long long m_currentItem;
+};
+
+} // namespace WebCore
+#endif
+#endif
diff --git a/Source/WebCore/platform/blackberry/PlatformFileWriterClient.cpp b/Source/WebCore/platform/blackberry/PlatformFileWriterClient.cpp
new file mode 100644 (file)
index 0000000..a80c949
--- /dev/null
@@ -0,0 +1,65 @@
+/*
+ * 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
+ */
+#include "config.h"
+#if ENABLE(FILE_SYSTEM)
+#include "PlatformFileWriterClient.h"
+
+#include "AsyncFileWriterBlackBerry.h"
+#include "AsyncFileWriterClient.h"
+
+namespace WebCore {
+
+void PlatformFileWriterClient::notifyWrite(long long bytes, bool complete)
+{
+    if (m_writer->isAborting())
+        return;
+
+    if (complete)
+        m_writer->finishOperation();
+    m_client->didWrite(bytes, complete);
+}
+
+void PlatformFileWriterClient::notifyTruncate()
+{
+    if (m_writer->isAborting())
+        return;
+
+    m_writer->finishOperation();
+    m_client->didTruncate();
+}
+
+void PlatformFileWriterClient::notifyFail(BlackBerry::Platform::WebFileError error)
+{
+    if (m_writer->isAborting() && error != BlackBerry::Platform::WebFileErrorAbort)
+        return;
+
+    // We don't reset m_isAborting unitl new operations (write, truncate) arrive.
+    // notifyFail for abort may not be called because the platform writer may be
+    // in successful state for a previous operation (write or truncate) but the
+    // notification hasn't arrived in the thread we are running in. So if we reset
+    // m_isAborting here and ASSERT(!m_isAborting) in other operations we could hit
+    // the ASSERT because m_isAborting may not be reset.
+
+    m_writer->finishOperation();
+    m_client->didFail(static_cast<FileError::ErrorCode>(error));
+}
+
+}
+
+#endif
diff --git a/Source/WebCore/platform/blackberry/PlatformFileWriterClient.h b/Source/WebCore/platform/blackberry/PlatformFileWriterClient.h
new file mode 100644 (file)
index 0000000..182b645
--- /dev/null
@@ -0,0 +1,68 @@
+/*
+ * 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 PlatformFileWriterClient_h
+#define PlatformFileWriterClient_h
+
+#if ENABLE(FILE_SYSTEM)
+#include <BlackBerryPlatformWebFileSystemFileWriter.h>
+#include <wtf/PassOwnPtr.h>
+
+namespace WebCore {
+
+class AsyncFileWriterBlackBerry;
+class AsyncFileWriterClient;
+
+class PlatformFileWriterClient: public BlackBerry::Platform::WebFileWriterClient {
+public:
+    static PassOwnPtr<PlatformFileWriterClient> create(AsyncFileWriterClient* client, AsyncFileWriterBlackBerry* writer)
+    {
+        return adoptPtr(new PlatformFileWriterClient(client, writer));
+    }
+
+    virtual void notifyWrite(long long bytes, bool complete);
+    virtual void notifyTruncate();
+    virtual void notifyFail(BlackBerry::Platform::WebFileError);
+
+protected:
+    PlatformFileWriterClient(AsyncFileWriterClient* client, AsyncFileWriterBlackBerry* writer)
+        : m_client(client)
+        , m_writer(writer)
+    { }
+
+    ~PlatformFileWriterClient() { }
+
+private:
+    AsyncFileWriterClient* m_client;
+    AsyncFileWriterBlackBerry* m_writer;
+};
+
+} // namespace WebCore
+
+namespace WTF {
+
+template <> inline void deleteOwnedPtr<WebCore::PlatformFileWriterClient>(WebCore::PlatformFileWriterClient* ptr)
+{
+    BlackBerry::Platform::deleteGuardedObject(ptr);
+}
+
+}
+
+#endif
+#endif
diff --git a/Source/WebCore/platform/blackberry/WorkerAsyncFileSystemBlackBerry.cpp b/Source/WebCore/platform/blackberry/WorkerAsyncFileSystemBlackBerry.cpp
new file mode 100644 (file)
index 0000000..2b8f59f
--- /dev/null
@@ -0,0 +1,205 @@
+/*
+ * 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
+ */
+
+#include "config.h"
+#if ENABLE(FILE_SYSTEM) && ENABLE(WORKERS)
+#include "WorkerAsyncFileSystemBlackBerry.h"
+
+#include "AsyncFileSystemCallbacks.h"
+#include "AsyncFileWriterClient.h"
+#include "CrossThreadTask.h"
+#include "WorkerAsyncFileWriterBlackBerry.h"
+#include "WorkerContext.h"
+#include "WorkerLoaderProxy.h"
+#include "WorkerPlatformAsyncFileSystemCallbacks.h"
+#include "WorkerThread.h"
+
+#include <BlackBerryPlatformMessageClient.h>
+#include <wtf/MainThread.h>
+#include <wtf/text/CString.h>
+#include <wtf/text/StringBuilder.h>
+
+using BlackBerry::Platform::WebFileSystem;
+using BlackBerry::Platform::WebFileWriter;
+using BlackBerry::Platform::webKitThreadMessageClient;
+
+namespace WebCore {
+
+WorkerAsyncFileSystemBlackBerry::WorkerAsyncFileSystemBlackBerry(WorkerContext* context, const String& mode, PassOwnPtr<WebFileSystem> platformFileSystem)
+    : AsyncFileSystemBlackBerry(platformFileSystem)
+    , m_context(context)
+    , m_mode(mode)
+{
+}
+
+WorkerAsyncFileSystemBlackBerry::~WorkerAsyncFileSystemBlackBerry()
+{
+}
+
+bool WorkerAsyncFileSystemBlackBerry::waitForOperationToComplete()
+{
+    if (m_context->thread()->runLoop().runInMode(m_context, m_mode) == MessageQueueTerminated)
+        return false;
+    return true;
+}
+
+void WorkerAsyncFileSystemBlackBerry::openFileSystemOnMainThread(ScriptExecutionContext*, const String& basePath, const String& storageIdentifier, FileSystemType type, long long size, bool create, WorkerPlatformAsyncFileSystemCallbacks* callbacks)
+{
+    WebFileSystem::openFileSystem(webKitThreadMessageClient(), basePath.utf8().data(), storageIdentifier.utf8().data(), static_cast<WebFileSystem::Type>(type), size, create, callbacks, 0);
+}
+
+void WorkerAsyncFileSystemBlackBerry::deleteFileSystemOnMainThread(ScriptExecutionContext*, const String& basePath, const String& storageIdentifier, FileSystemType type, WorkerPlatformAsyncFileSystemCallbacks* callbacks)
+{
+    WebFileSystem::deleteFileSystem(webKitThreadMessageClient(), basePath.utf8().data(), storageIdentifier.utf8().data(), static_cast<WebFileSystem::Type>(type), callbacks);
+}
+
+void WorkerAsyncFileSystemBlackBerry::moveOnMainThread(ScriptExecutionContext*, WebFileSystem* platformFileSystem, const KURL& sourcePath, const KURL& destinationPath, WorkerPlatformAsyncFileSystemCallbacks* callbacks)
+{
+    platformFileSystem->move(fileSystemURLToPath(sourcePath).utf8().data(), fileSystemURLToPath(destinationPath).utf8().data(), callbacks);
+}
+
+void WorkerAsyncFileSystemBlackBerry::copyOnMainThread(ScriptExecutionContext*, WebFileSystem* platformFileSystem, const KURL& sourcePath, const KURL& destinationPath, WorkerPlatformAsyncFileSystemCallbacks* callbacks)
+{
+    platformFileSystem->copy(fileSystemURLToPath(sourcePath).utf8().data(), fileSystemURLToPath(destinationPath).utf8().data(), callbacks);
+}
+
+void WorkerAsyncFileSystemBlackBerry::removeOnMainThread(ScriptExecutionContext*, WebFileSystem* platformFileSystem, const KURL& path, WorkerPlatformAsyncFileSystemCallbacks* callbacks)
+{
+    platformFileSystem->remove(fileSystemURLToPath(path).utf8().data(), callbacks);
+}
+
+void WorkerAsyncFileSystemBlackBerry::removeRecursivelyOnMainThread(ScriptExecutionContext*, WebFileSystem* platformFileSystem, const KURL& path, WorkerPlatformAsyncFileSystemCallbacks* callbacks)
+{
+    platformFileSystem->removeRecursively(fileSystemURLToPath(path).utf8().data(), callbacks);
+}
+
+void WorkerAsyncFileSystemBlackBerry::readMetadataOnMainThread(ScriptExecutionContext*, WebFileSystem* platformFileSystem, const KURL& path, WorkerPlatformAsyncFileSystemCallbacks* callbacks)
+{
+    platformFileSystem->readMetadata(fileSystemURLToPath(path).utf8().data(), callbacks);
+}
+
+void WorkerAsyncFileSystemBlackBerry::createFileOnMainThread(ScriptExecutionContext*, WebFileSystem* platformFileSystem, const KURL& path, bool exclusive, WorkerPlatformAsyncFileSystemCallbacks* callbacks)
+{
+    platformFileSystem->createFile(fileSystemURLToPath(path).utf8().data(), exclusive, callbacks);
+}
+
+void WorkerAsyncFileSystemBlackBerry::createDirectoryOnMainThread(ScriptExecutionContext*, WebFileSystem* platformFileSystem, const KURL& path, bool exclusive, WorkerPlatformAsyncFileSystemCallbacks* callbacks)
+{
+    platformFileSystem->createDirectory(fileSystemURLToPath(path).utf8().data(), exclusive, callbacks);
+}
+
+void WorkerAsyncFileSystemBlackBerry::fileExistsOnMainThread(ScriptExecutionContext*, WebFileSystem* platformFileSystem, const KURL& path, WorkerPlatformAsyncFileSystemCallbacks* callbacks)
+{
+    platformFileSystem->fileExists(fileSystemURLToPath(path).utf8().data(), callbacks);
+}
+
+void WorkerAsyncFileSystemBlackBerry::directoryExistsOnMainThread(ScriptExecutionContext*, WebFileSystem* platformFileSystem, const KURL& path, WorkerPlatformAsyncFileSystemCallbacks* callbacks)
+{
+    platformFileSystem->directoryExists(fileSystemURLToPath(path).utf8().data(), callbacks);
+}
+
+void WorkerAsyncFileSystemBlackBerry::readDirectoryOnMainThread(ScriptExecutionContext*, WebFileSystem* platformFileSystem, const KURL& path, WorkerPlatformAsyncFileSystemCallbacks* callbacks)
+{
+    platformFileSystem->readDirectory(fileSystemURLToPath(path).utf8().data(), callbacks);
+}
+
+void WorkerAsyncFileSystemBlackBerry::createWriterOnMainThread(ScriptExecutionContext*, WebFileSystem* platformFileSystem, AsyncFileWriterClient* client, const KURL& path, WorkerPlatformAsyncFileSystemCallbacks* callbacks)
+{
+    WebFileWriter::createWriter(platformFileSystem, fileSystemURLToPath(path).utf8().data(), callbacks);
+}
+
+void WorkerAsyncFileSystemBlackBerry::createSnapshotFileAndReadMetadataOnMainThread(ScriptExecutionContext*, WebFileSystem* platformFileSystem, const KURL& path, WorkerPlatformAsyncFileSystemCallbacks* callbacks)
+{
+    platformFileSystem->createSnapshotFileAndReadMetadata(fileSystemURLToPath(path).utf8().data(), callbacks);
+}
+
+void WorkerAsyncFileSystemBlackBerry::openFileSystem(WorkerContext* context, const KURL& rootURL, const String& mode, const String& basePath, const String& storageIdentifier, FileSystemType type, long long size, bool create, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
+{
+    ASSERT(context);
+    postTaskToMainThread(createCallbackTask(&WorkerAsyncFileSystemBlackBerry::openFileSystemOnMainThread, basePath, storageIdentifier, type, size, create, new WorkerPlatformAsyncFileSystemCallbacks(callbacks, context, mode, rootURL)));
+}
+
+void WorkerAsyncFileSystemBlackBerry::deleteFileSystem(WorkerContext* context, const String& mode, const String& basePath, const String& storageIdentifier, FileSystemType type, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
+{
+    ASSERT(context);
+    postTaskToMainThread(createCallbackTask(&WorkerAsyncFileSystemBlackBerry::deleteFileSystemOnMainThread, basePath, storageIdentifier, type, new WorkerPlatformAsyncFileSystemCallbacks(callbacks, context, mode)));
+}
+
+void WorkerAsyncFileSystemBlackBerry::move(const KURL& sourcePath, const KURL& destinationPath, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
+{
+    postTaskToMainThread(createCallbackTask(&WorkerAsyncFileSystemBlackBerry::moveOnMainThread, m_platformFileSystem.get(), sourcePath, destinationPath, new WorkerPlatformAsyncFileSystemCallbacks(callbacks, m_context, m_mode)));
+}
+
+void WorkerAsyncFileSystemBlackBerry::copy(const KURL& sourcePath, const KURL& destinationPath, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
+{
+    postTaskToMainThread(createCallbackTask(&WorkerAsyncFileSystemBlackBerry::copyOnMainThread, m_platformFileSystem.get(), sourcePath, destinationPath, new WorkerPlatformAsyncFileSystemCallbacks(callbacks, m_context, m_mode)));
+}
+
+void WorkerAsyncFileSystemBlackBerry::remove(const KURL& path, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
+{
+    postTaskToMainThread(createCallbackTask(&WorkerAsyncFileSystemBlackBerry::removeOnMainThread, m_platformFileSystem.get(), path, new WorkerPlatformAsyncFileSystemCallbacks(callbacks, m_context, m_mode)));
+}
+
+void WorkerAsyncFileSystemBlackBerry::removeRecursively(const KURL& path, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
+{
+    postTaskToMainThread(createCallbackTask(&WorkerAsyncFileSystemBlackBerry::removeRecursivelyOnMainThread, m_platformFileSystem.get(), path, new WorkerPlatformAsyncFileSystemCallbacks(callbacks, m_context, m_mode)));
+}
+
+void WorkerAsyncFileSystemBlackBerry::readMetadata(const KURL& path, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
+{
+    postTaskToMainThread(createCallbackTask(&WorkerAsyncFileSystemBlackBerry::readMetadataOnMainThread, m_platformFileSystem.get(), path, new WorkerPlatformAsyncFileSystemCallbacks(callbacks, m_context, m_mode)));
+}
+
+void WorkerAsyncFileSystemBlackBerry::createFile(const KURL& path, bool exclusive, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
+{
+    postTaskToMainThread(createCallbackTask(&WorkerAsyncFileSystemBlackBerry::createFileOnMainThread, m_platformFileSystem.get(), path, exclusive, new WorkerPlatformAsyncFileSystemCallbacks(callbacks, m_context, m_mode)));
+}
+
+void WorkerAsyncFileSystemBlackBerry::createDirectory(const KURL& path, bool exclusive, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
+{
+    postTaskToMainThread(createCallbackTask(&WorkerAsyncFileSystemBlackBerry::createDirectoryOnMainThread, m_platformFileSystem.get(), path, exclusive, new WorkerPlatformAsyncFileSystemCallbacks(callbacks, m_context, m_mode)));
+}
+
+void WorkerAsyncFileSystemBlackBerry::fileExists(const KURL& path, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
+{
+    postTaskToMainThread(createCallbackTask(&WorkerAsyncFileSystemBlackBerry::fileExistsOnMainThread, m_platformFileSystem.get(), path, new WorkerPlatformAsyncFileSystemCallbacks(callbacks, m_context, m_mode)));
+}
+
+void WorkerAsyncFileSystemBlackBerry::directoryExists(const KURL& path, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
+{
+    postTaskToMainThread(createCallbackTask(&WorkerAsyncFileSystemBlackBerry::directoryExistsOnMainThread, m_platformFileSystem.get(), path, new WorkerPlatformAsyncFileSystemCallbacks(callbacks, m_context, m_mode)));
+}
+
+void WorkerAsyncFileSystemBlackBerry::readDirectory(const KURL& path, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
+{
+    postTaskToMainThread(createCallbackTask(&WorkerAsyncFileSystemBlackBerry::readDirectoryOnMainThread, m_platformFileSystem.get(), path, new WorkerPlatformAsyncFileSystemCallbacks(callbacks, m_context, m_mode)));
+}
+
+void WorkerAsyncFileSystemBlackBerry::createWriter(AsyncFileWriterClient* client, const KURL& path, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
+{
+    postTaskToMainThread(createCallbackTask(&WorkerAsyncFileSystemBlackBerry::createWriterOnMainThread, m_platformFileSystem.get(), client, path, new WorkerPlatformAsyncFileSystemCallbacks(callbacks, client, m_context, m_mode)));
+}
+
+void WorkerAsyncFileSystemBlackBerry::createSnapshotFileAndReadMetadata(const KURL& path, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
+{
+    postTaskToMainThread(createCallbackTask(&WorkerAsyncFileSystemBlackBerry::createSnapshotFileAndReadMetadataOnMainThread, m_platformFileSystem.get(), path, new WorkerPlatformAsyncFileSystemCallbacks(callbacks, m_context, m_mode)));
+}
+
+} // namespace WebCore
+#endif // ENABLE(FILE_SYSTEM) && ENABLE(WORKERS)
diff --git a/Source/WebCore/platform/blackberry/WorkerAsyncFileSystemBlackBerry.h b/Source/WebCore/platform/blackberry/WorkerAsyncFileSystemBlackBerry.h
new file mode 100644 (file)
index 0000000..7c14298
--- /dev/null
@@ -0,0 +1,86 @@
+/*
+ * 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 WorkerAsyncFileSystemBlackBerry_h
+#define WorkerAsyncFileSystemBlackBerry_h
+
+#if ENABLE(FILE_SYSTEM) && ENABLE(WORKERS)
+#include "AsyncFileSystemBlackBerry.h"
+
+#include "FileSystemType.h"
+
+#include <wtf/PassOwnPtr.h>
+#include <wtf/text/WTFString.h>
+
+namespace WebCore {
+
+class ScriptExecutionContext;
+class WorkerPlatformAsyncFileSystemCallbacks;
+class WorkerContext;
+
+class WorkerAsyncFileSystemBlackBerry : public AsyncFileSystemBlackBerry {
+public:
+    static PassOwnPtr<WorkerAsyncFileSystemBlackBerry> create(WorkerContext* context, const String& mode, PassOwnPtr<BlackBerry::Platform::WebFileSystem> platformFileSystem)
+    {
+        return adoptPtr(new WorkerAsyncFileSystemBlackBerry(context, mode, platformFileSystem));
+    }
+
+    static void openFileSystem(WorkerContext*, const KURL& rootURL, const String& mode, const String& basePath, const String& storageIdentifier, FileSystemType, long long size, bool create, PassOwnPtr<AsyncFileSystemCallbacks>);
+    static void deleteFileSystem(WorkerContext*, const String& mode, const String& basePath, const String& storageIdentifier, FileSystemType, PassOwnPtr<AsyncFileSystemCallbacks>);
+    virtual ~WorkerAsyncFileSystemBlackBerry();
+    virtual bool waitForOperationToComplete();
+    virtual void move(const KURL& sourcePath, const KURL& destinationPath, PassOwnPtr<AsyncFileSystemCallbacks>);
+    virtual void copy(const KURL& sourcePath, const KURL& destinationPath, PassOwnPtr<AsyncFileSystemCallbacks>);
+    virtual void remove(const KURL& path, PassOwnPtr<AsyncFileSystemCallbacks>);
+    virtual void removeRecursively(const KURL& path, PassOwnPtr<AsyncFileSystemCallbacks>);
+    virtual void readMetadata(const KURL& path, PassOwnPtr<AsyncFileSystemCallbacks>);
+    virtual void createFile(const KURL& path, bool exclusive, PassOwnPtr<AsyncFileSystemCallbacks>);
+    virtual void createDirectory(const KURL& path, bool exclusive, PassOwnPtr<AsyncFileSystemCallbacks>);
+    virtual void fileExists(const KURL& path, PassOwnPtr<AsyncFileSystemCallbacks>);
+    virtual void directoryExists(const KURL& path, PassOwnPtr<AsyncFileSystemCallbacks>);
+    virtual void readDirectory(const KURL& path, PassOwnPtr<AsyncFileSystemCallbacks>);
+    virtual void createWriter(AsyncFileWriterClient*, const KURL& path, PassOwnPtr<AsyncFileSystemCallbacks>);
+    virtual void createSnapshotFileAndReadMetadata(const KURL& path, PassOwnPtr<AsyncFileSystemCallbacks>);
+
+private:
+    WorkerAsyncFileSystemBlackBerry(WorkerContext*, const String& mode, PassOwnPtr<BlackBerry::Platform::WebFileSystem> platformFileSystem);
+    static void openFileSystemOnMainThread(ScriptExecutionContext*, const String& basePath, const String& storageIdentifier, FileSystemType, long long size, bool create, WorkerPlatformAsyncFileSystemCallbacks*);
+    static void deleteFileSystemOnMainThread(ScriptExecutionContext*, const String& basePath, const String& storageIdentifier, FileSystemType, WorkerPlatformAsyncFileSystemCallbacks*);
+    static void moveOnMainThread(ScriptExecutionContext*, BlackBerry::Platform::WebFileSystem*, const KURL& sourcePath, const KURL& destinationPath, WorkerPlatformAsyncFileSystemCallbacks*);
+    static void copyOnMainThread(ScriptExecutionContext*, BlackBerry::Platform::WebFileSystem*, const KURL& sourcePath, const KURL& destinationPath, WorkerPlatformAsyncFileSystemCallbacks*);
+    static void removeOnMainThread(ScriptExecutionContext*, BlackBerry::Platform::WebFileSystem*, const KURL& path, WorkerPlatformAsyncFileSystemCallbacks*);
+    static void removeRecursivelyOnMainThread(ScriptExecutionContext*, BlackBerry::Platform::WebFileSystem*, const KURL& path, WorkerPlatformAsyncFileSystemCallbacks*);
+    static void readMetadataOnMainThread(ScriptExecutionContext*, BlackBerry::Platform::WebFileSystem*, const KURL& path, WorkerPlatformAsyncFileSystemCallbacks*);
+    static void createFileOnMainThread(ScriptExecutionContext*, BlackBerry::Platform::WebFileSystem*, const KURL& path, bool exclusive, WorkerPlatformAsyncFileSystemCallbacks*);
+    static void createDirectoryOnMainThread(ScriptExecutionContext*, BlackBerry::Platform::WebFileSystem*, const KURL& path, bool exclusive, WorkerPlatformAsyncFileSystemCallbacks*);
+    static void fileExistsOnMainThread(ScriptExecutionContext*, BlackBerry::Platform::WebFileSystem*, const KURL& path, WorkerPlatformAsyncFileSystemCallbacks*);
+    static void directoryExistsOnMainThread(ScriptExecutionContext*, BlackBerry::Platform::WebFileSystem*, const KURL& path, WorkerPlatformAsyncFileSystemCallbacks*);
+    static void readDirectoryOnMainThread(ScriptExecutionContext*, BlackBerry::Platform::WebFileSystem*, const KURL& path, WorkerPlatformAsyncFileSystemCallbacks*);
+    static void createWriterOnMainThread(ScriptExecutionContext*, BlackBerry::Platform::WebFileSystem*, AsyncFileWriterClient*, const KURL& path, WorkerPlatformAsyncFileSystemCallbacks*);
+    static void createSnapshotFileAndReadMetadataOnMainThread(ScriptExecutionContext*, BlackBerry::Platform::WebFileSystem*, const KURL& path, WorkerPlatformAsyncFileSystemCallbacks*);
+
+    WorkerContext* m_context;
+    String m_mode;
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(FILE_SYSTEM) && ENABLE(WORKERS)
+
+#endif // WorkerAsyncFileSystemBlackBerry_h
diff --git a/Source/WebCore/platform/blackberry/WorkerAsyncFileWriterBlackBerry.cpp b/Source/WebCore/platform/blackberry/WorkerAsyncFileWriterBlackBerry.cpp
new file mode 100644 (file)
index 0000000..17e3e97
--- /dev/null
@@ -0,0 +1,88 @@
+/*
+ * 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
+ */
+
+#include "config.h"
+#if ENABLE(FILE_SYSTEM) && ENABLE(WORKERS)
+#include "WorkerAsyncFileWriterBlackBerry.h"
+
+#include "CrossThreadCopier.h"
+#include "CrossThreadTask.h"
+#include "PlatformBlob.h"
+#include "WorkerPlatformAsyncFileSystemCallbacks.h"
+#include "WorkerPlatformFileWriterClient.h"
+#include "WorkerThread.h"
+
+#include <wtf/OwnPtr.h>
+#include <wtf/PassOwnPtr.h>
+#include <wtf/RefPtr.h>
+#include <wtf/text/CString.h>
+
+namespace WebCore {
+
+void WorkerAsyncFileWriterBlackBerry::writeOnMainThread(ScriptExecutionContext*, BlackBerry::Platform::WebFileWriter* platformWriter, long long position, Blob* blob)
+{
+    platformWriter->write(position, new PlatformBlob(blob));
+}
+
+void WorkerAsyncFileWriterBlackBerry::truncateOnMainThread(ScriptExecutionContext*, BlackBerry::Platform::WebFileWriter* platformWriter, long long length)
+{
+    platformWriter->truncate(length);
+}
+
+void WorkerAsyncFileWriterBlackBerry::abortOnMainThread(ScriptExecutionContext*, BlackBerry::Platform::WebFileWriter* platformWriter)
+{
+    platformWriter->abort();
+}
+
+void WorkerAsyncFileWriterBlackBerry::write(long long position, Blob* blob)
+{
+    beginWriteOrTruncate();
+    postTaskToMainThread(createCallbackTask(&WorkerAsyncFileWriterBlackBerry::writeOnMainThread, m_platformWriter.get(), position, blob));
+}
+
+void WorkerAsyncFileWriterBlackBerry::truncate(long long length)
+{
+    beginWriteOrTruncate();
+    postTaskToMainThread(createCallbackTask(&WorkerAsyncFileWriterBlackBerry::truncateOnMainThread, m_platformWriter.get(), length));
+}
+
+void WorkerAsyncFileWriterBlackBerry::abort()
+{
+    beginAbort();
+    postTaskToMainThread(createCallbackTask(&WorkerAsyncFileWriterBlackBerry::abortOnMainThread, m_platformWriter.get()));
+}
+
+bool WorkerAsyncFileWriterBlackBerry::waitForOperationToComplete()
+{
+    while (m_isOperationInProgress) {
+        if (m_context->thread()->runLoop().runInMode(m_context, m_mode) == MessageQueueTerminated)
+            return false;
+    }
+    return true;
+}
+
+PlatformFileWriterClient* WorkerAsyncFileWriterBlackBerry::platformWriterClient()
+{
+    if (!m_platformWriterClient)
+        m_platformWriterClient = WorkerPlatformFileWriterClient::create(m_context, m_mode, m_client, this);
+    return m_platformWriterClient.get();
+}
+
+} // namespace WebCore
+#endif
diff --git a/Source/WebCore/platform/blackberry/WorkerAsyncFileWriterBlackBerry.h b/Source/WebCore/platform/blackberry/WorkerAsyncFileWriterBlackBerry.h
new file mode 100644 (file)
index 0000000..cc3296e
--- /dev/null
@@ -0,0 +1,68 @@
+/*
+ * 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 WorkerAsyncFileWriterBlackBerry_h
+#define WorkerAsyncFileWriterBlackBerry_h
+
+#if ENABLE(FILE_SYSTEM) && ENABLE(WORKERS)
+#include "AsyncFileWriterBlackBerry.h"
+
+#include <BlackBerryPlatformWebFileSystemFileWriter.h>
+#include <wtf/Assertions.h>
+#include <wtf/OwnPtr.h>
+#include <wtf/PassOwnPtr.h>
+#include <wtf/text/WTFString.h>
+
+namespace WebCore {
+
+class ScriptExecutionContext;
+class WorkerContext;
+
+class WorkerAsyncFileWriterBlackBerry: public AsyncFileWriterBlackBerry {
+public:
+    static PassOwnPtr<WorkerAsyncFileWriterBlackBerry> create(WorkerContext* context, const String& mode, PassOwnPtr<BlackBerry::Platform::WebFileWriter> platformWriter, AsyncFileWriterClient* client)
+    {
+        return adoptPtr(new WorkerAsyncFileWriterBlackBerry(context, mode, platformWriter, client));
+    }
+
+    virtual void write(long long position, Blob*);
+    virtual void truncate(long long length);
+    virtual void abort();
+    virtual bool waitForOperationToComplete();
+    virtual PlatformFileWriterClient* platformWriterClient();
+
+private:
+    WorkerAsyncFileWriterBlackBerry(WorkerContext* context, const String& mode, PassOwnPtr<BlackBerry::Platform::WebFileWriter> platformWriter, AsyncFileWriterClient* client)
+        : AsyncFileWriterBlackBerry(platformWriter, client)
+        , m_context(context)
+        , m_mode(mode)
+    {
+    }
+
+    static void writeOnMainThread(ScriptExecutionContext*, BlackBerry::Platform::WebFileWriter* platformWriter, long long position, Blob*);
+    static void truncateOnMainThread(ScriptExecutionContext*, BlackBerry::Platform::WebFileWriter* platformWriter, long long length);
+    static void abortOnMainThread(ScriptExecutionContext*, BlackBerry::Platform::WebFileWriter* platformWriter);
+
+    WorkerContext* m_context;
+    String m_mode;
+};
+
+} // namespace WebCore
+#endif
+#endif
diff --git a/Source/WebCore/platform/blackberry/WorkerPlatformAsyncFileSystemCallbacks.cpp b/Source/WebCore/platform/blackberry/WorkerPlatformAsyncFileSystemCallbacks.cpp
new file mode 100644 (file)
index 0000000..b8b59c8
--- /dev/null
@@ -0,0 +1,214 @@
+/*
+ * 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
+ */
+
+#include "config.h"
+#if ENABLE(FILE_SYSTEM) && ENABLE(WORKERS)
+#include "WorkerPlatformAsyncFileSystemCallbacks.h"
+
+#include "CrossThreadTask.h"
+#include "WorkerAsyncFileSystemBlackBerry.h"
+#include "WorkerAsyncFileWriterBlackBerry.h"
+#include "WorkerContext.h"
+#include "WorkerLoaderProxy.h"
+#include "WorkerThread.h"
+
+#include <wtf/MainThread.h>
+
+namespace WebCore {
+
+static void performTaskOnMainThread(void* context)
+{
+    OwnPtr<ScriptExecutionContext::Task> task = adoptPtr(static_cast<ScriptExecutionContext::Task*>(context));
+    task->performTask(0);
+}
+
+void postTaskToMainThread(PassOwnPtr<ScriptExecutionContext::Task> task)
+{
+    callOnMainThread(&performTaskOnMainThread, task.leakPtr());
+}
+
+template<> struct CrossThreadCopierBase<false, false, BlackBerry::Platform::WebFileInfo> {
+    typedef BlackBerry::Platform::WebFileInfo Type;
+    static Type copy(const Type& info)
+    {
+        Type result;
+        result.m_modificationTime = info.m_modificationTime;
+        result.m_length = info.m_length;
+        result.m_type = info.m_type;
+        result.m_platformPath = info.m_platformPath;
+        return result;
+    }
+};
+
+template <> struct CrossThreadCopierBase<false, false, std::vector<BlackBerry::Platform::WebFileSystemEntry> > {
+    typedef std::vector<BlackBerry::Platform::WebFileSystemEntry> Type;
+    static Type copy(const Type& entries)
+    {
+        Type result(entries.size());
+        for (size_t i = 0; i < entries.size(); ++i) {
+            result[i].m_name = entries[i].m_name;
+            result[i].m_isDirectory = entries[i].m_isDirectory;
+        }
+        return result;
+    }
+};
+
+void WorkerPlatformAsyncFileSystemCallbacks::notifyStop()
+{
+    m_callbacks.clear();
+    {
+        WTF::MutexLocker locker(m_mutex);
+        m_context = 0;
+    }
+}
+
+void WorkerPlatformAsyncFileSystemCallbacks::notifyOpenFileSystem(BlackBerry::Platform::WebFileSystem* platformFileSystem)
+{
+    m_mutex.lock();
+    if (!m_context) {
+        m_mutex.unlock();
+        PlatformAsyncFileSystemCallbacks::deleteMe();
+        return;
+    }
+
+    postTaskToWorkerThread(createCallbackTask(&notifyOpenFileSystemOnWorkerThread, this, platformFileSystem));
+    m_mutex.unlock();
+}
+
+void WorkerPlatformAsyncFileSystemCallbacks::notifySucceed()
+{
+    m_mutex.lock();
+    if (!m_context) {
+        m_mutex.unlock();
+        PlatformAsyncFileSystemCallbacks::deleteMe();
+        return;
+    }
+
+    postTaskToWorkerThread(createCallbackTask(&notifySucceedOnWorkerThread, this));
+    m_mutex.unlock();
+}
+
+void WorkerPlatformAsyncFileSystemCallbacks::notifyFail(BlackBerry::Platform::WebFileError error)
+{
+    m_mutex.lock();
+    if (!m_context) {
+        m_mutex.unlock();
+        PlatformAsyncFileSystemCallbacks::deleteMe();
+        return;
+    }
+
+    postTaskToWorkerThread(createCallbackTask(&notifyFailOnWorkerThread, this, error));
+    m_mutex.unlock();
+}
+
+void WorkerPlatformAsyncFileSystemCallbacks::notifyReadMetadata(const BlackBerry::Platform::WebFileInfo& fileInfo)
+{
+    m_mutex.lock();
+    if (!m_context) {
+        m_mutex.unlock();
+        PlatformAsyncFileSystemCallbacks::deleteMe();
+        return;
+    }
+
+    postTaskToWorkerThread(createCallbackTask(&notifyReadMetadataOnWorkerThread, this, fileInfo));
+    m_mutex.unlock();
+}
+
+void WorkerPlatformAsyncFileSystemCallbacks::notifyReadDirectory(const std::vector<BlackBerry::Platform::WebFileSystemEntry>& entries, bool hasMore)
+{
+    m_mutex.lock();
+    if (!m_context) {
+        m_mutex.unlock();
+        PlatformAsyncFileSystemCallbacks::deleteMe();
+        return;
+    }
+
+    postTaskToWorkerThread(createCallbackTask(&notifyReadDirectoryEntryOnWorkerThread, this, entries, hasMore));
+    m_mutex.unlock();
+}
+
+void WorkerPlatformAsyncFileSystemCallbacks::notifyCreateFileWriter(BlackBerry::Platform::WebFileWriter* platformWriter, long long length)
+{
+    m_mutex.lock();
+    if (!m_context) {
+        m_mutex.unlock();
+        PlatformAsyncFileSystemCallbacks::deleteMe();
+        return;
+    }
+
+    postTaskToWorkerThread(createCallbackTask(&notifyCreateFileWriterOnWorkerThread, this, platformWriter, length));
+    m_mutex.unlock();
+}
+
+PassOwnPtr<AsyncFileSystem> WorkerPlatformAsyncFileSystemCallbacks::createAsyncFileSystem(PassOwnPtr<BlackBerry::Platform::WebFileSystem> platformFileSystem)
+{
+    return WorkerAsyncFileSystemBlackBerry::create(m_context, m_mode, platformFileSystem);
+}
+
+PassOwnPtr<AsyncFileWriter> WorkerPlatformAsyncFileSystemCallbacks::createAsyncFileWriter(PassOwnPtr<BlackBerry::Platform::WebFileWriter> platformWriter)
+{
+    ASSERT(m_writerClient);
+    BlackBerry::Platform::WebFileWriter* platformWriterPtr = platformWriter.get();
+    OwnPtr<WorkerAsyncFileWriterBlackBerry> writer = WorkerAsyncFileWriterBlackBerry::create(m_context, m_mode, platformWriter, m_writerClient);
+    platformWriterPtr->setClient(writer->platformWriterClient());
+    return writer.release();
+}
+
+void WorkerPlatformAsyncFileSystemCallbacks::deleteMe()
+{
+    deleteGuardedObject(this);
+}
+
+void WorkerPlatformAsyncFileSystemCallbacks::postTaskToWorkerThread(PassOwnPtr<ScriptExecutionContext::Task> task)
+{
+    m_context->thread()->workerLoaderProxy().postTaskForModeToWorkerContext(task, m_mode);
+}
+
+void WorkerPlatformAsyncFileSystemCallbacks::notifyOpenFileSystemOnWorkerThread(ScriptExecutionContext*, WorkerPlatformAsyncFileSystemCallbacks* callbacks, BlackBerry::Platform::WebFileSystem* platformFileSystem)
+{
+    callbacks->PlatformAsyncFileSystemCallbacks::notifyOpenFileSystem(platformFileSystem);
+}
+
+void WorkerPlatformAsyncFileSystemCallbacks::notifySucceedOnWorkerThread(ScriptExecutionContext*, WorkerPlatformAsyncFileSystemCallbacks* callbacks)
+{
+    callbacks->PlatformAsyncFileSystemCallbacks::notifySucceed();
+}
+
+void WorkerPlatformAsyncFileSystemCallbacks::notifyFailOnWorkerThread(ScriptExecutionContext*, WorkerPlatformAsyncFileSystemCallbacks* callbacks, BlackBerry::Platform::WebFileError error)
+{
+    callbacks->PlatformAsyncFileSystemCallbacks::notifyFail(error);
+}
+
+void WorkerPlatformAsyncFileSystemCallbacks::notifyReadMetadataOnWorkerThread(ScriptExecutionContext*, WorkerPlatformAsyncFileSystemCallbacks* callbacks, const BlackBerry::Platform::WebFileInfo& fileInfo)
+{
+    callbacks->PlatformAsyncFileSystemCallbacks::notifyReadMetadata(fileInfo);
+}
+
+void WorkerPlatformAsyncFileSystemCallbacks::notifyReadDirectoryEntryOnWorkerThread(ScriptExecutionContext*, WorkerPlatformAsyncFileSystemCallbacks* callbacks, const std::vector<BlackBerry::Platform::WebFileSystemEntry>& entries, bool hasMore)
+{
+    callbacks->PlatformAsyncFileSystemCallbacks::notifyReadDirectory(entries, hasMore);
+}
+
+void WorkerPlatformAsyncFileSystemCallbacks::notifyCreateFileWriterOnWorkerThread(ScriptExecutionContext*, WorkerPlatformAsyncFileSystemCallbacks* callbacks, BlackBerry::Platform::WebFileWriter* platformWriter, long long length)
+{
+    callbacks->PlatformAsyncFileSystemCallbacks::notifyCreateFileWriter(platformWriter, length);
+}
+
+} // namespace WebCore
+#endif
diff --git a/Source/WebCore/platform/blackberry/WorkerPlatformAsyncFileSystemCallbacks.h b/Source/WebCore/platform/blackberry/WorkerPlatformAsyncFileSystemCallbacks.h
new file mode 100644 (file)
index 0000000..f2c0946
--- /dev/null
@@ -0,0 +1,110 @@
+/*
+ * 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 "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)
+    {
+    }
+
+    // For createWriter.
+    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>);
+
+    // From WorkerContext::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 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 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;
+};
+
+} // namespace WebCore
+#endif
+#endif
diff --git a/Source/WebCore/platform/blackberry/WorkerPlatformFileWriterClient.cpp b/Source/WebCore/platform/blackberry/WorkerPlatformFileWriterClient.cpp
new file mode 100644 (file)
index 0000000..f05d081
--- /dev/null
@@ -0,0 +1,77 @@
+/*
+ * 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
+ */
+#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(&notifyWriteOnWorkerThread, this, bytes, complete));
+}
+
+void WorkerPlatformFileWriterClient::notifyTruncate()
+{
+    postTaskToWorkerThreadIfNeeded(createCallbackTask(&notifyTruncateOnWorkerThread, this));
+}
+
+void WorkerPlatformFileWriterClient::notifyFail(BlackBerry::Platform::WebFileError error)
+{
+    postTaskToWorkerThreadIfNeeded(createCallbackTask(&notifyFailOnWorkerThread, 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
diff --git a/Source/WebCore/platform/blackberry/WorkerPlatformFileWriterClient.h b/Source/WebCore/platform/blackberry/WorkerPlatformFileWriterClient.h
new file mode 100644 (file)
index 0000000..5bd0ad5
--- /dev/null
@@ -0,0 +1,86 @@
+/*
+ * 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 WorkerPlatformFileWriterClient_h
+#define WorkerPlatformFileWriterClient_h
+
+#if ENABLE(FILE_SYSTEM) && ENABLE(WORKERS)
+#include "PlatformFileWriterClient.h"
+#include "ScriptExecutionContext.h"
+#include "WorkerAsyncFileWriterBlackBerry.h"
+#include "WorkerContext.h"
+
+#include <wtf/PassOwnPtr.h>
+#include <wtf/Threading.h>
+#include <wtf/text/WTFString.h>
+
+namespace WebCore {
+
+class WorkerContext;
+
+class WorkerPlatformFileWriterClient: public PlatformFileWriterClient, public WorkerContext::Observer {
+public:
+    static PassOwnPtr<WorkerPlatformFileWriterClient> create(WorkerContext* context, const String& mode, AsyncFileWriterClient* client, WorkerAsyncFileWriterBlackBerry* writer)
+    {
+        return adoptPtr(new WorkerPlatformFileWriterClient(context, mode, client, writer));
+    }
+
+    virtual void notifyWrite(long long bytes, bool complete);
+    virtual void notifyTruncate();
+    virtual void notifyFail(BlackBerry::Platform::WebFileError);
+
+    // From WorkerContext::Observer
+    virtual void notifyStop()
+    {
+        WTF::MutexLocker locker(m_mutex);
+        m_context = 0;
+    }
+
+private:
+    WorkerPlatformFileWriterClient(WorkerContext* context, const String& mode, AsyncFileWriterClient* client, WorkerAsyncFileWriterBlackBerry* writer)
+        : PlatformFileWriterClient(client, writer)
+        , WorkerContext::Observer(context)
+        , m_context(context)
+        , m_mode(mode)
+    { }
+    ~WorkerPlatformFileWriterClient() { }
+    void postTaskToWorkerThreadIfNeeded(PassOwnPtr<ScriptExecutionContext::Task>);
+
+    static void notifyWriteOnWorkerThread(ScriptExecutionContext*, WorkerPlatformFileWriterClient* platformClient, long long bytes, bool complete);
+    static void notifyFailOnWorkerThread(ScriptExecutionContext*, WorkerPlatformFileWriterClient* platformClient, BlackBerry::Platform::WebFileError);
+    static void notifyTruncateOnWorkerThread(ScriptExecutionContext*, WorkerPlatformFileWriterClient* platformClient);
+
+    WorkerContext* m_context;
+    String m_mode;
+    WTF::Mutex m_mutex;
+};
+
+} // namespace WebCore
+
+namespace WTF {
+
+template <> inline void deleteOwnedPtr<WebCore::WorkerPlatformFileWriterClient>(WebCore::WorkerPlatformFileWriterClient* ptr)
+{
+    BlackBerry::Platform::deleteGuardedObject(ptr);
+}
+
+}
+
+#endif
+#endif