Modern IDB (Workers): Get the IDBConnectionProxy from the Document to the WorkerGloba...
authorbeidson@apple.com <beidson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 22 Apr 2016 01:03:39 +0000 (01:03 +0000)
committerbeidson@apple.com <beidson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 22 Apr 2016 01:03:39 +0000 (01:03 +0000)
https://bugs.webkit.org/show_bug.cgi?id=156877

Reviewed by Tim Horton.

Source/WebCore:

No new tests (Covered by changes to existing tests).

* workers/WorkerMessagingProxy.cpp:
(WebCore::WorkerMessagingProxy::startWorkerGlobalScope): This is the point on the main thread
  where we can get the IDBConnectionProxy from the Document and pass it down through Worker
  machinery so it can end up at the WorkerGlobalScope.

Everything else is this patch is just passing it along as needed.

And cleaning up header style for neglected headers.

* workers/DedicatedWorkerGlobalScope.cpp:
(WebCore::DedicatedWorkerGlobalScope::create):
(WebCore::DedicatedWorkerGlobalScope::DedicatedWorkerGlobalScope):
* workers/DedicatedWorkerGlobalScope.h:

* workers/DedicatedWorkerThread.cpp:
(WebCore::DedicatedWorkerThread::DedicatedWorkerThread):
(WebCore::DedicatedWorkerThread::createWorkerGlobalScope):
* workers/DedicatedWorkerThread.h:
(WebCore::DedicatedWorkerThread::create):
(WebCore::DedicatedWorkerThread::workerObjectProxy):

* workers/WorkerGlobalScope.cpp:
(WebCore::WorkerGlobalScope::WorkerGlobalScope):
(WebCore::WorkerGlobalScope::idbConnectionProxy):
* workers/WorkerGlobalScope.h:

* workers/WorkerThread.cpp:
(WebCore::WorkerThread::WorkerThread):
(WebCore::WorkerThread::idbConnectionProxy):
* workers/WorkerThread.h:
(WebCore::WorkerThread::threadID):
(WebCore::WorkerThread::runLoop):
(WebCore::WorkerThread::workerLoaderProxy):
(WebCore::WorkerThread::workerReportingProxy):
(WebCore::WorkerThread::getNotificationClient):
(WebCore::WorkerThread::setNotificationClient):
(WebCore::WorkerThread::workerGlobalScope):

LayoutTests:

* storage/indexeddb/modern/workers-enable-expected.txt:

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

12 files changed:
LayoutTests/ChangeLog
LayoutTests/storage/indexeddb/modern/workers-enable-expected.txt
Source/WebCore/ChangeLog
Source/WebCore/workers/DedicatedWorkerGlobalScope.cpp
Source/WebCore/workers/DedicatedWorkerGlobalScope.h
Source/WebCore/workers/DedicatedWorkerThread.cpp
Source/WebCore/workers/DedicatedWorkerThread.h
Source/WebCore/workers/WorkerGlobalScope.cpp
Source/WebCore/workers/WorkerGlobalScope.h
Source/WebCore/workers/WorkerMessagingProxy.cpp
Source/WebCore/workers/WorkerThread.cpp
Source/WebCore/workers/WorkerThread.h

index b6ef1d9..0fd3f47 100644 (file)
@@ -1,3 +1,12 @@
+2016-04-21  Brady Eidson  <beidson@apple.com>
+
+        Modern IDB (Workers): Get the IDBConnectionProxy from the Document to the WorkerGlobalScope.
+        https://bugs.webkit.org/show_bug.cgi?id=156877
+
+        Reviewed by Tim Horton.
+
+        * storage/indexeddb/modern/workers-enable-expected.txt:
+
 2016-04-21  Joseph Pecoraro  <pecoraro@apple.com>
 
         Web Inspector: sourceMappingURL not loaded in generated script
index 60d310f..e73c939 100644 (file)
@@ -5,8 +5,8 @@ On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE
 
 Starting worker: resources/workers-enable.js
 PASS [Worker] self.indexedDB is defined.
-FAIL [Worker] self.indexedDB should be non-null. Was null
-FAIL [Worker] self.indexedDB instanceof IDBFactory should be true. Was false.
+PASS [Worker] self.indexedDB is non-null.
+PASS [Worker] self.indexedDB instanceof IDBFactory is true
 PASS successfullyParsed is true
 
 TEST COMPLETE
index 608aff9..3a8aa88 100644 (file)
@@ -1,3 +1,50 @@
+2016-04-21  Brady Eidson  <beidson@apple.com>
+
+        Modern IDB (Workers): Get the IDBConnectionProxy from the Document to the WorkerGlobalScope.
+        https://bugs.webkit.org/show_bug.cgi?id=156877
+
+        Reviewed by Tim Horton.
+
+        No new tests (Covered by changes to existing tests).
+
+        * workers/WorkerMessagingProxy.cpp:
+        (WebCore::WorkerMessagingProxy::startWorkerGlobalScope): This is the point on the main thread
+          where we can get the IDBConnectionProxy from the Document and pass it down through Worker
+          machinery so it can end up at the WorkerGlobalScope.
+        
+        Everything else is this patch is just passing it along as needed.
+
+        And cleaning up header style for neglected headers.
+
+        * workers/DedicatedWorkerGlobalScope.cpp:
+        (WebCore::DedicatedWorkerGlobalScope::create):
+        (WebCore::DedicatedWorkerGlobalScope::DedicatedWorkerGlobalScope):
+        * workers/DedicatedWorkerGlobalScope.h:
+
+        * workers/DedicatedWorkerThread.cpp:
+        (WebCore::DedicatedWorkerThread::DedicatedWorkerThread):
+        (WebCore::DedicatedWorkerThread::createWorkerGlobalScope):
+        * workers/DedicatedWorkerThread.h:
+        (WebCore::DedicatedWorkerThread::create):
+        (WebCore::DedicatedWorkerThread::workerObjectProxy):
+
+        * workers/WorkerGlobalScope.cpp:
+        (WebCore::WorkerGlobalScope::WorkerGlobalScope):
+        (WebCore::WorkerGlobalScope::idbConnectionProxy):
+        * workers/WorkerGlobalScope.h:
+
+        * workers/WorkerThread.cpp:
+        (WebCore::WorkerThread::WorkerThread):
+        (WebCore::WorkerThread::idbConnectionProxy):
+        * workers/WorkerThread.h:
+        (WebCore::WorkerThread::threadID):
+        (WebCore::WorkerThread::runLoop):
+        (WebCore::WorkerThread::workerLoaderProxy):
+        (WebCore::WorkerThread::workerReportingProxy):
+        (WebCore::WorkerThread::getNotificationClient):
+        (WebCore::WorkerThread::setNotificationClient):
+        (WebCore::WorkerThread::workerGlobalScope):
+
 2016-04-21  Anders Carlsson  <andersca@apple.com>
 
         Fix crashes when loading SVG images.
index 30fde1c..8d8621e 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2009 Google Inc. All rights reserved.
+ * Copyright (C) 2016 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are
 
 namespace WebCore {
 
-Ref<DedicatedWorkerGlobalScope> DedicatedWorkerGlobalScope::create(const URL& url, const String& userAgent, DedicatedWorkerThread& thread, const ContentSecurityPolicyResponseHeaders& contentSecurityPolicyResponseHeaders, bool shouldBypassMainWorldContentSecurityPolicy, PassRefPtr<SecurityOrigin> topOrigin)
+Ref<DedicatedWorkerGlobalScope> DedicatedWorkerGlobalScope::create(const URL& url, const String& userAgent, DedicatedWorkerThread& thread, const ContentSecurityPolicyResponseHeaders& contentSecurityPolicyResponseHeaders, bool shouldBypassMainWorldContentSecurityPolicy, PassRefPtr<SecurityOrigin> topOrigin, IDBClient::IDBConnectionProxy* connectionProxy)
 {
-    Ref<DedicatedWorkerGlobalScope> context = adoptRef(*new DedicatedWorkerGlobalScope(url, userAgent, thread, shouldBypassMainWorldContentSecurityPolicy, topOrigin));
+    Ref<DedicatedWorkerGlobalScope> context = adoptRef(*new DedicatedWorkerGlobalScope(url, userAgent, thread, shouldBypassMainWorldContentSecurityPolicy, topOrigin, connectionProxy));
     if (!shouldBypassMainWorldContentSecurityPolicy)
         context->applyContentSecurityPolicyResponseHeaders(contentSecurityPolicyResponseHeaders);
     return context;
 }
 
-DedicatedWorkerGlobalScope::DedicatedWorkerGlobalScope(const URL& url, const String& userAgent, DedicatedWorkerThread& thread, bool shouldBypassMainWorldContentSecurityPolicy, PassRefPtr<SecurityOrigin> topOrigin)
-    : WorkerGlobalScope(url, userAgent, thread, shouldBypassMainWorldContentSecurityPolicy, topOrigin)
+DedicatedWorkerGlobalScope::DedicatedWorkerGlobalScope(const URL& url, const String& userAgent, DedicatedWorkerThread& thread, bool shouldBypassMainWorldContentSecurityPolicy, PassRefPtr<SecurityOrigin> topOrigin, IDBClient::IDBConnectionProxy* connectionProxy)
+    : WorkerGlobalScope(url, userAgent, thread, shouldBypassMainWorldContentSecurityPolicy, topOrigin, connectionProxy)
 {
 }
 
index 66bc9bf..abe3be3 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2009 Google Inc. All rights reserved.
+ * Copyright (C) 2016 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are
@@ -28,8 +29,7 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef DedicatedWorkerGlobalScope_h
-#define DedicatedWorkerGlobalScope_h
+#pragma once
 
 #include "MessagePort.h"
 #include "WorkerGlobalScope.h"
@@ -42,7 +42,7 @@ namespace WebCore {
     class DedicatedWorkerGlobalScope : public WorkerGlobalScope {
     public:
         typedef WorkerGlobalScope Base;
-        static Ref<DedicatedWorkerGlobalScope> create(const URL&, const String& userAgent, DedicatedWorkerThread&, const ContentSecurityPolicyResponseHeaders&, bool shouldBypassMainWorldContentSecurityPolicy, PassRefPtr<SecurityOrigin> topOrigin);
+        static Ref<DedicatedWorkerGlobalScope> create(const URL&, const String& userAgent, DedicatedWorkerThread&, const ContentSecurityPolicyResponseHeaders&, bool shouldBypassMainWorldContentSecurityPolicy, PassRefPtr<SecurityOrigin> topOrigin, IDBClient::IDBConnectionProxy*);
         virtual ~DedicatedWorkerGlobalScope();
 
         bool isDedicatedWorkerGlobalScope() const override { return true; }
@@ -60,9 +60,7 @@ namespace WebCore {
         DedicatedWorkerThread& thread();
 
     private:
-        DedicatedWorkerGlobalScope(const URL&, const String& userAgent, DedicatedWorkerThread&, bool shouldBypassMainWorldContentSecurityPolicy, PassRefPtr<SecurityOrigin> topOrigin);
+        DedicatedWorkerGlobalScope(const URL&, const String& userAgent, DedicatedWorkerThread&, bool shouldBypassMainWorldContentSecurityPolicy, PassRefPtr<SecurityOrigin> topOrigin, IDBClient::IDBConnectionProxy*);
     };
 
 } // namespace WebCore
-
-#endif // DedicatedWorkerGlobalScope_h
index 0394f0d..63fb8de 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2009 Google Inc. All rights reserved.
+ * Copyright (C) 2016 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are
@@ -29,7 +30,6 @@
  */
 
 #include "config.h"
-
 #include "DedicatedWorkerThread.h"
 
 #include "DedicatedWorkerGlobalScope.h"
@@ -38,8 +38,8 @@
 
 namespace WebCore {
 
-DedicatedWorkerThread::DedicatedWorkerThread(const URL& url, const String& userAgent, const String& sourceCode, WorkerLoaderProxy& workerLoaderProxy, WorkerObjectProxy& workerObjectProxy, WorkerThreadStartMode startMode, const ContentSecurityPolicyResponseHeaders& contentSecurityPolicyResponseHeaders, bool shouldBypassMainWorldContentSecurityPolicy, const SecurityOrigin* topOrigin)
-    : WorkerThread(url, userAgent, sourceCode, workerLoaderProxy, workerObjectProxy, startMode, contentSecurityPolicyResponseHeaders, shouldBypassMainWorldContentSecurityPolicy, topOrigin)
+DedicatedWorkerThread::DedicatedWorkerThread(const URL& url, const String& userAgent, const String& sourceCode, WorkerLoaderProxy& workerLoaderProxy, WorkerObjectProxy& workerObjectProxy, WorkerThreadStartMode startMode, const ContentSecurityPolicyResponseHeaders& contentSecurityPolicyResponseHeaders, bool shouldBypassMainWorldContentSecurityPolicy, const SecurityOrigin* topOrigin, IDBClient::IDBConnectionProxy* connectionProxy)
+    : WorkerThread(url, userAgent, sourceCode, workerLoaderProxy, workerObjectProxy, startMode, contentSecurityPolicyResponseHeaders, shouldBypassMainWorldContentSecurityPolicy, topOrigin, connectionProxy)
     , m_workerObjectProxy(workerObjectProxy)
 {
 }
@@ -50,7 +50,7 @@ DedicatedWorkerThread::~DedicatedWorkerThread()
 
 Ref<WorkerGlobalScope> DedicatedWorkerThread::createWorkerGlobalScope(const URL& url, const String& userAgent, const ContentSecurityPolicyResponseHeaders& contentSecurityPolicyResponseHeaders, bool shouldBypassMainWorldContentSecurityPolicy, PassRefPtr<SecurityOrigin> topOrigin)
 {
-    return DedicatedWorkerGlobalScope::create(url, userAgent, *this, contentSecurityPolicyResponseHeaders, shouldBypassMainWorldContentSecurityPolicy, topOrigin);
+    return DedicatedWorkerGlobalScope::create(url, userAgent, *this, contentSecurityPolicyResponseHeaders, shouldBypassMainWorldContentSecurityPolicy, topOrigin, idbConnectionProxy());
 }
 
 void DedicatedWorkerThread::runEventLoop()
index 18b2f16..a782b30 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2009 Google Inc. All rights reserved.
+ * Copyright (C) 2016 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
-#ifndef DedicatedWorkerThread_h
-#define DedicatedWorkerThread_h
+
+#pragma once
 
 #include "WorkerThread.h"
 
 namespace WebCore {
 
-    class ContentSecurityPolicyResponseHeaders;
-    class WorkerObjectProxy;
+class ContentSecurityPolicyResponseHeaders;
+class WorkerObjectProxy;
 
-    class DedicatedWorkerThread : public WorkerThread {
-    public:
-        template<typename... Args> static Ref<DedicatedWorkerThread> create(Args&&... args)
-        {
-            return adoptRef(*new DedicatedWorkerThread(std::forward<Args>(args)...));
-        }
-        virtual ~DedicatedWorkerThread();
+class DedicatedWorkerThread : public WorkerThread {
+public:
+    template<typename... Args> static Ref<DedicatedWorkerThread> create(Args&&... args)
+    {
+        return adoptRef(*new DedicatedWorkerThread(std::forward<Args>(args)...));
+    }
+    virtual ~DedicatedWorkerThread();
 
-        WorkerObjectProxy& workerObjectProxy() const { return m_workerObjectProxy; }
+    WorkerObjectProxy& workerObjectProxy() const { return m_workerObjectProxy; }
 
-    protected:
-        Ref<WorkerGlobalScope> createWorkerGlobalScope(const URL&, const String& userAgent, const ContentSecurityPolicyResponseHeaders&, bool shouldBypassMainWorldContentSecurityPolicy, PassRefPtr<SecurityOrigin> topOrigin) override;
-        void runEventLoop() override;
+protected:
+    Ref<WorkerGlobalScope> createWorkerGlobalScope(const URL&, const String& userAgent, const ContentSecurityPolicyResponseHeaders&, bool shouldBypassMainWorldContentSecurityPolicy, PassRefPtr<SecurityOrigin> topOrigin) override;
+    void runEventLoop() override;
 
-    private:
-        DedicatedWorkerThread(const URL&, const String& userAgent, const String& sourceCode, WorkerLoaderProxy&, WorkerObjectProxy&, WorkerThreadStartMode, const ContentSecurityPolicyResponseHeaders&, bool shouldBypassMainWorldContentSecurityPolicy, const SecurityOrigin* topOrigin);
+private:
+    DedicatedWorkerThread(const URL&, const String& userAgent, const String& sourceCode, WorkerLoaderProxy&, WorkerObjectProxy&, WorkerThreadStartMode, const ContentSecurityPolicyResponseHeaders&, bool shouldBypassMainWorldContentSecurityPolicy, const SecurityOrigin* topOrigin, IDBClient::IDBConnectionProxy*);
 
-        WorkerObjectProxy& m_workerObjectProxy;
-    };
-} // namespace WebCore
+    WorkerObjectProxy& m_workerObjectProxy;
+};
 
-#endif // DedicatedWorkerThread_h
+} // namespace WebCore
index ee8d775..d464ddb 100644 (file)
@@ -36,6 +36,7 @@
 #include "ErrorEvent.h"
 #include "Event.h"
 #include "ExceptionCode.h"
+#include "IDBConnectionProxy.h"
 #include "InspectorConsoleInstrumentation.h"
 #include "MessagePort.h"
 #include "ScheduledAction.h"
@@ -62,7 +63,7 @@ using namespace Inspector;
 
 namespace WebCore {
 
-WorkerGlobalScope::WorkerGlobalScope(const URL& url, const String& userAgent, WorkerThread& thread, bool shouldBypassMainWorldContentSecurityPolicy, PassRefPtr<SecurityOrigin> topOrigin)
+WorkerGlobalScope::WorkerGlobalScope(const URL& url, const String& userAgent, WorkerThread& thread, bool shouldBypassMainWorldContentSecurityPolicy, PassRefPtr<SecurityOrigin> topOrigin, IDBClient::IDBConnectionProxy* connectionProxy)
     : m_url(url)
     , m_userAgent(userAgent)
     , m_script(std::make_unique<WorkerScriptController>(this))
@@ -71,6 +72,9 @@ WorkerGlobalScope::WorkerGlobalScope(const URL& url, const String& userAgent, Wo
     , m_shouldBypassMainWorldContentSecurityPolicy(shouldBypassMainWorldContentSecurityPolicy)
     , m_eventQueue(*this)
     , m_topOrigin(topOrigin)
+#if ENABLE(INDEXED_DATABASE)
+    , m_connectionProxy(connectionProxy)
+#endif
 {
     setSecurityOriginPolicy(SecurityOriginPolicy::create(SecurityOrigin::create(url)));
     setContentSecurityPolicy(std::make_unique<ContentSecurityPolicy>(*this));
@@ -115,9 +119,11 @@ void WorkerGlobalScope::disableEval(const String& errorMessage)
 #if ENABLE(INDEXED_DATABASE)
 IDBClient::IDBConnectionProxy* WorkerGlobalScope::idbConnectionProxy()
 {
-    // FIXME: Implement
-
+#if ENABLE(INDEXED_DATABASE_IN_WORKERS)
+    return m_connectionProxy.get();
+#else
     return nullptr;
+#endif
 }
 #endif // ENABLE(INDEXED_DATABASE)
 
index 259f5e2..5ead829 100644 (file)
@@ -53,6 +53,10 @@ class WorkerLocation;
 class WorkerNavigator;
 class WorkerThread;
 
+namespace IDBClient {
+class IDBConnectionProxy;
+}
+
 class WorkerGlobalScope : public RefCounted<WorkerGlobalScope>, public Supplementable<WorkerGlobalScope>, public ScriptExecutionContext, public EventTargetWithInlineData {
 public:
     virtual ~WorkerGlobalScope();
@@ -140,7 +144,7 @@ public:
 #endif
 
 protected:
-    WorkerGlobalScope(const URL&, const String& userAgent, WorkerThread&, bool shouldBypassMainWorldContentSecurityPolicy, PassRefPtr<SecurityOrigin> topOrigin);
+    WorkerGlobalScope(const URL&, const String& userAgent, WorkerThread&, bool shouldBypassMainWorldContentSecurityPolicy, PassRefPtr<SecurityOrigin> topOrigin, IDBClient::IDBConnectionProxy*);
     void applyContentSecurityPolicyResponseHeaders(const ContentSecurityPolicyResponseHeaders&);
 
     void logExceptionToConsole(const String& errorMessage, const String& sourceURL, int lineNumber, int columnNumber, RefPtr<Inspector::ScriptCallStack>&&) override;
@@ -177,6 +181,10 @@ private:
     mutable WorkerEventQueue m_eventQueue;
 
     RefPtr<SecurityOrigin> m_topOrigin;
+
+#if ENABLE(INDEXED_DATABASE)
+    RefPtr<IDBClient::IDBConnectionProxy> m_connectionProxy;
+#endif
 };
 
 } // namespace WebCore
index 82cd0bc..75f68ff 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2008 Apple Inc. All Rights Reserved.
+ * Copyright (C) 2008, 2016 Apple Inc. All Rights Reserved.
  * Copyright (C) 2009 Google Inc. All Rights Reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -77,7 +77,8 @@ void WorkerMessagingProxy::startWorkerGlobalScope(const URL& scriptURL, const St
     // FIXME: This need to be revisited when we support nested worker one day
     ASSERT(m_scriptExecutionContext);
     Document& document = downcast<Document>(*m_scriptExecutionContext);
-    RefPtr<DedicatedWorkerThread> thread = DedicatedWorkerThread::create(scriptURL, userAgent, sourceCode, *this, *this, startMode, contentSecurityPolicyResponseHeaders, shouldBypassMainWorldContentSecurityPolicy, document.topOrigin());
+
+    RefPtr<DedicatedWorkerThread> thread = DedicatedWorkerThread::create(scriptURL, userAgent, sourceCode, *this, *this, startMode, contentSecurityPolicyResponseHeaders, shouldBypassMainWorldContentSecurityPolicy, document.topOrigin(), document.idbConnectionProxy());
     workerThreadCreated(thread);
     thread->start();
 }
index 297bf7e..9c28a4f 100644 (file)
@@ -30,6 +30,7 @@
 
 #include "ContentSecurityPolicyResponseHeaders.h"
 #include "DedicatedWorkerGlobalScope.h"
+#include "IDBConnectionProxy.h"
 #include "ScriptSourceCode.h"
 #include "SecurityOrigin.h"
 #include "ThreadGlobalData.h"
@@ -92,7 +93,7 @@ WorkerThreadStartupData::WorkerThreadStartupData(const URL& scriptURL, const Str
 {
 }
 
-WorkerThread::WorkerThread(const URL& scriptURL, const String& userAgent, const String& sourceCode, WorkerLoaderProxy& workerLoaderProxy, WorkerReportingProxy& workerReportingProxy, WorkerThreadStartMode startMode, const ContentSecurityPolicyResponseHeaders& contentSecurityPolicyResponseHeaders, bool shouldBypassMainWorldContentSecurityPolicy, const SecurityOrigin* topOrigin)
+WorkerThread::WorkerThread(const URL& scriptURL, const String& userAgent, const String& sourceCode, WorkerLoaderProxy& workerLoaderProxy, WorkerReportingProxy& workerReportingProxy, WorkerThreadStartMode startMode, const ContentSecurityPolicyResponseHeaders& contentSecurityPolicyResponseHeaders, bool shouldBypassMainWorldContentSecurityPolicy, const SecurityOrigin* topOrigin, IDBClient::IDBConnectionProxy* connectionProxy)
     : m_threadID(0)
     , m_workerLoaderProxy(workerLoaderProxy)
     , m_workerReportingProxy(workerReportingProxy)
@@ -100,6 +101,9 @@ WorkerThread::WorkerThread(const URL& scriptURL, const String& userAgent, const
 #if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
     , m_notificationClient(0)
 #endif
+#if ENABLE(INDEXED_DATABASE)
+    , m_idbConnectionProxy(connectionProxy)
+#endif
 {
     std::lock_guard<StaticLock> lock(threadSetMutex);
 
@@ -233,4 +237,13 @@ void WorkerThread::releaseFastMallocFreeMemoryInAllThreads()
     }
 }
 
+IDBClient::IDBConnectionProxy* WorkerThread::idbConnectionProxy()
+{
+#if ENABLE(INDEXED_DATABASE)
+    return m_idbConnectionProxy.get();
+#else
+    return nullptr;
+#endif
+}
+
 } // namespace WebCore
index 16c8db7..0bccb43 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2008 Apple Inc. All Rights Reserved.
+ * Copyright (C) 2008, 2016 Apple Inc. All Rights Reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -24,8 +24,7 @@
  *
  */
 
-#ifndef WorkerThread_h
-#define WorkerThread_h
+#pragma once
 
 #include "WorkerRunLoop.h"
 #include <memory>
 
 namespace WebCore {
 
-    class ContentSecurityPolicyResponseHeaders;
-    class URL;
-    class NotificationClient;
-    class SecurityOrigin;
-    class WorkerGlobalScope;
-    class WorkerLoaderProxy;
-    class WorkerReportingProxy;
-    struct WorkerThreadStartupData;
+class ContentSecurityPolicyResponseHeaders;
+class URL;
+class NotificationClient;
+class SecurityOrigin;
+class WorkerGlobalScope;
+class WorkerLoaderProxy;
+class WorkerReportingProxy;
 
-    enum WorkerThreadStartMode { DontPauseWorkerGlobalScopeOnStart, PauseWorkerGlobalScopeOnStart };
+enum WorkerThreadStartMode { DontPauseWorkerGlobalScopeOnStart, PauseWorkerGlobalScopeOnStart };
 
-    class WorkerThread : public RefCounted<WorkerThread> {
-    public:
-        virtual ~WorkerThread();
+namespace IDBClient {
+class IDBConnectionProxy;
+}
 
-        bool start();
-        void stop();
+struct WorkerThreadStartupData;
 
-        ThreadIdentifier threadID() const { return m_threadID; }
-        WorkerRunLoop& runLoop() { return m_runLoop; }
-        WorkerLoaderProxy& workerLoaderProxy() const { return m_workerLoaderProxy; }
-        WorkerReportingProxy& workerReportingProxy() const { return m_workerReportingProxy; }
+class WorkerThread : public RefCounted<WorkerThread> {
+public:
+    virtual ~WorkerThread();
 
-        // Number of active worker threads.
-        WEBCORE_EXPORT static unsigned workerThreadCount();
-        static void releaseFastMallocFreeMemoryInAllThreads();
+    bool start();
+    void stop();
+
+    ThreadIdentifier threadID() const { return m_threadID; }
+    WorkerRunLoop& runLoop() { return m_runLoop; }
+    WorkerLoaderProxy& workerLoaderProxy() const { return m_workerLoaderProxy; }
+    WorkerReportingProxy& workerReportingProxy() const { return m_workerReportingProxy; }
+
+    // Number of active worker threads.
+    WEBCORE_EXPORT static unsigned workerThreadCount();
+    static void releaseFastMallocFreeMemoryInAllThreads();
 
 #if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
-        NotificationClient* getNotificationClient() { return m_notificationClient; }
-        void setNotificationClient(NotificationClient* client) { m_notificationClient = client; }
+    NotificationClient* getNotificationClient() { return m_notificationClient; }
+    void setNotificationClient(NotificationClient* client) { m_notificationClient = client; }
 #endif
 
-    protected:
-        WorkerThread(const URL&, const String& userAgent, const String& sourceCode, WorkerLoaderProxy&, WorkerReportingProxy&, WorkerThreadStartMode, const ContentSecurityPolicyResponseHeaders&, bool shouldBypassMainWorldContentSecurityPolicy, const SecurityOrigin* topOrigin);
+protected:
+    WorkerThread(const URL&, const String& userAgent, const String& sourceCode, WorkerLoaderProxy&, WorkerReportingProxy&, WorkerThreadStartMode, const ContentSecurityPolicyResponseHeaders&, bool shouldBypassMainWorldContentSecurityPolicy, const SecurityOrigin* topOrigin, IDBClient::IDBConnectionProxy*);
+
+    // Factory method for creating a new worker context for the thread.
+    virtual Ref<WorkerGlobalScope> createWorkerGlobalScope(const URL&, const String& userAgent, const ContentSecurityPolicyResponseHeaders&, bool shouldBypassMainWorldContentSecurityPolicy, PassRefPtr<SecurityOrigin> topOrigin) = 0;
 
-        // Factory method for creating a new worker context for the thread.
-        virtual Ref<WorkerGlobalScope> createWorkerGlobalScope(const URL&, const String& userAgent, const ContentSecurityPolicyResponseHeaders&, bool shouldBypassMainWorldContentSecurityPolicy, PassRefPtr<SecurityOrigin> topOrigin) = 0;
+    // Executes the event loop for the worker thread. Derived classes can override to perform actions before/after entering the event loop.
+    virtual void runEventLoop();
 
-        // Executes the event loop for the worker thread. Derived classes can override to perform actions before/after entering the event loop.
-        virtual void runEventLoop();
+    WorkerGlobalScope* workerGlobalScope() { return m_workerGlobalScope.get(); }
 
-        WorkerGlobalScope* workerGlobalScope() { return m_workerGlobalScope.get(); }
+    IDBClient::IDBConnectionProxy* idbConnectionProxy();
 
-    private:
-        // Static function executed as the core routine on the new thread. Passed a pointer to a WorkerThread object.
-        static void workerThreadStart(void*);
-        void workerThread();
+private:
+    // Static function executed as the core routine on the new thread. Passed a pointer to a WorkerThread object.
+    static void workerThreadStart(void*);
+    void workerThread();
 
-        ThreadIdentifier m_threadID;
-        WorkerRunLoop m_runLoop;
-        WorkerLoaderProxy& m_workerLoaderProxy;
-        WorkerReportingProxy& m_workerReportingProxy;
+    ThreadIdentifier m_threadID;
+    WorkerRunLoop m_runLoop;
+    WorkerLoaderProxy& m_workerLoaderProxy;
+    WorkerReportingProxy& m_workerReportingProxy;
 
-        RefPtr<WorkerGlobalScope> m_workerGlobalScope;
-        Lock m_threadCreationMutex;
+    RefPtr<WorkerGlobalScope> m_workerGlobalScope;
+    Lock m_threadCreationMutex;
 
-        std::unique_ptr<WorkerThreadStartupData> m_startupData;
+    std::unique_ptr<WorkerThreadStartupData> m_startupData;
 
 #if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
-        NotificationClient* m_notificationClient;
+    NotificationClient* m_notificationClient;
 #endif
-    };
 
-} // namespace WebCore
+#if ENABLE(INDEXED_DATABASE)
+    RefPtr<IDBClient::IDBConnectionProxy> m_idbConnectionProxy;
+#endif
+};
 
-#endif // WorkerThread_h
+} // namespace WebCore