Changeset 68222 in webkit


Ignore:
Timestamp:
Sep 23, 2010 5:46:01 PM (14 years ago)
Author:
kinuko@chromium.org
Message:

2010-09-23 Kinuko Yasuda <kinuko@chromium.org>

Reviewed by David Levin.

Add Worker support for FileSystem API
https://bugs.webkit.org/show_bug.cgi?id=45808

Added WebWorkerBase::openFileSystem and WebCommonWorkerClient::
openFileSystem to call in to the browser via Worker stub/proxy
in the chromium.

Also added WorkerFileSystemCallbacksBridge class that proxies
requests and callbacks between from/to worker thread to/from the
main thread.

  • public/WebCommonWorkerClient.h: (WebKit::WebCommonWorkerClient::openFileSystem): Added.
  • src/LocalFileSystemChromium.cpp: (WebCore::LocalFileSystem::localFileSystem): Added. (WebCore::LocalFileSystem::requestFileSystem): Added implementation for workers. In worker case this calls WebWorkerBase::openFileSystem.
  • src/WebWorkerBase.cpp: (WebKit::WebWorkerBase::openFileSystem): Added. This is called from LocalFileSystem::requestFileSystem on the worker thread and creates a bridge to call WebCommonWorkerClient::openFileSystem on the main thread.
  • src/WebWorkerBase.h:
  • src/WebWorkerClientImpl.h: (WebKit::WebWorkerClientImpl::openFileSystem): Added.
  • src/WorkerFileSystemCallbacksBridge.cpp: Added.
  • src/WorkerFileSystemCallbacksBridge.h: Added.

2010-09-23 Kinuko Yasuda <kinuko@chromium.org>

Reviewed by David Levin.

Add Worker support for FileSystem API
https://bugs.webkit.org/show_bug.cgi?id=45808

Exposed requestFileSystem and Flags constructor on worker contexts.

Also changed how to get the base path for Web file systems (in
non-chromium ports) so that it works for workers too.
This patch assumes each port calls
LocalFileSystem::initializeLocalFileSystem() in its initialization
phase.

No new tests; tests will be added when we have complete implementation.

  • bindings/generic/RuntimeEnabledFeatures.cpp: (WebCore::RuntimeEnabledFeatures::fileSystemEnabled): Changed to reflect AsyncFileSystem::isAvailable
  • bindings/generic/RuntimeEnabledFeatures.h: Moved the implementation of fileSystemEnabled to .cpp.
  • fileapi/LocalFileSystem.cpp: (WebCore::LocalFileSystem::initializeLocalFileSystem): Added. (WebCore::LocalFileSystem::localFileSystem): Added. (WebCore::LocalFileSystem::fileSystemBasePath): Added.
  • fileapi/LocalFileSystem.h: (WebCore::LocalFileSystem::~LocalFileSystem): Removed. (As now it's going to be used as a singleton.)
  • page/DOMWindow.cpp: (WebCore::DOMWindow::requestFileSystem): Changed to use a singleton instance of LocalFileSystem.
  • page/SecurityOrigin.h: (WebCore::SecurityOrigin::canAccessFileSystem): Added.
  • page/Settings.cpp: Removed fileSystemRootPath method.
  • page/Settings.h: Removed fileSystemRootPath method.
  • platform/AsyncFileSystem.cpp: (WebCore::AsyncFileSystem::isAvailable): Added.
  • workers/WorkerContext.cpp: (WebCore::WorkerContext::requestFileSystem): Added to expose requestFileSystem method in worker contexts. (WebCore::WorkerContext::Observer): Added. (WebCore::WorkerContext::registerObserver): Added. (WebCore::WorkerContext::unregisterObserver): Added. (WebCore::WorkerContext::notifyObserversOfStop): Added.
  • workers/WorkerContext.h:
  • workers/WorkerContext.idl:
  • workers/WorkerThread.cpp: (WebCore::WorkerThreadShutdownStartTask::performTask): Modified to call workerContext->notifyObserversOfStop to notify worker observers of the worker thread termination.
Location:
trunk
Files:
2 added
24 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r68221 r68222  
     12010-09-23  Kinuko Yasuda  <kinuko@chromium.org>
     2
     3        Reviewed by David Levin.
     4
     5        Add Worker support for FileSystem API
     6        https://bugs.webkit.org/show_bug.cgi?id=45808
     7
     8        Exposed requestFileSystem and Flags constructor on worker contexts.
     9
     10        Also changed how to get the base path for Web file systems (in
     11        non-chromium ports) so that it works for workers too.
     12        This patch assumes each port calls
     13        LocalFileSystem::initializeLocalFileSystem() in its initialization
     14        phase.
     15
     16        No new tests; tests will be added when we have complete implementation.
     17
     18        * bindings/generic/RuntimeEnabledFeatures.cpp:
     19        (WebCore::RuntimeEnabledFeatures::fileSystemEnabled): Changed to
     20        reflect AsyncFileSystem::isAvailable
     21        * bindings/generic/RuntimeEnabledFeatures.h: Moved the implementation
     22        of fileSystemEnabled to .cpp.
     23        * fileapi/LocalFileSystem.cpp:
     24        (WebCore::LocalFileSystem::initializeLocalFileSystem): Added.
     25        (WebCore::LocalFileSystem::localFileSystem): Added.
     26        (WebCore::LocalFileSystem::fileSystemBasePath): Added.
     27        * fileapi/LocalFileSystem.h:
     28        (WebCore::LocalFileSystem::~LocalFileSystem): Removed. (As now it's
     29        going to be used as a singleton.)
     30        * page/DOMWindow.cpp:
     31        (WebCore::DOMWindow::requestFileSystem): Changed to use a singleton
     32        instance of LocalFileSystem.
     33        * page/SecurityOrigin.h:
     34        (WebCore::SecurityOrigin::canAccessFileSystem): Added.
     35        * page/Settings.cpp: Removed fileSystemRootPath method.
     36        * page/Settings.h: Removed fileSystemRootPath method.
     37        * platform/AsyncFileSystem.cpp:
     38        (WebCore::AsyncFileSystem::isAvailable): Added.
     39        * workers/WorkerContext.cpp:
     40        (WebCore::WorkerContext::requestFileSystem): Added to expose
     41        requestFileSystem method in worker contexts.
     42        (WebCore::WorkerContext::Observer): Added.
     43        (WebCore::WorkerContext::registerObserver): Added.
     44        (WebCore::WorkerContext::unregisterObserver): Added.
     45        (WebCore::WorkerContext::notifyObserversOfStop): Added.
     46        * workers/WorkerContext.h:
     47        * workers/WorkerContext.idl:
     48        * workers/WorkerThread.cpp:
     49        (WebCore::WorkerThreadShutdownStartTask::performTask): Modified to
     50        call workerContext->notifyObserversOfStop to notify worker observers
     51        of the worker thread termination.
     52
    1532010-09-23  Matthew Delaney  <mdelaney@apple.com>
    254
  • trunk/WebCore/bindings/generic/RuntimeEnabledFeatures.cpp

    r66570 r68222  
    3737#include "WebSocket.h"
    3838
     39#if ENABLE(FILE_SYSTEM)
     40#include "AsyncFileSystem.h"
     41#endif
     42
    3943namespace WebCore {
    4044
     
    5862#if ENABLE(FILE_SYSTEM)
    5963bool RuntimeEnabledFeatures::isFileSystemEnabled = false;
     64
     65bool RuntimeEnabledFeatures::fileSystemEnabled()
     66{
     67    return isFileSystemEnabled && AsyncFileSystem::isAvailable();
     68}
    6069#endif
    6170
  • trunk/WebCore/bindings/generic/RuntimeEnabledFeatures.h

    r66802 r68222  
    149149
    150150#if ENABLE(FILE_SYSTEM)
    151     static bool fileSystemEnabled() { return isFileSystemEnabled; }
     151    static bool fileSystemEnabled();
    152152    static void setFileSystemEnabled(bool isEnabled) { isFileSystemEnabled = isEnabled; }
    153153    static bool requestFileSystemEnabled() { return isFileSystemEnabled; }
  • trunk/WebCore/fileapi/LocalFileSystem.cpp

    r66586 r68222  
    5151namespace WebCore {
    5252
    53 PassRefPtr<LocalFileSystem> LocalFileSystem::create(const String& basePath)
     53LocalFileSystem* LocalFileSystem::s_instance = 0;
     54
     55void LocalFileSystem::initializeLocalFileSystem(const String& basePath)
    5456{
    55     return adoptRef(new LocalFileSystem(basePath));
     57    // FIXME: Should initialize the quota settings as well.
     58    ASSERT(isMainThread());
     59    ASSERT(!s_instance);
     60    if (s_instance)
     61        return;
     62
     63    OwnPtr<LocalFileSystem> localFileSystem = adoptPtr(new LocalFileSystem(basePath));
     64    s_instance = localFileSystem.leakPtr();
     65}
     66
     67LocalFileSystem& LocalFileSystem::localFileSystem()
     68{
     69    // initializeLocalFileSystem must be called prior calling this.
     70    ASSERT(s_instance);
     71    return *s_instance;
     72}
     73
     74String LocalFileSystem::fileSystemBasePath() const
     75{
     76    return m_basePath;
    5677}
    5778
     
    6990
    7091    // AsyncFileSystem::openFileSystem calls callbacks synchronously, so the method needs to be called asynchronously.
    71     context->postTask(createCallbackTask(&openFileSystem, m_basePath, context->securityOrigin()->databaseIdentifier(), type, new FileSystemCallbacks(successCallback, errorCallback, context)));
     92    context->postTask(createCallbackTask(&openFileSystem, fileSystemBasePath(), context->securityOrigin()->databaseIdentifier(), type, new FileSystemCallbacks(successCallback, errorCallback, context)));
    7293}
    7394
  • trunk/WebCore/fileapi/LocalFileSystem.h

    r66586 r68222  
    4545class ScriptExecutionContext;
    4646
    47 class LocalFileSystem : public RefCounted<LocalFileSystem> {
     47// Keeps per-process information and provides an entry point to open a file system.
     48class LocalFileSystem : public Noncopyable {
    4849public:
    49     static PassRefPtr<LocalFileSystem> create(const String& basePath);
    50     virtual ~LocalFileSystem() { }
     50    // Returns a per-process instance of LocalFileSystem.
     51    // Note that LocalFileSystem::initializeLocalFileSystem must be called before
     52    // calling this one.
     53    static LocalFileSystem& localFileSystem();
    5154
    5255    void requestFileSystem(ScriptExecutionContext*, AsyncFileSystem::Type, long long size, PassRefPtr<FileSystemCallback>, PassRefPtr<ErrorCallback>);
    5356
    54 protected:
     57#if !PLATFORM(CHROMIUM)
     58    // This call is not thread-safe; must be called before any worker threads are created.
     59    void initializeLocalFileSystem(const String&);
     60
     61    String fileSystemBasePath() const;
     62#endif
     63
     64private:
    5565    LocalFileSystem(const String& basePath)
    5666        : m_basePath(basePath)
     
    5868    }
    5969
    60     String m_basePath;
     70    static LocalFileSystem* s_instance;
     71
     72    // An inner class that enforces thread-safe string access.
     73    class SystemBasePath {
     74    public:
     75        explicit SystemBasePath(const String& path) : m_value(path) { }
     76        operator String() const
     77        {
     78            return m_value.threadsafeCopy();
     79        }
     80    private:
     81        String m_value;
     82    };
     83
     84    SystemBasePath m_basePath;
    6185};
    6286
  • trunk/WebCore/page/DOMWindow.cpp

    r67762 r68222  
    728728        return;
    729729
    730     if (!m_localFileSystem) {
    731         // FIXME: See if access is allowed.
    732 
    733         Page* page = document->page();
    734         if (!page) {
    735             DOMFileSystem::scheduleCallback(document, errorCallback, FileError::create(INVALID_STATE_ERR));
    736             return;
    737         }
    738 
    739         // FIXME: Get the quota settings as well.
    740         String path = page->settings()->fileSystemRootPath();
    741         m_localFileSystem = LocalFileSystem::create(path);
    742     }
    743 
    744     m_localFileSystem->requestFileSystem(document, static_cast<AsyncFileSystem::Type>(type), size, successCallback, errorCallback);
    745 }
    746 
    747 COMPILE_ASSERT(int(DOMWindow::TEMPORARY) == int(AsyncFileSystem::Temporary), enum_mismatch);
    748 COMPILE_ASSERT(int(DOMWindow::PERSISTENT) == int(AsyncFileSystem::Persistent), enum_mismatch);
     730    if (!AsyncFileSystem::isAvailable() || !document->securityOrigin()->canAccessFileSystem()) {
     731        DOMFileSystem::scheduleCallback(document, errorCallback, FileError::create(SECURITY_ERR));
     732        return;
     733    }
     734
     735    LocalFileSystem::localFileSystem().requestFileSystem(document, static_cast<AsyncFileSystem::Type>(type), size, successCallback, errorCallback);
     736}
     737
     738COMPILE_ASSERT(static_cast<int>(DOMWindow::TEMPORARY) == static_cast<int>(AsyncFileSystem::Temporary), enum_mismatch);
     739COMPILE_ASSERT(static_cast<int>(DOMWindow::PERSISTENT) == static_cast<int>(AsyncFileSystem::Persistent), enum_mismatch);
    749740
    750741#endif
  • trunk/WebCore/page/DOMWindow.h

    r66802 r68222  
    5959    class IDBFactory;
    6060    class InspectorTimelineAgent;
    61     class LocalFileSystem;
    6261    class Location;
    6362    class StyleMedia;
     
    445444        mutable RefPtr<IDBFactory> m_idbFactory;
    446445#endif
    447 #if ENABLE(FILE_SYSTEM)
    448         RefPtr<LocalFileSystem> m_localFileSystem;
    449 #endif
    450446
    451447        EventTargetData m_eventTargetData;
  • trunk/WebCore/page/SecurityOrigin.h

    r67316 r68222  
    122122    bool canAccessCookies() const { return !isUnique(); }
    123123    bool canAccessPasswordManager() const { return !isUnique(); }
     124    bool canAccessFileSystem() const { return !isUnique(); }
    124125
    125126    // Technically, we should always allow access to sessionStorage, but we
  • trunk/WebCore/page/Settings.cpp

    r68166 r68222  
    499499}
    500500
    501 void Settings::setFileSystemRootPath(const String& path)
    502 {
    503     m_fileSystemRootPath = path;
    504 }
    505 
    506501void Settings::setApplicationChromeMode(bool mode)
    507502{
  • trunk/WebCore/page/Settings.h

    r68188 r68222  
    242242        const String& localStorageDatabasePath() const { return m_localStorageDatabasePath; }
    243243
    244         void setFileSystemRootPath(const String&);
    245         const String& fileSystemRootPath() const { return m_fileSystemRootPath; }
    246 
    247244        void setApplicationChromeMode(bool);
    248245        bool inApplicationChromeMode() const { return m_inApplicationChromeMode; }
     
    340337        String m_ftpDirectoryTemplatePath;
    341338        String m_localStorageDatabasePath;
    342         String m_fileSystemRootPath;
    343339        KURL m_userStyleSheetLocation;
    344340        AtomicString m_standardFontFamily;
  • trunk/WebCore/platform/AsyncFileSystem.cpp

    r66255 r68222  
    3636#include "AsyncFileSystemCallbacks.h"
    3737#include "FileSystem.h"
     38#include "NotImplemented.h"
    3839
    3940namespace WebCore {
    4041
     42#if !PLATFORM(CHROMIUM)
     43bool AsyncFileSystem::isAvailable()
     44{
     45    notImplemented();
     46    return false;
     47}
     48
    4149PassOwnPtr<AsyncFileSystem> AsyncFileSystem::create(const String&)
    4250{
    43     // FIXME: return default AsyncFileSystem implementation.
     51    notImplemented();
    4452    return 0;
    4553}
     
    6371    callbacks->didOpenFileSystem(name, AsyncFileSystem::create(rootPath));
    6472}
     73#endif
    6574
    6675// Default implementation.
  • trunk/WebCore/platform/AsyncFileSystem.h

    r68180 r68222  
    5757    virtual void stop() { }
    5858    virtual bool hasPendingActivity() { return false; }
     59
     60    static bool isAvailable();
    5961
    6062    // Creates and returns a new platform-specific AsyncFileSystem instance if the platform has its own implementation.
  • trunk/WebCore/workers/WorkerContext.cpp

    r66537 r68222  
    6464#endif
    6565
     66#if ENABLE(FILE_SYSTEM)
     67#include "AsyncFileSystem.h"
     68#include "DOMFileSystem.h"
     69#include "ErrorCallback.h"
     70#include "FileError.h"
     71#include "FileSystemCallback.h"
     72#include "LocalFileSystem.h"
     73#endif
     74
    6675namespace WebCore {
    6776
     
    101110    m_notifications.clear();
    102111#endif
     112
     113    // Make sure we have no observers.
     114    notifyObserversOfStop();
     115
    103116    // Notify proxy that we are going away. This can free the WorkerThread object, so do not access it after this.
    104117    thread()->workerReportingProxy().workerContextDestroyed();
     
    336349#endif
    337350
     351#if ENABLE(FILE_SYSTEM)
     352void WorkerContext::requestFileSystem(int type, long long size, PassRefPtr<FileSystemCallback> successCallback, PassRefPtr<ErrorCallback> errorCallback)
     353{
     354    if (!AsyncFileSystem::isAvailable() || !securityOrigin()->canAccessFileSystem()) {
     355        DOMFileSystem::scheduleCallback(this, errorCallback, FileError::create(SECURITY_ERR));
     356        return;
     357    }
     358
     359    LocalFileSystem::localFileSystem().requestFileSystem(this, static_cast<AsyncFileSystem::Type>(type), size, successCallback, errorCallback);
     360}
     361
     362COMPILE_ASSERT(static_cast<int>(WorkerContext::TEMPORARY) == static_cast<int>(AsyncFileSystem::Temporary), enum_mismatch);
     363COMPILE_ASSERT(static_cast<int>(WorkerContext::PERSISTENT) == static_cast<int>(AsyncFileSystem::Persistent), enum_mismatch);
     364#endif
     365
     366WorkerContext::Observer::Observer(WorkerContext* context)
     367    : m_context(context)
     368{
     369    ASSERT(m_context && m_context->isContextThread());
     370    m_context->registerObserver(this);
     371}
     372
     373WorkerContext::Observer::~Observer()
     374{
     375    if (!m_context)
     376        return;
     377    ASSERT(m_context->isContextThread());
     378    m_context->unregisterObserver(this);
     379}
     380
     381void WorkerContext::Observer::stopObserving()
     382{
     383    if (!m_context)
     384        return;
     385    ASSERT(m_context->isContextThread());
     386    m_context->unregisterObserver(this);
     387    m_context = 0;
     388}
     389
     390void WorkerContext::registerObserver(Observer* observer)
     391{
     392    ASSERT(observer);
     393    m_workerObservers.add(observer);
     394}
     395
     396void WorkerContext::unregisterObserver(Observer* observer)
     397{
     398    ASSERT(observer);
     399    m_workerObservers.remove(observer);
     400}
     401
     402void WorkerContext::notifyObserversOfStop()
     403{
     404    HashSet<Observer*>::iterator iter = m_workerObservers.begin();
     405    while (iter != m_workerObservers.end()) {
     406        WorkerContext::Observer* observer = *iter;
     407        observer->stopObserving();
     408        observer->notifyStop();
     409        iter = m_workerObservers.begin();
     410    }
     411}
     412
    338413} // namespace WebCore
    339414
  • trunk/WebCore/workers/WorkerContext.h

    r66537 r68222  
    3636#include "WorkerScriptController.h"
    3737#include <wtf/Assertions.h>
     38#include <wtf/HashMap.h>
    3839#include <wtf/OwnPtr.h>
    3940#include <wtf/PassRefPtr.h>
     
    4849    class DatabaseCallback;
    4950    class DatabaseSync;
     51    class ErrorCallback;
     52    class FileSystemCallback;
    5053    class NotificationCenter;
    5154    class ScheduledAction;
     
    122125#endif
    123126
     127#if ENABLE(FILE_SYSTEM)
     128        enum FileSystemType {
     129            TEMPORARY,
     130            PERSISTENT,
     131        };
     132        void requestFileSystem(int type, long long size, PassRefPtr<FileSystemCallback>, PassRefPtr<ErrorCallback>);
     133#endif
     134
    124135        // These methods are used for GC marking. See JSWorkerContext::markChildren(MarkStack&) in
    125136        // JSWorkerContextCustom.cpp.
     
    131142
    132143        bool isClosing() { return m_closing; }
     144
     145        // An observer interface to be notified when the worker thread is getting stopped.
     146        class Observer : public Noncopyable {
     147        public:
     148            Observer(WorkerContext*);
     149            virtual ~Observer();
     150            virtual void notifyStop() = 0;
     151            void stopObserving();
     152        private:
     153            WorkerContext* m_context;
     154        };
     155        friend class Observer;
     156        void registerObserver(Observer*);
     157        void unregisterObserver(Observer*);
     158        void notifyObserversOfStop();
    133159
    134160    protected:
     
    162188        bool m_reportingException;
    163189        EventTargetData m_eventTargetData;
     190
     191        HashSet<Observer*> m_workerObservers;
    164192    };
    165193
  • trunk/WebCore/workers/WorkerContext.idl

    r66537 r68222  
    105105        void revokeBlobURL(in DOMString blobURL);
    106106#endif
     107
     108#if defined(ENABLE_FILE_SYSTEM) && ENABLE_FILE_SYSTEM
     109        const unsigned short TEMPORARY = 0;
     110        const unsigned short PERSISTENT = 1;
     111        [EnabledAtRuntime] void requestFileSystem(in unsigned short type, in long long size, in [Callback, Optional] FileSystemCallback successCallback, in [Callback, Optional] ErrorCallback errorCallback);
     112
     113                 attribute [EnabledAtRuntime=FileSystem] FlagsConstructor Flags;
     114#endif
    107115    };
    108116
  • trunk/WebCore/workers/WorkerThread.cpp

    r64384 r68222  
    203203        workerContext->stopActiveDOMObjects();
    204204
     205        workerContext->notifyObserversOfStop();
     206
    205207        // Event listeners would keep DOMWrapperWorld objects alive for too long. Also, they have references to JS objects,
    206208        // which become dangling once Heap is destroyed.
  • trunk/WebKit/chromium/ChangeLog

    r68216 r68222  
     12010-09-23  Kinuko Yasuda  <kinuko@chromium.org>
     2
     3        Reviewed by David Levin.
     4
     5        Add Worker support for FileSystem API
     6        https://bugs.webkit.org/show_bug.cgi?id=45808
     7
     8        Added WebWorkerBase::openFileSystem and WebCommonWorkerClient::
     9        openFileSystem to call in to the browser via Worker stub/proxy
     10        in the chromium.
     11
     12        Also added WorkerFileSystemCallbacksBridge class that proxies
     13        requests and callbacks between from/to worker thread to/from the
     14        main thread.
     15
     16        * public/WebCommonWorkerClient.h:
     17        (WebKit::WebCommonWorkerClient::openFileSystem): Added.
     18        * src/LocalFileSystemChromium.cpp:
     19        (WebCore::LocalFileSystem::localFileSystem): Added.
     20        (WebCore::LocalFileSystem::requestFileSystem): Added implementation
     21        for workers. In worker case this calls WebWorkerBase::openFileSystem.
     22        * src/WebWorkerBase.cpp:
     23        (WebKit::WebWorkerBase::openFileSystem): Added. This is called from
     24        LocalFileSystem::requestFileSystem on the worker thread and creates
     25        a bridge to call WebCommonWorkerClient::openFileSystem on the main
     26        thread.
     27        * src/WebWorkerBase.h:
     28        * src/WebWorkerClientImpl.h:
     29        (WebKit::WebWorkerClientImpl::openFileSystem): Added.
     30        * src/WorkerFileSystemCallbacksBridge.cpp: Added.
     31        * src/WorkerFileSystemCallbacksBridge.h: Added.
     32
    1332010-09-23  Tony Chang  <tony@chromium.org>
    234
  • trunk/WebKit/chromium/WebKit.gyp

    r68141 r68222  
    533533                'src/WebWorkerImpl.cpp',
    534534                'src/WebWorkerImpl.h',
     535                'src/WorkerFileSystemCallbacksBridge.cpp',
     536                'src/WorkerFileSystemCallbacksBridge.h',
    535537                'src/WrappedResourceRequest.h',
    536538                'src/WrappedResourceResponse.h',
  • trunk/WebKit/chromium/public/WebCommonWorkerClient.h

    r59555 r68222  
    3131#ifndef WebCommonWorkerClient_h
    3232#define WebCommonWorkerClient_h
     33
     34#include "WebCommon.h"
     35#include "WebFileSystem.h"
    3336
    3437namespace WebKit {
     
    8487    virtual bool allowDatabase(WebFrame*, const WebString& name, const WebString& displayName, unsigned long estimatedSize) = 0;
    8588
     89    // Called on the main webkit thread before opening a file system.
     90    virtual void openFileSystem(WebFileSystem::Type, long long size, WebFileSystemCallbacks*)
     91    {
     92        WEBKIT_ASSERT_NOT_REACHED();
     93    }
     94
    8695protected:
    8796    ~WebCommonWorkerClient() { }
  • trunk/WebKit/chromium/src/AsyncFileSystemChromium.cpp

    r68180 r68222  
    4545
    4646namespace WebCore {
     47
     48bool AsyncFileSystem::isAvailable()
     49{
     50    return true;
     51}
    4752
    4853AsyncFileSystemChromium::AsyncFileSystemChromium(const String& rootPath)
  • trunk/WebKit/chromium/src/LocalFileSystemChromium.cpp

    r66280 r68222  
    4343#include "WebFrameClient.h"
    4444#include "WebFrameImpl.h"
     45#include "WebWorkerImpl.h"
     46#include "WorkerContext.h"
     47#include "WorkerThread.h"
     48#include <wtf/Threading.h>
    4549
    4650using namespace WebKit;
     
    4852namespace WebCore {
    4953
    50 PassRefPtr<LocalFileSystem> LocalFileSystem::create(const String& path)
     54LocalFileSystem& LocalFileSystem::localFileSystem()
    5155{
    52     return adoptRef(new LocalFileSystem(path));
     56    AtomicallyInitializedStatic(LocalFileSystem*, localFileSystem = new LocalFileSystem(""));
     57    return *localFileSystem;
    5358}
    5459
     
    6166        webFrame->client()->openFileSystem(webFrame, static_cast<WebFileSystem::Type>(type), size, new WebFileSystemCallbacksImpl(new FileSystemCallbacks(successCallback, errorCallback, context)));
    6267    } else {
    63         // FIXME: Add implementation for workers.
     68        WorkerContext* workerContext = static_cast<WorkerContext*>(context);
     69        WorkerLoaderProxy* workerLoaderProxy = &workerContext->thread()->workerLoaderProxy();
     70        WebWorkerBase* webWorker = static_cast<WebWorkerBase*>(workerLoaderProxy);
     71        webWorker->openFileSystem(static_cast<WebFileSystem::Type>(type), size, new WebFileSystemCallbacksImpl(new FileSystemCallbacks(successCallback, errorCallback, context)));
    6472    }
    6573}
  • trunk/WebKit/chromium/src/WebWorkerBase.cpp

    r65021 r68222  
    3838
    3939#include "WebDataSourceImpl.h"
     40#include "WebFileError.h"
    4041#include "WebFrameClient.h"
    4142#include "WebFrameImpl.h"
     
    4647#include "WebWorkerClient.h"
    4748
     49#include "WorkerContext.h"
     50#include "WorkerFileSystemCallbacksBridge.h"
    4851#include "WorkerScriptController.h"
    4952#include "WorkerThread.h"
     
    5760
    5861static const char allowDatabaseMode[] = "allowDatabaseMode";
     62static const char openFileSystemMode[] = "openFileSystemMode";
    5963
    6064namespace {
     
    115119    WTF::String m_mode;
    116120};
     121
    117122}
    118123
     
    232237}
    233238
     239void WebWorkerBase::openFileSystem(WebFileSystem::Type type, long long size, WebFileSystemCallbacks* callbacks)
     240{
     241    WorkerRunLoop& runLoop = m_workerThread->runLoop();
     242    WorkerScriptController* controller = WorkerScriptController::controllerForContext();
     243    WorkerContext* workerContext = controller->workerContext();
     244
     245    RefPtr<WorkerFileSystemCallbacksBridge> bridge = WorkerFileSystemCallbacksBridge::create(this, workerContext, callbacks);
     246    bridge->postOpenFileSystemToMainThread(commonClient(), type, size, openFileSystemMode);
     247}
     248
    234249// WorkerObjectProxy -----------------------------------------------------------
    235250
  • trunk/WebKit/chromium/src/WebWorkerBase.h

    r65021 r68222  
    9292    virtual bool allowDatabase(WebFrame*, const WebString& name, const WebString& displayName, unsigned long estimatedSize);
    9393
     94    // Requests to open a file system for this worker. (Note that this is not the implementation for WebFrameClient::openFileSystem.)
     95    void openFileSystem(WebFileSystem::Type, long long size, WebFileSystemCallbacks*);
     96
    9497    // Executes the given task on the main thread.
    9598    static void dispatchTaskToMainThread(PassOwnPtr<WebCore::ScriptExecutionContext::Task>);
  • trunk/WebKit/chromium/src/WebWorkerClientImpl.h

    r65021 r68222  
    3434#if ENABLE(WORKERS)
    3535
     36#include "WebFileSystem.h"
    3637#include "WebWorkerClient.h"
    37 
    3838#include "WorkerContextProxy.h"
    3939#include <wtf/PassOwnPtr.h>
     
    100100        return true;
    101101    }
     102    virtual void openFileSystem(WebFrame*, WebFileSystem::Type, long long size, WebFileSystemCallbacks*)
     103    {
     104        ASSERT_NOT_REACHED();
     105    }
    102106
    103107private:
Note: See TracChangeset for help on using the changeset viewer.