Diff
Modified: trunk/Source/WTF/ChangeLog (225449 => 225450)
--- trunk/Source/WTF/ChangeLog 2017-12-02 17:55:24 UTC (rev 225449)
+++ trunk/Source/WTF/ChangeLog 2017-12-02 18:00:19 UTC (rev 225450)
@@ -1,3 +1,22 @@
+2017-12-02 Brady Eidson <beid...@apple.com>
+
+ Factor out the "databaseTaskQueue" parts of IDBServer into something reusable.
+ https://bugs.webkit.org/show_bug.cgi?id=180298
+
+ Reviewed by Chris Dumez.
+
+ * WTF.xcodeproj/project.pbxproj:
+ * wtf/CMakeLists.txt:
+
+ * wtf/CrossThreadTaskHandler.cpp: Added.
+ (WTF::CrossThreadTaskHandler::CrossThreadTaskHandler):
+ (WTF::CrossThreadTaskHandler::~CrossThreadTaskHandler):
+ (WTF::CrossThreadTaskHandler::postTask):
+ (WTF::CrossThreadTaskHandler::postTaskReply):
+ (WTF::CrossThreadTaskHandler::taskRunLoop):
+ (WTF::CrossThreadTaskHandler::handleTaskRepliesOnMainThread):
+ * wtf/CrossThreadTaskHandler.h: Added.
+
2017-12-01 Mark Lam <mark....@apple.com>
Let's scramble ClassInfo pointers in cells.
Modified: trunk/Source/WTF/WTF.xcodeproj/project.pbxproj (225449 => 225450)
--- trunk/Source/WTF/WTF.xcodeproj/project.pbxproj 2017-12-02 17:55:24 UTC (rev 225449)
+++ trunk/Source/WTF/WTF.xcodeproj/project.pbxproj 2017-12-02 18:00:19 UTC (rev 225450)
@@ -65,6 +65,7 @@
2CDED0F318115C85004DBA70 /* RunLoop.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2CDED0F118115C85004DBA70 /* RunLoop.cpp */; };
3337DB9CE743410FAF076E17 /* StackTrace.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 313EDEC9778E49C9BEA91CFC /* StackTrace.cpp */; };
515F794E1CFC9F4A00CCED93 /* CrossThreadCopier.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 515F794B1CFC9F4A00CCED93 /* CrossThreadCopier.cpp */; };
+ 517F82D71FD22F3000DA3DEA /* CrossThreadTaskHandler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 517F82D51FD22F2F00DA3DEA /* CrossThreadTaskHandler.cpp */; };
51F1752B1F3D486000C74950 /* PersistentCoders.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51F175261F3D486000C74950 /* PersistentCoders.cpp */; };
51F1752C1F3D486000C74950 /* PersistentDecoder.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51F175271F3D486000C74950 /* PersistentDecoder.cpp */; };
51F1752D1F3D486000C74950 /* PersistentEncoder.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51F175291F3D486000C74950 /* PersistentEncoder.cpp */; };
@@ -322,6 +323,8 @@
515F794D1CFC9F4A00CCED93 /* CrossThreadTask.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CrossThreadTask.h; sourceTree = "<group>"; };
515F79551CFD3A6900CCED93 /* CrossThreadQueue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CrossThreadQueue.h; sourceTree = "<group>"; };
517A53571F5734B700DCDC0A /* Identified.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Identified.h; sourceTree = "<group>"; };
+ 517F82D51FD22F2F00DA3DEA /* CrossThreadTaskHandler.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CrossThreadTaskHandler.cpp; sourceTree = "<group>"; };
+ 517F82D61FD22F2F00DA3DEA /* CrossThreadTaskHandler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CrossThreadTaskHandler.h; sourceTree = "<group>"; };
5182C22C1F2BC7E60059BA7C /* InstanceCounted.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = InstanceCounted.h; sourceTree = "<group>"; };
51F175241F3D486000C74950 /* PersistentCoder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PersistentCoder.h; sourceTree = "<group>"; };
51F175251F3D486000C74950 /* PersistentCoders.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PersistentCoders.h; sourceTree = "<group>"; };
@@ -804,6 +807,8 @@
515F794C1CFC9F4A00CCED93 /* CrossThreadCopier.h */,
515F79551CFD3A6900CCED93 /* CrossThreadQueue.h */,
515F794D1CFC9F4A00CCED93 /* CrossThreadTask.h */,
+ 517F82D51FD22F2F00DA3DEA /* CrossThreadTaskHandler.cpp */,
+ 517F82D61FD22F2F00DA3DEA /* CrossThreadTaskHandler.h */,
A8A47273151A825A004123FF /* CryptographicallyRandomNumber.cpp */,
A8A47274151A825A004123FF /* CryptographicallyRandomNumber.h */,
E15556F318A0CC18006F48FB /* CryptographicUtilities.cpp */,
@@ -1386,6 +1391,7 @@
E38C41281EB4E0680042957D /* CPUTime.cpp in Sources */,
E38C41251EB4E04C0042957D /* CPUTimeCocoa.mm in Sources */,
515F794E1CFC9F4A00CCED93 /* CrossThreadCopier.cpp in Sources */,
+ 517F82D71FD22F3000DA3DEA /* CrossThreadTaskHandler.cpp in Sources */,
A8A4739A151A825B004123FF /* CryptographicallyRandomNumber.cpp in Sources */,
E15556F518A0CC18006F48FB /* CryptographicUtilities.cpp in Sources */,
A8A47439151A825B004123FF /* CString.cpp in Sources */,
@@ -1444,6 +1450,7 @@
1469419316EAAF6D0024E146 /* RunLoopTimerCF.cpp in Sources */,
1469419916EAB0410024E146 /* SchedulePairCF.cpp in Sources */,
1469419716EAAFF80024E146 /* SchedulePairMac.mm in Sources */,
+ FE85416E1FBE285D008DA5DA /* ScrambledPtr.cpp in Sources */,
0F66B28E1DC97BAB004A1D3F /* Seconds.cpp in Sources */,
A8A47421151A825B004123FF /* SHA1.cpp in Sources */,
5311BD531EA71CAD00525281 /* Signals.cpp in Sources */,
@@ -1470,7 +1477,6 @@
1C181C7F1D3078DA00F5FA16 /* TextBreakIterator.cpp in Sources */,
1C181C961D30800A00F5FA16 /* TextBreakIteratorInternalICUMac.mm in Sources */,
A3E4DD931F3A803400DED0B4 /* TextStream.cpp in Sources */,
- FE85416E1FBE285D008DA5DA /* ScrambledPtr.cpp in Sources */,
E311FB171F0A568B003C08DE /* ThreadGroup.cpp in Sources */,
A8A4744A151A825B004123FF /* Threading.cpp in Sources */,
A8A4744E151A825B004123FF /* ThreadingPthreads.cpp in Sources */,
Modified: trunk/Source/WTF/wtf/CMakeLists.txt (225449 => 225450)
--- trunk/Source/WTF/wtf/CMakeLists.txt 2017-12-02 17:55:24 UTC (rev 225449)
+++ trunk/Source/WTF/wtf/CMakeLists.txt 2017-12-02 18:00:19 UTC (rev 225450)
@@ -21,6 +21,7 @@
Condition.h
CrossThreadCopier.h
CrossThreadTask.h
+ CrossThreadTaskHandler.h
CryptographicUtilities.h
CryptographicallyRandomNumber.h
CurrentTime.h
@@ -219,6 +220,7 @@
ClockType.cpp
CompilationThread.cpp
CrossThreadCopier.cpp
+ CrossThreadTaskHandler.cpp
CryptographicUtilities.cpp
CryptographicallyRandomNumber.cpp
CurrentTime.cpp
Added: trunk/Source/WTF/wtf/CrossThreadTaskHandler.cpp (0 => 225450)
--- trunk/Source/WTF/wtf/CrossThreadTaskHandler.cpp (rev 0)
+++ trunk/Source/WTF/wtf/CrossThreadTaskHandler.cpp 2017-12-02 18:00:19 UTC (rev 225450)
@@ -0,0 +1,87 @@
+/*
+ * Copyright (C) 2017 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 met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "CrossThreadTaskHandler.h"
+
+namespace WTF {
+
+CrossThreadTaskHandler::CrossThreadTaskHandler(const char* threadName)
+{
+ ASSERT(isMainThread());
+ Locker<Lock> locker(m_taskThreadCreationLock);
+ m_thread = Thread::create(threadName, [this] {
+ taskRunLoop();
+ });
+}
+
+CrossThreadTaskHandler::~CrossThreadTaskHandler()
+{
+ ASSERT(isMainThread());
+}
+
+void CrossThreadTaskHandler::postTask(CrossThreadTask&& task)
+{
+ m_taskQueue.append(WTFMove(task));
+}
+
+void CrossThreadTaskHandler::postTaskReply(CrossThreadTask&& task)
+{
+ m_taskReplyQueue.append(WTFMove(task));
+
+ Locker<Lock> locker(m_mainThreadReplyLock);
+ if (m_mainThreadReplyScheduled)
+ return;
+
+ m_mainThreadReplyScheduled = true;
+ callOnMainThread([this] {
+ handleTaskRepliesOnMainThread();
+ });
+}
+
+void CrossThreadTaskHandler::taskRunLoop()
+{
+ ASSERT(!isMainThread());
+ {
+ Locker<Lock> locker(m_taskThreadCreationLock);
+ }
+
+ while (!m_taskQueue.isKilled())
+ m_taskQueue.waitForMessage().performTask();
+}
+
+void CrossThreadTaskHandler::handleTaskRepliesOnMainThread()
+{
+ {
+ Locker<Lock> locker(m_mainThreadReplyLock);
+ m_mainThreadReplyScheduled = false;
+ }
+
+ while (auto task = m_taskReplyQueue.tryGetMessage())
+ task->performTask();
+}
+
+
+} // namespace WTF
Added: trunk/Source/WTF/wtf/CrossThreadTaskHandler.h (0 => 225450)
--- trunk/Source/WTF/wtf/CrossThreadTaskHandler.h (rev 0)
+++ trunk/Source/WTF/wtf/CrossThreadTaskHandler.h 2017-12-02 18:00:19 UTC (rev 225450)
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 2017 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 met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include <wtf/CrossThreadQueue.h>
+#include <wtf/CrossThreadTask.h>
+#include <wtf/Lock.h>
+#include <wtf/Threading.h>
+
+namespace WTF {
+
+class RegistrationStore;
+class SQLiteDatabase;
+
+class CrossThreadTaskHandler {
+public:
+ WTF_EXPORT_PRIVATE virtual ~CrossThreadTaskHandler();
+
+protected:
+ WTF_EXPORT_PRIVATE CrossThreadTaskHandler(const char* threadName);
+
+ WTF_EXPORT_PRIVATE void postTask(CrossThreadTask&&);
+ WTF_EXPORT_PRIVATE void postTaskReply(CrossThreadTask&&);
+
+private:
+ void handleTaskRepliesOnMainThread();
+ void taskRunLoop();
+
+ RefPtr<Thread> m_thread { nullptr };
+ Lock m_taskThreadCreationLock;
+ Lock m_mainThreadReplyLock;
+ bool m_mainThreadReplyScheduled { false };
+
+ CrossThreadQueue<CrossThreadTask> m_taskQueue;
+ CrossThreadQueue<CrossThreadTask> m_taskReplyQueue;
+};
+
+} // namespace WTF
+
+using WTF::CrossThreadTaskHandler;
+
Modified: trunk/Source/WebCore/ChangeLog (225449 => 225450)
--- trunk/Source/WebCore/ChangeLog 2017-12-02 17:55:24 UTC (rev 225449)
+++ trunk/Source/WebCore/ChangeLog 2017-12-02 18:00:19 UTC (rev 225450)
@@ -1,3 +1,21 @@
+2017-12-02 Brady Eidson <beid...@apple.com>
+
+ Factor out the "databaseTaskQueue" parts of IDBServer into something reusable.
+ https://bugs.webkit.org/show_bug.cgi?id=180298
+
+ Reviewed by Chris Dumez.
+
+ No new tests (Refactor only).
+
+ * Modules/indexeddb/server/IDBServer.cpp:
+ (WebCore::IDBServer::IDBServer::IDBServer):
+ (WebCore::IDBServer::IDBServer::postDatabaseTask):
+ (WebCore::IDBServer::IDBServer::postDatabaseTaskReply):
+ (WebCore::IDBServer::IDBServer::databaseRunLoop): Deleted.
+ (WebCore::IDBServer::IDBServer::handleTaskRepliesOnMainThread): Deleted.
+ * Modules/indexeddb/server/IDBServer.h:
+ (): Deleted.
+
2017-12-02 Simon Fraser <simon.fra...@apple.com>
Add a log channel for viewports
Modified: trunk/Source/WebCore/Modules/indexeddb/server/IDBServer.cpp (225449 => 225450)
--- trunk/Source/WebCore/Modules/indexeddb/server/IDBServer.cpp 2017-12-02 17:55:24 UTC (rev 225449)
+++ trunk/Source/WebCore/Modules/indexeddb/server/IDBServer.cpp 2017-12-02 18:00:19 UTC (rev 225450)
@@ -53,24 +53,17 @@
}
IDBServer::IDBServer(IDBBackingStoreTemporaryFileHandler& fileHandler)
- : m_backingStoreTemporaryFileHandler(fileHandler)
+ : CrossThreadTaskHandler("IndexedDatabase Server")
+ , m_backingStoreTemporaryFileHandler(fileHandler)
{
- Locker<Lock> locker(m_databaseThreadCreationLock);
- m_thread = Thread::create("IndexedDatabase Server", [this] {
- databaseRunLoop();
- });
}
IDBServer::IDBServer(const String& databaseDirectoryPath, IDBBackingStoreTemporaryFileHandler& fileHandler)
- : m_databaseDirectoryPath(databaseDirectoryPath)
+ : CrossThreadTaskHandler("IndexedDatabase Server")
+ , m_databaseDirectoryPath(databaseDirectoryPath)
, m_backingStoreTemporaryFileHandler(fileHandler)
{
LOG(IndexedDB, "IDBServer created at path %s", databaseDirectoryPath.utf8().data());
-
- Locker<Lock> locker(m_databaseThreadCreationLock);
- m_thread = Thread::create("IndexedDatabase Server", [this] {
- databaseRunLoop();
- });
}
void IDBServer::registerConnection(IDBConnectionToClient& connection)
@@ -488,45 +481,14 @@
void IDBServer::postDatabaseTask(CrossThreadTask&& task)
{
- m_databaseQueue.append(WTFMove(task));
+ postTask(WTFMove(task));
}
void IDBServer::postDatabaseTaskReply(CrossThreadTask&& task)
{
- m_databaseReplyQueue.append(WTFMove(task));
-
- Locker<Lock> locker(m_mainThreadReplyLock);
- if (m_mainThreadReplyScheduled)
- return;
-
- m_mainThreadReplyScheduled = true;
- callOnMainThread([this] {
- handleTaskRepliesOnMainThread();
- });
+ postTaskReply(WTFMove(task));
}
-void IDBServer::databaseRunLoop()
-{
- ASSERT(!isMainThread());
- {
- Locker<Lock> locker(m_databaseThreadCreationLock);
- }
-
- while (!m_databaseQueue.isKilled())
- m_databaseQueue.waitForMessage().performTask();
-}
-
-void IDBServer::handleTaskRepliesOnMainThread()
-{
- {
- Locker<Lock> locker(m_mainThreadReplyLock);
- m_mainThreadReplyScheduled = false;
- }
-
- while (auto task = m_databaseReplyQueue.tryGetMessage())
- task->performTask();
-}
-
static uint64_t generateDeleteCallbackID()
{
ASSERT(isMainThread());
Modified: trunk/Source/WebCore/Modules/indexeddb/server/IDBServer.h (225449 => 225450)
--- trunk/Source/WebCore/Modules/indexeddb/server/IDBServer.h 2017-12-02 17:55:24 UTC (rev 225449)
+++ trunk/Source/WebCore/Modules/indexeddb/server/IDBServer.h 2017-12-02 18:00:19 UTC (rev 225450)
@@ -31,8 +31,7 @@
#include "IDBDatabaseIdentifier.h"
#include "UniqueIDBDatabase.h"
#include "UniqueIDBDatabaseConnection.h"
-#include <wtf/CrossThreadQueue.h>
-#include <wtf/CrossThreadTask.h>
+#include <wtf/CrossThreadTaskHandler.h>
#include <wtf/HashMap.h>
#include <wtf/Lock.h>
#include <wtf/Ref.h>
@@ -51,7 +50,7 @@
class IDBBackingStoreTemporaryFileHandler;
-class IDBServer : public RefCounted<IDBServer> {
+class IDBServer : public RefCounted<IDBServer>, public CrossThreadTaskHandler {
public:
static Ref<IDBServer> create(IDBBackingStoreTemporaryFileHandler&);
WEBCORE_EXPORT static Ref<IDBServer> create(const String& databaseDirectoryPath, IDBBackingStoreTemporaryFileHandler&);
@@ -118,20 +117,9 @@
void performCloseAndDeleteDatabasesForOrigins(const Vector<SecurityOriginData>&, uint64_t callbackID);
void didPerformCloseAndDeleteDatabases(uint64_t callbackID);
- void databaseRunLoop();
- void handleTaskRepliesOnMainThread();
-
HashMap<uint64_t, RefPtr<IDBConnectionToClient>> m_connectionMap;
HashMap<IDBDatabaseIdentifier, std::unique_ptr<UniqueIDBDatabase>> m_uniqueIDBDatabaseMap;
- RefPtr<Thread> m_thread { nullptr };
- Lock m_databaseThreadCreationLock;
- Lock m_mainThreadReplyLock;
- bool m_mainThreadReplyScheduled { false };
-
- CrossThreadQueue<CrossThreadTask> m_databaseQueue;
- CrossThreadQueue<CrossThreadTask> m_databaseReplyQueue;
-
HashMap<uint64_t, UniqueIDBDatabaseConnection*> m_databaseConnections;
HashMap<IDBResourceIdentifier, UniqueIDBDatabaseTransaction*> m_transactions;