Diff
Modified: trunk/Source/WebCore/CMakeLists.txt (183617 => 183618)
--- trunk/Source/WebCore/CMakeLists.txt 2015-04-30 05:53:01 UTC (rev 183617)
+++ trunk/Source/WebCore/CMakeLists.txt 2015-04-30 06:29:36 UTC (rev 183618)
@@ -1398,7 +1398,6 @@
dom/ExceptionCodePlaceholder.cpp
dom/FocusEvent.cpp
dom/GenericEventQueue.cpp
- dom/GenericTaskQueue.cpp
dom/IdTargetObserver.cpp
dom/IdTargetObserverRegistry.cpp
dom/InlineStyleSheetOwner.cpp
Modified: trunk/Source/WebCore/ChangeLog (183617 => 183618)
--- trunk/Source/WebCore/ChangeLog 2015-04-30 05:53:01 UTC (rev 183617)
+++ trunk/Source/WebCore/ChangeLog 2015-04-30 06:29:36 UTC (rev 183618)
@@ -1,3 +1,30 @@
+2015-04-29 Jer Noble <[email protected]>
+
+ Make GenericTaskQueue even more generic (and usable inside platform/)
+ https://bugs.webkit.org/show_bug.cgi?id=144414
+
+ Reviewed by Eric Carlson.
+
+ Templatize GenericTaskQueue so that it can be used from within platform/.
+
+ * CMakeLists.txt:
+ * WebCore.vcxproj/WebCore.vcxproj:
+ * WebCore.vcxproj/WebCore.vcxproj.filters:
+ * WebCore.xcodeproj/project.pbxproj:
+ * dom/GenericTaskQueue.cpp: Removed.
+ * html/HTMLMediaElement.h:
+ * platform/GenericTaskQueue.h: Renamed from Source/WebCore/dom/GenericTaskQueue.h.
+ (WebCore::TaskDispatcher::TaskDispatcher): Added default templatized class which just calls the parameter's postTask().
+ (WebCore::TaskDispatcher::postTask): Call context's postTask().
+ (WebCore::TaskDispatcher<Timer>::TaskDispatcher): Add a timer version which does not require a context.
+ (WebCore::TaskDispatcher<Timer>::postTask): Set the timer.
+ (WebCore::TaskDispatcher<Timer>::timerFired): Call the task.
+ (WebCore::GenericTaskQueue::GenericTaskQueue): Moved from .cpp.
+ (WebCore::GenericTaskQueue::enqueueTask): Ditto.
+ (WebCore::GenericTaskQueue::close): Ditto.
+ (WebCore::GenericTaskQueue::cancelAllTasks): Ditto.
+ (WebCore::GenericTaskQueue::hasPendingTasks): Ditto.
+
2015-04-29 Joseph Pecoraro <[email protected]>
Unreviewed build fix. WebCore has a weak symbol.
Modified: trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj (183617 => 183618)
--- trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj 2015-04-30 05:53:01 UTC (rev 183617)
+++ trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj 2015-04-30 06:29:36 UTC (rev 183618)
@@ -13399,7 +13399,6 @@
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\dom\GenericEventQueue.cpp" />
- <ClCompile Include="..\dom\GenericTaskQueue.cpp" />
<ClCompile Include="..\dom\IdTargetObserver.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
@@ -19789,6 +19788,7 @@
<ClInclude Include="..\platform\FileStreamClient.h" />
<ClInclude Include="..\platform\FileSystem.h" />
<ClInclude Include="..\platform\FloatConversion.h" />
+ <ClInclude Include="..\platform\GenericTaskQueue.h" />
<ClInclude Include="..\platform\audio\AudioSession.h" />
<ClInclude Include="..\platform\audio\MediaSession.h" />
<ClInclude Include="..\platform\audio\MediaSessionManager.h" />
@@ -20979,7 +20979,6 @@
<ClInclude Include="..\dom\ExceptionCode.h" />
<ClInclude Include="..\dom\ExceptionCodePlaceholder.h" />
<ClInclude Include="..\dom\GenericEventQueue.h" />
- <ClInclude Include="..\dom\GenericTaskQueue.h" />
<ClInclude Include="..\dom\HashChangeEvent.h" />
<ClInclude Include="..\dom\IconURL.h" />
<ClInclude Include="..\dom\IdTargetObserver.h" />
Modified: trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters (183617 => 183618)
--- trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters 2015-04-30 05:53:01 UTC (rev 183617)
+++ trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters 2015-04-30 06:29:36 UTC (rev 183618)
@@ -3180,9 +3180,6 @@
<ClCompile Include="..\dom\GenericEventQueue.cpp">
<Filter>dom</Filter>
</ClCompile>
- <ClCompile Include="..\dom\GenericTaskQueue.cpp">
- <Filter>dom</Filter>
- </ClCompile>
<ClCompile Include="..\dom\IdTargetObserver.cpp">
<Filter>dom</Filter>
</ClCompile>
@@ -8181,6 +8178,9 @@
<ClInclude Include="..\platform\FloatConversion.h">
<Filter>platform</Filter>
</ClInclude>
+ <ClInclude Include="..\platform\GenericTaskQueue.h">
+ <Filter>platform</Filter>
+ </ClInclude>
<ClInclude Include="..\platform\HostWindow.h">
<Filter>platform</Filter>
</ClInclude>
@@ -10290,9 +10290,6 @@
<ClInclude Include="..\dom\GenericEventQueue.h">
<Filter>dom</Filter>
</ClInclude>
- <ClInclude Include="..\dom\GenericTaskQueue.h">
- <Filter>dom</Filter>
- </ClInclude>
<ClInclude Include="..\dom\HashChangeEvent.h">
<Filter>dom</Filter>
</ClInclude>
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (183617 => 183618)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2015-04-30 05:53:01 UTC (rev 183617)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2015-04-30 06:29:36 UTC (rev 183618)
@@ -5740,7 +5740,6 @@
CD60C0C7193E87C7003C656B /* MediaTimeQTKit.h in Headers */ = {isa = PBXBuildFile; fileRef = CD60C0C5193E87C7003C656B /* MediaTimeQTKit.h */; };
CD61FE671794AADB004101EB /* MediaSourceRegistry.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B1A942E115B5CE2200D525D1 /* MediaSourceRegistry.cpp */; };
CD61FE681794AADB004101EB /* MediaSourceRegistry.h in Headers */ = {isa = PBXBuildFile; fileRef = B1A942E215B5CE2200D525D1 /* MediaSourceRegistry.h */; };
- CD62FB951AF018E70012ED7D /* GenericTaskQueue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CD62FB931AF018E70012ED7D /* GenericTaskQueue.cpp */; };
CD62FB961AF018E70012ED7D /* GenericTaskQueue.h in Headers */ = {isa = PBXBuildFile; fileRef = CD62FB941AF018E70012ED7D /* GenericTaskQueue.h */; settings = {ATTRIBUTES = (Private, ); }; };
CD641EB31818F5ED00EE4C41 /* MediaSourcePrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = CD641EB11818F5ED00EE4C41 /* MediaSourcePrivate.h */; };
CD641EB41818F5ED00EE4C41 /* SourceBufferPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = CD641EB21818F5ED00EE4C41 /* SourceBufferPrivate.h */; };
@@ -13295,7 +13294,6 @@
CD5E5B601A15F156000C609E /* PageConfiguration.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PageConfiguration.cpp; sourceTree = "<group>"; };
CD60C0C4193E87C7003C656B /* MediaTimeQTKit.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MediaTimeQTKit.mm; sourceTree = "<group>"; };
CD60C0C5193E87C7003C656B /* MediaTimeQTKit.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MediaTimeQTKit.h; sourceTree = "<group>"; };
- CD62FB931AF018E70012ED7D /* GenericTaskQueue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GenericTaskQueue.cpp; sourceTree = "<group>"; };
CD62FB941AF018E70012ED7D /* GenericTaskQueue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GenericTaskQueue.h; sourceTree = "<group>"; };
CD641EB11818F5ED00EE4C41 /* MediaSourcePrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MediaSourcePrivate.h; sourceTree = "<group>"; };
CD641EB21818F5ED00EE4C41 /* SourceBufferPrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SourceBufferPrivate.h; sourceTree = "<group>"; };
@@ -21731,6 +21729,7 @@
C57FEDE01212EE9C0097BE65 /* FileSystem.cpp */,
514B3F720C722047000530DF /* FileSystem.h */,
BC073BA90C399B1F000F5979 /* FloatConversion.h */,
+ CD62FB941AF018E70012ED7D /* GenericTaskQueue.h */,
5179CE25195C821D0019C198 /* GamepadProvider.cpp */,
5179CE23195C81420019C198 /* GamepadProvider.h */,
5179CE29195C91860019C198 /* GamepadProviderClient.h */,
@@ -23080,8 +23079,6 @@
A853123C11D0471B00D4D077 /* FragmentScriptingPermission.h */,
0720B09E14D3323500642955 /* GenericEventQueue.cpp */,
0720B09F14D3323500642955 /* GenericEventQueue.h */,
- CD62FB931AF018E70012ED7D /* GenericTaskQueue.cpp */,
- CD62FB941AF018E70012ED7D /* GenericTaskQueue.h */,
2442BBF81194C9D300D49469 /* HashChangeEvent.h */,
8482B7441198C32E00BFB005 /* HashChangeEvent.idl */,
45BAC2AF1360BBAB005DA258 /* IconURL.h */,
@@ -30461,7 +30458,6 @@
A833C7CC0A2CF07400D57664 /* XLinkNames.cpp in Sources */,
00B9318713BA8DB30035A948 /* XMLDocumentParser.cpp in Sources */,
00B9318913BA8DBC0035A948 /* XMLDocumentParserLibxml2.cpp in Sources */,
- CD62FB951AF018E70012ED7D /* GenericTaskQueue.cpp in Sources */,
26A517FD1AB92238006335DF /* DFAMinimizer.cpp in Sources */,
00B9318B13BA8DC90035A948 /* XMLDocumentParserScope.cpp in Sources */,
59C28045138DC2410079B7E2 /* XMLErrors.cpp in Sources */,
Deleted: trunk/Source/WebCore/dom/GenericTaskQueue.cpp (183617 => 183618)
--- trunk/Source/WebCore/dom/GenericTaskQueue.cpp 2015-04-30 05:53:01 UTC (rev 183617)
+++ trunk/Source/WebCore/dom/GenericTaskQueue.cpp 2015-04-30 06:29:36 UTC (rev 183618)
@@ -1,64 +0,0 @@
-/*
- * Copyright (C) 2015 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. ``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
- * 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 "GenericTaskQueue.h"
-
-#include "ScriptExecutionContext.h"
-
-namespace WebCore {
-
-GenericTaskQueue::GenericTaskQueue(ScriptExecutionContext& context)
- : m_context(context)
- , m_weakPtrFactory(this)
-{
-}
-
-void GenericTaskQueue::enqueueTask(std::function<void()> task)
-{
- ASSERT(!m_isClosed);
- ++m_pendingTasks;
- auto weakThis = m_weakPtrFactory.createWeakPtr();
- m_context.postTask([weakThis, task] (ScriptExecutionContext&) {
- if (!weakThis)
- return;
- --weakThis->m_pendingTasks;
- task();
- });
-}
-
-void GenericTaskQueue::close()
-{
- cancelAllTasks();
- m_isClosed = true;
-}
-
-void GenericTaskQueue::cancelAllTasks()
-{
- m_weakPtrFactory.revokeAll();
- m_pendingTasks = 0;
-}
-
-}
Deleted: trunk/Source/WebCore/dom/GenericTaskQueue.h (183617 => 183618)
--- trunk/Source/WebCore/dom/GenericTaskQueue.h 2015-04-30 05:53:01 UTC (rev 183617)
+++ trunk/Source/WebCore/dom/GenericTaskQueue.h 2015-04-30 06:29:36 UTC (rev 183618)
@@ -1,55 +0,0 @@
-/*
- * Copyright (C) 2015 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. ``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
- * 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.
- */
-
-#ifndef GenericTaskQueue_h
-#define GenericTaskQueue_h
-
-#include <wtf/Deque.h>
-#include <wtf/WeakPtr.h>
-
-namespace WebCore {
-
-class ScriptExecutionContext;
-
-class GenericTaskQueue {
-public:
- GenericTaskQueue(ScriptExecutionContext&);
-
- void enqueueTask(std::function<void()>);
- void close();
-
- void cancelAllTasks();
- bool hasPendingTasks() const { return m_pendingTasks; }
-
-private:
- ScriptExecutionContext& m_context;
- WeakPtrFactory<GenericTaskQueue> m_weakPtrFactory;
- unsigned m_pendingTasks { 0 };
- bool m_isClosed { false };
-};
-
-}
-
-#endif
Modified: trunk/Source/WebCore/html/HTMLMediaElement.h (183617 => 183618)
--- trunk/Source/WebCore/html/HTMLMediaElement.h 2015-04-30 05:53:01 UTC (rev 183617)
+++ trunk/Source/WebCore/html/HTMLMediaElement.h 2015-04-30 06:29:36 UTC (rev 183618)
@@ -741,7 +741,7 @@
Timer m_progressEventTimer;
Timer m_playbackProgressTimer;
Timer m_scanTimer;
- GenericTaskQueue m_seekTaskQueue;
+ GenericTaskQueue<ScriptExecutionContext> m_seekTaskQueue;
RefPtr<TimeRanges> m_playedTimeRanges;
GenericEventQueue m_asyncEventQueue;
Copied: trunk/Source/WebCore/platform/GenericTaskQueue.h (from rev 183617, trunk/Source/WebCore/dom/GenericTaskQueue.h) (0 => 183618)
--- trunk/Source/WebCore/platform/GenericTaskQueue.h (rev 0)
+++ trunk/Source/WebCore/platform/GenericTaskQueue.h 2015-04-30 06:29:36 UTC (rev 183618)
@@ -0,0 +1,129 @@
+/*
+ * Copyright (C) 2015 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. ``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
+ * 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.
+ */
+
+#ifndef GenericTaskQueue_h
+#define GenericTaskQueue_h
+
+#include "Timer.h"
+#include <wtf/Deque.h>
+#include <wtf/WeakPtr.h>
+
+namespace WebCore {
+
+template <typename T>
+class TaskDispatcher {
+public:
+ TaskDispatcher(T& context)
+ : m_context(context)
+ {
+ }
+
+ void postTask(std::function<void()> f)
+ {
+ m_context.postTask(f);
+ }
+
+private:
+ T& m_context;
+};
+
+template<>
+class TaskDispatcher<Timer> {
+public:
+ TaskDispatcher()
+ : m_timer(*this, &TaskDispatcher<Timer>::timerFired)
+ {
+ }
+
+ void postTask(std::function<void()> function)
+ {
+ m_queue.append(function);
+ m_timer.startOneShot(0);
+ }
+
+ void timerFired()
+ {
+ Deque<std::function<void()>> queue;
+ queue.swap(m_queue);
+ for (std::function<void()>& function : queue)
+ function();
+ }
+
+ Timer m_timer;
+ Deque<std::function<void()>> m_queue;
+};
+
+template <typename T>
+class GenericTaskQueue {
+public:
+ GenericTaskQueue()
+ : m_weakPtrFactory(this)
+ , m_dispatcher()
+ {
+ }
+
+ GenericTaskQueue(T& t)
+ : m_weakPtrFactory(this)
+ , m_dispatcher(t)
+ {
+ }
+
+ typedef std::function<void()> TaskFunction;
+
+ void enqueueTask(TaskFunction task)
+ {
+ ASSERT(!m_isClosed);
+ ++m_pendingTasks;
+ auto weakThis = m_weakPtrFactory.createWeakPtr();
+ m_dispatcher.postTask([weakThis, task] {
+ if (!weakThis)
+ return;
+ task();
+ });
+ }
+
+ void close()
+ {
+ cancelAllTasks();
+ m_isClosed = true;
+ }
+
+ void cancelAllTasks()
+ {
+ m_weakPtrFactory.revokeAll();
+ m_pendingTasks = 0;
+ }
+ bool hasPendingTasks() const { return m_pendingTasks; }
+
+private:
+ WeakPtrFactory<GenericTaskQueue> m_weakPtrFactory;
+ TaskDispatcher<T> m_dispatcher;
+ unsigned m_pendingTasks { 0 };
+ bool m_isClosed { false };
+};
+
+}
+
+#endif