Title: [191789] trunk/Source/WebCore
Revision
191789
Author
[email protected]
Date
2015-10-30 06:25:26 -0700 (Fri, 30 Oct 2015)

Log Message

Make every port implement MainThreadSharedTimer instead of using global functions
https://bugs.webkit.org/show_bug.cgi?id=150498

Reviewed by Darin Adler.

Move MainThreadSharedTimer to its own files and add the common
implementation there.

* CMakeLists.txt: Add MainThreadSharedTimer.cpp.
* PlatformEfl.cmake: Update filenames.
* PlatformGTK.cmake: Ditto.
* PlatformMac.cmake: Ditto.
* PlatformWin.cmake: Ditto.
* platform/MainThreadSharedTimer.cpp: Copied from Source/WebCore/platform/efl/SharedTimerEfl.cpp.
(WebCore::MainThreadSharedTimer::singleton):
(WebCore::MainThreadSharedTimer::MainThreadSharedTimer):
(WebCore::MainThreadSharedTimer::setFiredFunction):
(WebCore::MainThreadSharedTimer::fired):
* platform/MainThreadSharedTimer.h: Copied from Source/WebCore/platform/gtk/SharedTimerGtk.cpp.
* platform/SharedTimer.h: Remove MainThreadSharedTimer
implementation and reindent the code.
(WebCore::SharedTimer::SharedTimer):
(WebCore::SharedTimer::~SharedTimer):
(WebCore::SharedTimer::invalidate):
* platform/ThreadTimers.cpp:
(WebCore::ThreadTimers::ThreadTimers): Use MainThreadSharedTimer::singleton().
(WebCore::ThreadTimers::setSharedTimer): Use a lambda function
instead of a pointer to a static method.
(WebCore::ThreadTimers::sharedTimerFired): Deleted.
* platform/ThreadTimers.h: Removed unsused static method sharedTimerFired.
* platform/cf/MainThreadSharedTimerCF.cpp: Renamed from Source/WebCore/platform/cf/SharedTimerCF.cpp.
(WebCore::applicationDidBecomeActive):
(WebCore::setupPowerObserver):
(WebCore::timerFired):
(WebCore::restartSharedTimer):
(WebCore::MainThreadSharedTimer::invalidate):
(WebCore::MainThreadSharedTimer::setFireInterval):
(WebCore::MainThreadSharedTimer::stop):
* platform/efl/MainThreadSharedTimerEfl.cpp: Renamed from Source/WebCore/platform/efl/SharedTimerEfl.cpp.
(WebCore::timerEvent):
(WebCore::MainThreadSharedTimer::stop):
(WebCore::MainThreadSharedTimer::setFireInterval):
(WebCore::MainThreadSharedTimer::invalidate):
* platform/gtk/MainThreadSharedTimerGtk.cpp: Renamed from Source/WebCore/platform/gtk/SharedTimerGtk.cpp.
(WebCore::MainThreadSharedTimer::setFireInterval):
(WebCore::MainThreadSharedTimer::stop):
(WebCore::MainThreadSharedTimer::invalidate):
* platform/win/MainThreadSharedTimerWin.cpp: Renamed from Source/WebCore/platform/win/SharedTimerWin.cpp.
(WebCore::TimerWindowWndProc):
(WebCore::initializeOffScreenTimerWindow):
(WebCore::queueTimerProc):
(WebCore::MainThreadSharedTimer::setFireInterval):
(WebCore::MainThreadSharedTimer::stop):
(WebCore::MainThreadSharedTimer::invalidate):
* workers/WorkerRunLoop.cpp: Update WorkerSharedTimer
implementation to use std::function instead of a pointer. Also
mark the class as final and the virtual implementations as override.

Modified Paths

Added Paths

Removed Paths

Diff

Modified: trunk/Source/WebCore/CMakeLists.txt (191788 => 191789)


--- trunk/Source/WebCore/CMakeLists.txt	2015-10-30 12:46:55 UTC (rev 191788)
+++ trunk/Source/WebCore/CMakeLists.txt	2015-10-30 13:25:26 UTC (rev 191789)
@@ -2110,6 +2110,7 @@
     platform/LinkHash.cpp
     platform/Logging.cpp
     platform/MIMETypeRegistry.cpp
+    platform/MainThreadSharedTimer.cpp
     platform/MemoryPressureHandler.cpp
     platform/NotImplemented.cpp
     platform/PlatformEvent.cpp

Modified: trunk/Source/WebCore/ChangeLog (191788 => 191789)


--- trunk/Source/WebCore/ChangeLog	2015-10-30 12:46:55 UTC (rev 191788)
+++ trunk/Source/WebCore/ChangeLog	2015-10-30 13:25:26 UTC (rev 191789)
@@ -1,5 +1,65 @@
 2015-10-30  Carlos Garcia Campos  <[email protected]>
 
+        Make every port implement MainThreadSharedTimer instead of using global functions
+        https://bugs.webkit.org/show_bug.cgi?id=150498
+
+        Reviewed by Darin Adler.
+
+        Move MainThreadSharedTimer to its own files and add the common
+        implementation there.
+
+        * CMakeLists.txt: Add MainThreadSharedTimer.cpp.
+        * PlatformEfl.cmake: Update filenames.
+        * PlatformGTK.cmake: Ditto.
+        * PlatformMac.cmake: Ditto.
+        * PlatformWin.cmake: Ditto.
+        * platform/MainThreadSharedTimer.cpp: Copied from Source/WebCore/platform/efl/SharedTimerEfl.cpp.
+        (WebCore::MainThreadSharedTimer::singleton):
+        (WebCore::MainThreadSharedTimer::MainThreadSharedTimer):
+        (WebCore::MainThreadSharedTimer::setFiredFunction):
+        (WebCore::MainThreadSharedTimer::fired):
+        * platform/MainThreadSharedTimer.h: Copied from Source/WebCore/platform/gtk/SharedTimerGtk.cpp.
+        * platform/SharedTimer.h: Remove MainThreadSharedTimer
+        implementation and reindent the code.
+        (WebCore::SharedTimer::SharedTimer):
+        (WebCore::SharedTimer::~SharedTimer):
+        (WebCore::SharedTimer::invalidate):
+        * platform/ThreadTimers.cpp:
+        (WebCore::ThreadTimers::ThreadTimers): Use MainThreadSharedTimer::singleton().
+        (WebCore::ThreadTimers::setSharedTimer): Use a lambda function
+        instead of a pointer to a static method.
+        (WebCore::ThreadTimers::sharedTimerFired): Deleted.
+        * platform/ThreadTimers.h: Removed unsused static method sharedTimerFired.
+        * platform/cf/MainThreadSharedTimerCF.cpp: Renamed from Source/WebCore/platform/cf/SharedTimerCF.cpp.
+        (WebCore::applicationDidBecomeActive):
+        (WebCore::setupPowerObserver):
+        (WebCore::timerFired):
+        (WebCore::restartSharedTimer):
+        (WebCore::MainThreadSharedTimer::invalidate):
+        (WebCore::MainThreadSharedTimer::setFireInterval):
+        (WebCore::MainThreadSharedTimer::stop):
+        * platform/efl/MainThreadSharedTimerEfl.cpp: Renamed from Source/WebCore/platform/efl/SharedTimerEfl.cpp.
+        (WebCore::timerEvent):
+        (WebCore::MainThreadSharedTimer::stop):
+        (WebCore::MainThreadSharedTimer::setFireInterval):
+        (WebCore::MainThreadSharedTimer::invalidate):
+        * platform/gtk/MainThreadSharedTimerGtk.cpp: Renamed from Source/WebCore/platform/gtk/SharedTimerGtk.cpp.
+        (WebCore::MainThreadSharedTimer::setFireInterval):
+        (WebCore::MainThreadSharedTimer::stop):
+        (WebCore::MainThreadSharedTimer::invalidate):
+        * platform/win/MainThreadSharedTimerWin.cpp: Renamed from Source/WebCore/platform/win/SharedTimerWin.cpp.
+        (WebCore::TimerWindowWndProc):
+        (WebCore::initializeOffScreenTimerWindow):
+        (WebCore::queueTimerProc):
+        (WebCore::MainThreadSharedTimer::setFireInterval):
+        (WebCore::MainThreadSharedTimer::stop):
+        (WebCore::MainThreadSharedTimer::invalidate):
+        * workers/WorkerRunLoop.cpp: Update WorkerSharedTimer
+        implementation to use std::function instead of a pointer. Also
+        mark the class as final and the virtual implementations as override.
+
+2015-10-30  Carlos Garcia Campos  <[email protected]>
+
         [GTK] Use RunLoop::Timer instead of GMainLoopSource
         https://bugs.webkit.org/show_bug.cgi?id=150592
 

Modified: trunk/Source/WebCore/PlatformEfl.cmake (191788 => 191789)


--- trunk/Source/WebCore/PlatformEfl.cmake	2015-10-30 12:46:55 UTC (rev 191788)
+++ trunk/Source/WebCore/PlatformEfl.cmake	2015-10-30 13:25:26 UTC (rev 191789)
@@ -114,13 +114,13 @@
     platform/efl/LocalizedStringsEfl.cpp
     platform/efl/LoggingEfl.cpp
     platform/efl/MIMETypeRegistryEfl.cpp
+    platform/efl/MainThreadSharedTimerEfl.cpp
     platform/efl/PasteboardEfl.cpp
     platform/efl/PlatformKeyboardEventEfl.cpp
     platform/efl/PlatformMouseEventEfl.cpp
     platform/efl/PlatformScreenEfl.cpp
     platform/efl/PlatformWheelEventEfl.cpp
     platform/efl/ScrollbarThemeEfl.cpp
-    platform/efl/SharedTimerEfl.cpp
     platform/efl/SoundEfl.cpp
     platform/efl/TemporaryLinkStubs.cpp
     platform/efl/WidgetEfl.cpp

Modified: trunk/Source/WebCore/PlatformGTK.cmake (191788 => 191789)


--- trunk/Source/WebCore/PlatformGTK.cmake	2015-10-30 12:46:55 UTC (rev 191788)
+++ trunk/Source/WebCore/PlatformGTK.cmake	2015-10-30 13:25:26 UTC (rev 191789)
@@ -162,8 +162,8 @@
     platform/gtk/LanguageGtk.cpp
     platform/gtk/LoggingGtk.cpp
     platform/gtk/MIMETypeRegistryGtk.cpp
+    platform/gtk/MainThreadSharedTimerGtk.cpp
     platform/gtk/SharedBufferGtk.cpp
-    platform/gtk/SharedTimerGtk.cpp
     platform/gtk/TemporaryLinkStubs.cpp
     platform/gtk/UserAgentGtk.cpp
 

Modified: trunk/Source/WebCore/PlatformMac.cmake (191788 => 191789)


--- trunk/Source/WebCore/PlatformMac.cmake	2015-10-30 12:46:55 UTC (rev 191788)
+++ trunk/Source/WebCore/PlatformMac.cmake	2015-10-30 13:25:26 UTC (rev 191789)
@@ -312,10 +312,10 @@
     platform/cf/FileSystemCF.cpp
     platform/cf/KeyedDecoderCF.cpp
     platform/cf/KeyedEncoderCF.cpp
+    platform/cf/MainThreadSharedTimerCF.cpp
     platform/cf/MediaAccessibilitySoftLink.cpp
     platform/cf/RunLoopObserver.cpp
     platform/cf/SharedBufferCF.cpp
-    platform/cf/SharedTimerCF.cpp
     platform/cf/URLCF.cpp
 
     platform/cocoa/ContentFilterUnblockHandlerCocoa.mm

Modified: trunk/Source/WebCore/PlatformWin.cmake (191788 => 191789)


--- trunk/Source/WebCore/PlatformWin.cmake	2015-10-30 12:46:55 UTC (rev 191788)
+++ trunk/Source/WebCore/PlatformWin.cmake	2015-10-30 13:25:26 UTC (rev 191789)
@@ -124,6 +124,7 @@
     platform/win/LoggingWin.cpp
     platform/win/MemoryPressureHandlerWin.cpp
     platform/win/MIMETypeRegistryWin.cpp
+    platform/win/MainThreadSharedTimerWin.cpp
     platform/win/PasteboardWin.cpp
     platform/win/PathWalker.cpp
     platform/win/PlatformMouseEventWin.cpp
@@ -133,7 +134,6 @@
     platform/win/ScrollbarThemeWin.cpp
     platform/win/SearchPopupMenuWin.cpp
     platform/win/SharedBufferWin.cpp
-    platform/win/SharedTimerWin.cpp
     platform/win/SoundWin.cpp
     platform/win/StructuredExceptionHandlerSuppressor.cpp
     platform/win/SystemInfo.cpp

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (191788 => 191789)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2015-10-30 12:46:55 UTC (rev 191788)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2015-10-30 13:25:26 UTC (rev 191789)
@@ -1703,7 +1703,6 @@
 		46233EEE1BA0F187000EBEBB /* AttributeDOMTokenList.h in Headers */ = {isa = PBXBuildFile; fileRef = 46233EED1BA0F17A000EBEBB /* AttributeDOMTokenList.h */; };
 		46233EEF1BA0F18B000EBEBB /* AttributeDOMTokenList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46233EEC1BA0F17A000EBEBB /* AttributeDOMTokenList.cpp */; };
 		4634592C1AC2271000ECB71C /* PowerObserverMac.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4634592B1AC2271000ECB71C /* PowerObserverMac.cpp */; };
-		4634592E1AC2273C00ECB71C /* SharedTimerCF.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4634592D1AC2273C00ECB71C /* SharedTimerCF.cpp */; };
 		463EB6221B8789E00096ED51 /* TagCollection.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 463EB6201B8789CB0096ED51 /* TagCollection.cpp */; };
 		463EB6231B8789E00096ED51 /* TagCollection.h in Headers */ = {isa = PBXBuildFile; fileRef = 463EB6211B8789CB0096ED51 /* TagCollection.h */; };
 		4669B2871B852A0B000F905F /* JSDOMNamedFlowCollectionCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46F2768E1B85297F005C2556 /* JSDOMNamedFlowCollectionCustom.cpp */; };
@@ -2643,6 +2642,9 @@
 		7ADE722610CBBB9B006B3B3A /* ContextMenuProvider.h in Headers */ = {isa = PBXBuildFile; fileRef = 7ADE722510CBBB9B006B3B3A /* ContextMenuProvider.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		7AE335F11ACB09E200E401EF /* WheelEventTestTrigger.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7AE335EF1ACB09E200E401EF /* WheelEventTestTrigger.cpp */; };
 		7AE335F21ACB09E200E401EF /* WheelEventTestTrigger.h in Headers */ = {isa = PBXBuildFile; fileRef = 7AE335F01ACB09E200E401EF /* WheelEventTestTrigger.h */; settings = {ATTRIBUTES = (Private, ); }; };
+		7AE6C9381BE0C5C800E19E03 /* MainThreadSharedTimerCF.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7AE6C9371BE0C5C800E19E03 /* MainThreadSharedTimerCF.cpp */; };
+		7AE6C93B1BE0C60100E19E03 /* MainThreadSharedTimer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7AE6C9391BE0C60100E19E03 /* MainThreadSharedTimer.cpp */; };
+		7AE6C93C1BE0C60100E19E03 /* MainThreadSharedTimer.h in Headers */ = {isa = PBXBuildFile; fileRef = 7AE6C93A1BE0C60100E19E03 /* MainThreadSharedTimer.h */; };
 		7AF9B20218CFB2DF00C64BEF /* VTTRegion.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7AF9B1FC18CFB2DF00C64BEF /* VTTRegion.cpp */; };
 		7AF9B20318CFB2DF00C64BEF /* VTTRegion.h in Headers */ = {isa = PBXBuildFile; fileRef = 7AF9B1FD18CFB2DF00C64BEF /* VTTRegion.h */; };
 		7AF9B20518CFB2DF00C64BEF /* VTTRegionList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7AF9B1FF18CFB2DF00C64BEF /* VTTRegionList.cpp */; };
@@ -9064,7 +9066,6 @@
 		46233EEC1BA0F17A000EBEBB /* AttributeDOMTokenList.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = AttributeDOMTokenList.cpp; path = ../AttributeDOMTokenList.cpp; sourceTree = "<group>"; };
 		46233EED1BA0F17A000EBEBB /* AttributeDOMTokenList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AttributeDOMTokenList.h; path = ../AttributeDOMTokenList.h; sourceTree = "<group>"; };
 		4634592B1AC2271000ECB71C /* PowerObserverMac.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PowerObserverMac.cpp; sourceTree = "<group>"; };
-		4634592D1AC2273C00ECB71C /* SharedTimerCF.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SharedTimerCF.cpp; sourceTree = "<group>"; };
 		463EB6201B8789CB0096ED51 /* TagCollection.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TagCollection.cpp; sourceTree = "<group>"; };
 		463EB6211B8789CB0096ED51 /* TagCollection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TagCollection.h; sourceTree = "<group>"; };
 		4689F1AE1267BAE100E8D380 /* FileMetadata.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FileMetadata.h; sourceTree = "<group>"; };
@@ -10105,6 +10106,9 @@
 		7ADE722510CBBB9B006B3B3A /* ContextMenuProvider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ContextMenuProvider.h; sourceTree = "<group>"; };
 		7AE335EF1ACB09E200E401EF /* WheelEventTestTrigger.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WheelEventTestTrigger.cpp; sourceTree = "<group>"; };
 		7AE335F01ACB09E200E401EF /* WheelEventTestTrigger.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WheelEventTestTrigger.h; sourceTree = "<group>"; };
+		7AE6C9371BE0C5C800E19E03 /* MainThreadSharedTimerCF.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MainThreadSharedTimerCF.cpp; sourceTree = "<group>"; };
+		7AE6C9391BE0C60100E19E03 /* MainThreadSharedTimer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MainThreadSharedTimer.cpp; sourceTree = "<group>"; };
+		7AE6C93A1BE0C60100E19E03 /* MainThreadSharedTimer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MainThreadSharedTimer.h; sourceTree = "<group>"; };
 		7AF9B1FC18CFB2DF00C64BEF /* VTTRegion.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = VTTRegion.cpp; sourceTree = "<group>"; };
 		7AF9B1FD18CFB2DF00C64BEF /* VTTRegion.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VTTRegion.h; sourceTree = "<group>"; };
 		7AF9B1FE18CFB2DF00C64BEF /* VTTRegion.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = VTTRegion.idl; sourceTree = "<group>"; };
@@ -15764,6 +15768,7 @@
 		1AE42F670AA4B8CB00C8612D /* cf */ = {
 			isa = PBXGroup;
 			children = (
+				7AE6C9371BE0C5C800E19E03 /* MainThreadSharedTimerCF.cpp */,
 				E1A8E56417552B2A007488E7 /* CFURLExtras.cpp */,
 				E1A8E56517552B2A007488E7 /* CFURLExtras.h */,
 				443817FD1A91B2F8006E04F2 /* CoreMediaSoftLink.cpp */,
@@ -15778,7 +15783,6 @@
 				2D76BB8319456F8100CFD29A /* RunLoopObserver.cpp */,
 				2D76BB801945632400CFD29A /* RunLoopObserver.h */,
 				512DD8E20D91E2B4000F89EE /* SharedBufferCF.cpp */,
-				4634592D1AC2273C00ECB71C /* SharedTimerCF.cpp */,
 				1A98956A0AA78F80005EF5EF /* URLCF.cpp */,
 			);
 			path = cf;
@@ -22366,6 +22370,8 @@
 		BCF1A5BA097832090061A123 /* platform */ = {
 			isa = PBXGroup;
 			children = (
+				7AE6C9391BE0C60100E19E03 /* MainThreadSharedTimer.cpp */,
+				7AE6C93A1BE0C60100E19E03 /* MainThreadSharedTimer.h */,
 				49E912A40EFAC8E6009D0CAF /* animation */,
 				FD31604012B026A300C1A359 /* audio */,
 				1AE42F670AA4B8CB00C8612D /* cf */,
@@ -27852,6 +27858,7 @@
 				AAA728F716D1D8BC00D3BBC6 /* WebAccessibilityObjectWrapperIOS.h in Headers */,
 				AA478A7F16CD70C3007D1BB4 /* WebAccessibilityObjectWrapperMac.h in Headers */,
 				2D3EF4481917915C00034184 /* WebActionDisablingCALayerDelegate.h in Headers */,
+				7AE6C93C1BE0C60100E19E03 /* MainThreadSharedTimer.h in Headers */,
 				07D637401BB0B11300256CE9 /* WebAudioSourceProviderAVFObjC.h in Headers */,
 				A5A7AA43132F0ECC00D3A3C2 /* WebAutocapitalize.h in Headers */,
 				A56C5B9B189F34570082D13C /* WebConsoleAgent.h in Headers */,
@@ -29252,6 +29259,7 @@
 				0779BF0D18453168000B6AE7 /* HTMLMediaElementMediaStream.cpp in Sources */,
 				A8EA79F80A1916DF00A8EF5F /* HTMLMenuElement.cpp in Sources */,
 				2BE8E2C912A58A0100FAD550 /* HTMLMetaCharsetParser.cpp in Sources */,
+				7AE6C9381BE0C5C800E19E03 /* MainThreadSharedTimerCF.cpp in Sources */,
 				A871DC270A15205700B12A68 /* HTMLMetaElement.cpp in Sources */,
 				A454424A119B3661009BE912 /* HTMLMeterElement.cpp in Sources */,
 				A8CFF7A90A156978000A4234 /* HTMLModElement.cpp in Sources */,
@@ -30796,7 +30804,6 @@
 				512DD8E30D91E2B4000F89EE /* SharedBufferCF.cpp in Sources */,
 				97B1F02E13B025CA00F5103F /* SharedBufferChunkReader.cpp in Sources */,
 				1A4A95520B4EDCFF002D8C3C /* SharedBufferMac.mm in Sources */,
-				4634592E1AC2273C00ECB71C /* SharedTimerCF.cpp in Sources */,
 				163E88F7118A39D200ED9231 /* SimpleFontDataCoreText.cpp in Sources */,
 				E48944A2180B57D800F165D8 /* SimpleLineLayout.cpp in Sources */,
 				585D6E031A1A792E00FA4F12 /* SimpleLineLayoutFlowContents.cpp in Sources */,
@@ -31363,6 +31370,7 @@
 				BC8243E80D0CFD7500460C8F /* WindowFeatures.cpp in Sources */,
 				7E99AF510B13846468FB01A5 /* WindowFocusAllowedIndicator.cpp in Sources */,
 				A14832BD187F64B400DA63A6 /* WKContentObservation.cpp in Sources */,
+				7AE6C93B1BE0C60100E19E03 /* MainThreadSharedTimer.cpp in Sources */,
 				A14832C0187F656600DA63A6 /* WKGraphics.mm in Sources */,
 				A14832C2187F65C700DA63A6 /* WKUtilities.c in Sources */,
 				A14832C5187F668300DA63A6 /* WKView.mm in Sources */,

Copied: trunk/Source/WebCore/platform/MainThreadSharedTimer.cpp (from rev 191788, trunk/Source/WebCore/platform/efl/SharedTimerEfl.cpp) (0 => 191789)


--- trunk/Source/WebCore/platform/MainThreadSharedTimer.cpp	                        (rev 0)
+++ trunk/Source/WebCore/platform/MainThreadSharedTimer.cpp	2015-10-30 13:25:26 UTC (rev 191789)
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2015 Igalia S.L.
+ *
+ * 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 "MainThreadSharedTimer.h"
+
+namespace WebCore {
+
+MainThreadSharedTimer& MainThreadSharedTimer::singleton()
+{
+    static NeverDestroyed<MainThreadSharedTimer> instance;
+    return instance;
+}
+
+MainThreadSharedTimer::MainThreadSharedTimer()
+{
+}
+
+void MainThreadSharedTimer::setFiredFunction(std::function<void()>&& firedFunction)
+{
+    RELEASE_ASSERT(!m_firedFunction || !firedFunction);
+    m_firedFunction = WTF::move(firedFunction);
+}
+
+void MainThreadSharedTimer::fired() const
+{
+    ASSERT(m_firedFunction);
+    m_firedFunction();
+}
+
+} // namespace WebCore

Copied: trunk/Source/WebCore/platform/MainThreadSharedTimer.h (from rev 191788, trunk/Source/WebCore/platform/gtk/SharedTimerGtk.cpp) (0 => 191789)


--- trunk/Source/WebCore/platform/MainThreadSharedTimer.h	                        (rev 0)
+++ trunk/Source/WebCore/platform/MainThreadSharedTimer.h	2015-10-30 13:25:26 UTC (rev 191789)
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2015 Igalia S.L.
+ * Copyright (C) 2006 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 MainThreadSharedTimer_h
+#define MainThreadSharedTimer_h
+
+#include "SharedTimer.h"
+#include <wtf/NeverDestroyed.h>
+
+namespace WebCore {
+
+class MainThreadSharedTimer final : public SharedTimer {
+    friend class WTF::NeverDestroyed<MainThreadSharedTimer>;
+public:
+    static MainThreadSharedTimer& singleton();
+
+    void setFiredFunction(std::function<void()>&&) override;
+    void setFireInterval(double) override;
+    void stop() override;
+    void invalidate() override;
+
+    // FIXME: This should be private, but CF and Windows implementations
+    // need to call this from non-member functions at the moment.
+    void fired() const;
+
+private:
+    MainThreadSharedTimer();
+
+    std::function<void()> m_firedFunction;
+};
+
+} // namespace WebCore
+
+#endif // MainThreadSharedTimer

Modified: trunk/Source/WebCore/platform/SharedTimer.h (191788 => 191789)


--- trunk/Source/WebCore/platform/SharedTimer.h	2015-10-30 12:46:55 UTC (rev 191788)
+++ trunk/Source/WebCore/platform/SharedTimer.h	2015-10-30 13:25:26 UTC (rev 191789)
@@ -26,60 +26,29 @@
 #ifndef SharedTimer_h
 #define SharedTimer_h
 
+#include <functional>
 #include <wtf/FastMalloc.h>
 #include <wtf/Noncopyable.h>
 
 namespace WebCore {
 
-    // Each thread has its own single instance of shared timer, which implements this interface.
-    // This instance is shared by all timers in the thread.
-    // Not intended to be used directly; use the Timer class instead.
-    class SharedTimer {
-        WTF_MAKE_NONCOPYABLE(SharedTimer); WTF_MAKE_FAST_ALLOCATED;
-    public:
-        SharedTimer() { }
-        virtual ~SharedTimer() {}
-        virtual void setFiredFunction(void (*)()) = 0;
+// Each thread has its own single instance of shared timer, which implements this interface.
+// This instance is shared by all timers in the thread.
+// Not intended to be used directly; use the Timer class instead.
+class SharedTimer {
+    WTF_MAKE_NONCOPYABLE(SharedTimer); WTF_MAKE_FAST_ALLOCATED;
+public:
+    SharedTimer() = default;
+    virtual ~SharedTimer() { }
+    virtual void setFiredFunction(std::function<void()>&&) = 0;
 
-        // The fire interval is in seconds relative to the current monotonic clock time.
-        virtual void setFireInterval(double) = 0;
-        virtual void stop() = 0;
+    // The fire interval is in seconds relative to the current monotonic clock time.
+    virtual void setFireInterval(double) = 0;
+    virtual void stop() = 0;
 
-        virtual void invalidate() { }
-    };
+    virtual void invalidate() { }
+};
 
-
-    // Implemented by port (since it provides the run loop for the main thread).
-    // FIXME: make ports implement MainThreadSharedTimer directly instead.
-    void setSharedTimerFiredFunction(void (*)());
-    void setSharedTimerFireInterval(double);
-    void stopSharedTimer();
-    void invalidateSharedTimer();
-
-    // Implementation of SharedTimer for the main thread.
-    class MainThreadSharedTimer final : public SharedTimer {
-    public:
-        void setFiredFunction(void (*function)()) override
-        {
-            setSharedTimerFiredFunction(function);
-        }
-        
-        void setFireInterval(double interval) override
-        {
-            setSharedTimerFireInterval(interval);
-        }
-        
-        void stop() override
-        {
-            stopSharedTimer();
-        }
-
-        void invalidate() override
-        {
-            invalidateSharedTimer();
-        }
-    };
-
 } // namespace WebCore
 
 #endif // SharedTimer_h

Modified: trunk/Source/WebCore/platform/ThreadTimers.cpp (191788 => 191789)


--- trunk/Source/WebCore/platform/ThreadTimers.cpp	2015-10-30 12:46:55 UTC (rev 191788)
+++ trunk/Source/WebCore/platform/ThreadTimers.cpp	2015-10-30 13:25:26 UTC (rev 191789)
@@ -27,6 +27,7 @@
 #include "config.h"
 #include "ThreadTimers.h"
 
+#include "MainThreadSharedTimer.h"
 #include "SharedTimer.h"
 #include "ThreadGlobalData.h"
 #include "Timer.h"
@@ -47,27 +48,21 @@
 // Timers are created, started and fired on the same thread, and each thread has its own ThreadTimers
 // copy to keep the heap and a set of currently firing timers.
 
-static MainThreadSharedTimer* mainThreadSharedTimer()
-{
-    static MainThreadSharedTimer* timer = new MainThreadSharedTimer;
-    return timer;
-}
-
 ThreadTimers::ThreadTimers()
     : m_sharedTimer(0)
     , m_firingTimers(false)
     , m_pendingSharedTimerFireTime(0)
 {
     if (isUIThread())
-        setSharedTimer(mainThreadSharedTimer());
+        setSharedTimer(&MainThreadSharedTimer::singleton());
 }
 
 // A worker thread may initialize SharedTimer after some timers are created.
-// Also, SharedTimer can be replaced with 0 before all timers are destroyed.
+// Also, SharedTimer can be replaced with nullptr before all timers are destroyed.
 void ThreadTimers::setSharedTimer(SharedTimer* sharedTimer)
 {
     if (m_sharedTimer) {
-        m_sharedTimer->setFiredFunction(0);
+        m_sharedTimer->setFiredFunction(nullptr);
         m_sharedTimer->stop();
         m_pendingSharedTimerFireTime = 0;
     }
@@ -75,7 +70,7 @@
     m_sharedTimer = sharedTimer;
     
     if (sharedTimer) {
-        m_sharedTimer->setFiredFunction(ThreadTimers::sharedTimerFired);
+        m_sharedTimer->setFiredFunction([] { threadGlobalData().threadTimers().sharedTimerFiredInternal(); });
         updateSharedTimer();
     }
 }
@@ -101,12 +96,6 @@
     }
 }
 
-void ThreadTimers::sharedTimerFired()
-{
-    // Redirect to non-static method.
-    threadGlobalData().threadTimers().sharedTimerFiredInternal();
-}
-
 void ThreadTimers::sharedTimerFiredInternal()
 {
     ASSERT(isMainThread() || (!isWebThread() && !isUIThread()));

Modified: trunk/Source/WebCore/platform/ThreadTimers.h (191788 => 191789)


--- trunk/Source/WebCore/platform/ThreadTimers.h	2015-10-30 12:46:55 UTC (rev 191788)
+++ trunk/Source/WebCore/platform/ThreadTimers.h	2015-10-30 13:25:26 UTC (rev 191789)
@@ -51,8 +51,6 @@
         void fireTimersInNestedEventLoop();
 
     private:
-        static void sharedTimerFired();
-
         void sharedTimerFiredInternal();
         void fireTimersInNestedEventLoopInternal();
 

Copied: trunk/Source/WebCore/platform/cf/MainThreadSharedTimerCF.cpp (from rev 191788, trunk/Source/WebCore/platform/cf/SharedTimerCF.cpp) (0 => 191789)


--- trunk/Source/WebCore/platform/cf/MainThreadSharedTimerCF.cpp	                        (rev 0)
+++ trunk/Source/WebCore/platform/cf/MainThreadSharedTimerCF.cpp	2015-10-30 13:25:26 UTC (rev 191789)
@@ -0,0 +1,125 @@
+/*
+ * Copyright (C) 2006, 2010, 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.
+ */
+
+#import "config.h"
+#import "MainThreadSharedTimer.h"
+
+#include <wtf/AutodrainedPool.h>
+
+#if PLATFORM(MAC)
+#import "PowerObserverMac.h"
+#elif PLATFORM(IOS)
+#import "WebCoreThread.h"
+#import "WebCoreThreadRun.h"
+#endif
+
+namespace WebCore {
+
+static CFRunLoopTimerRef sharedTimer;
+static void timerFired(CFRunLoopTimerRef, void*);
+static void restartSharedTimer();
+
+static const CFTimeInterval kCFTimeIntervalDistantFuture = std::numeric_limits<CFTimeInterval>::max();
+
+#if PLATFORM(IOS)
+static void applicationDidBecomeActive(CFNotificationCenterRef, void*, CFStringRef, const void*, CFDictionaryRef)
+{
+    WebThreadRun(^{
+        restartSharedTimer();
+    });
+}
+#endif
+
+static void setupPowerObserver()
+{
+#if PLATFORM(MAC)
+    static PowerObserver* powerObserver;
+    if (!powerObserver)
+        powerObserver = std::make_unique<PowerObserver>(restartSharedTimer).release();
+#elif PLATFORM(IOS)
+    static bool registeredForApplicationNotification = false;
+    if (!registeredForApplicationNotification) {
+        registeredForApplicationNotification = true;
+        CFNotificationCenterRef notificationCenter = CFNotificationCenterGetLocalCenter();
+        CFNotificationCenterAddObserver(notificationCenter, nullptr, applicationDidBecomeActive, CFSTR("UIApplicationDidBecomeActiveNotification"), nullptr, CFNotificationSuspensionBehaviorCoalesce);
+    }
+#endif
+}
+
+static void timerFired(CFRunLoopTimerRef, void*)
+{
+    AutodrainedPool pool;
+    MainThreadSharedTimer::singleton().fired();
+}
+
+static void restartSharedTimer()
+{
+    if (!sharedTimer)
+        return;
+
+    MainThreadSharedTimer::singleton().stop();
+    timerFired(0, 0);
+}
+
+void MainThreadSharedTimer::invalidate()
+{
+    if (!sharedTimer)
+        return;
+
+    CFRunLoopTimerInvalidate(sharedTimer);
+    CFRelease(sharedTimer);
+    sharedTimer = nullptr;
+}
+
+void MainThreadSharedTimer::setFireInterval(double interval)
+{
+    ASSERT(m_firedFunction);
+
+    CFAbsoluteTime fireDate = CFAbsoluteTimeGetCurrent() + interval;
+    if (!sharedTimer) {
+        sharedTimer = CFRunLoopTimerCreate(nullptr, fireDate, kCFTimeIntervalDistantFuture, 0, 0, timerFired, nullptr);
+#if PLATFORM(IOS)
+        CFRunLoopAddTimer(WebThreadRunLoop(), sharedTimer, kCFRunLoopCommonModes);
+#else
+        CFRunLoopAddTimer(CFRunLoopGetCurrent(), sharedTimer, kCFRunLoopCommonModes);
+#endif
+
+        setupPowerObserver();
+
+        return;
+    }
+
+    CFRunLoopTimerSetNextFireDate(sharedTimer, fireDate);
+}
+
+void MainThreadSharedTimer::stop()
+{
+    if (!sharedTimer)
+        return;
+
+    CFRunLoopTimerSetNextFireDate(sharedTimer, kCFTimeIntervalDistantFuture);
+}
+
+} // namespace WebCore

Deleted: trunk/Source/WebCore/platform/cf/SharedTimerCF.cpp (191788 => 191789)


--- trunk/Source/WebCore/platform/cf/SharedTimerCF.cpp	2015-10-30 12:46:55 UTC (rev 191788)
+++ trunk/Source/WebCore/platform/cf/SharedTimerCF.cpp	2015-10-30 13:25:26 UTC (rev 191789)
@@ -1,133 +0,0 @@
-/*
- * Copyright (C) 2006, 2010, 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.
- */
-
-#import "config.h"
-#import "SharedTimer.h"
-
-#include <wtf/AutodrainedPool.h>
-
-#if PLATFORM(MAC)
-#import "PowerObserverMac.h"
-#elif PLATFORM(IOS)
-#import "WebCoreThread.h"
-#import "WebCoreThreadRun.h"
-#endif
-
-namespace WebCore {
-
-static CFRunLoopTimerRef sharedTimer;
-static void (*sharedTimerFiredFunction)();
-static void timerFired(CFRunLoopTimerRef, void*);
-static void restartSharedTimer();
-
-static const CFTimeInterval kCFTimeIntervalDistantFuture = std::numeric_limits<CFTimeInterval>::max();
-
-#if PLATFORM(IOS)
-static void applicationDidBecomeActive(CFNotificationCenterRef, void*, CFStringRef, const void*, CFDictionaryRef)
-{
-    WebThreadRun(^{
-        restartSharedTimer();
-    });
-}
-#endif
-
-static void setupPowerObserver()
-{
-#if PLATFORM(MAC)
-    static PowerObserver* powerObserver;
-    if (!powerObserver)
-        powerObserver = std::make_unique<PowerObserver>(restartSharedTimer).release();
-#elif PLATFORM(IOS)
-    static bool registeredForApplicationNotification = false;
-    if (!registeredForApplicationNotification) {
-        registeredForApplicationNotification = true;
-        CFNotificationCenterRef notificationCenter = CFNotificationCenterGetLocalCenter();
-        CFNotificationCenterAddObserver(notificationCenter, nullptr, applicationDidBecomeActive, CFSTR("UIApplicationDidBecomeActiveNotification"), nullptr, CFNotificationSuspensionBehaviorCoalesce);
-    }
-#endif
-}
-
-void setSharedTimerFiredFunction(void (*f)())
-{
-    ASSERT(!sharedTimerFiredFunction || sharedTimerFiredFunction == f);
-
-    sharedTimerFiredFunction = f;
-}
-
-static void timerFired(CFRunLoopTimerRef, void*)
-{
-    AutodrainedPool pool;
-    sharedTimerFiredFunction();
-}
-
-static void restartSharedTimer()
-{
-    if (!sharedTimer)
-        return;
-
-    stopSharedTimer();
-    timerFired(0, 0);
-}
-
-void invalidateSharedTimer()
-{
-    if (!sharedTimer)
-        return;
-
-    CFRunLoopTimerInvalidate(sharedTimer);
-    CFRelease(sharedTimer);
-    sharedTimer = nullptr;
-}
-
-void setSharedTimerFireInterval(double interval)
-{
-    ASSERT(sharedTimerFiredFunction);
-
-    CFAbsoluteTime fireDate = CFAbsoluteTimeGetCurrent() + interval;
-    if (!sharedTimer) {
-        sharedTimer = CFRunLoopTimerCreate(nullptr, fireDate, kCFTimeIntervalDistantFuture, 0, 0, timerFired, nullptr);
-#if PLATFORM(IOS)
-        CFRunLoopAddTimer(WebThreadRunLoop(), sharedTimer, kCFRunLoopCommonModes);
-#else
-        CFRunLoopAddTimer(CFRunLoopGetCurrent(), sharedTimer, kCFRunLoopCommonModes);
-#endif
-
-        setupPowerObserver();
-
-        return;
-    }
-
-    CFRunLoopTimerSetNextFireDate(sharedTimer, fireDate);
-}
-
-void stopSharedTimer()
-{
-    if (!sharedTimer)
-        return;
-
-    CFRunLoopTimerSetNextFireDate(sharedTimer, kCFTimeIntervalDistantFuture);
-}
-
-} // namespace WebCore

Copied: trunk/Source/WebCore/platform/efl/MainThreadSharedTimerEfl.cpp (from rev 191788, trunk/Source/WebCore/platform/efl/SharedTimerEfl.cpp) (0 => 191789)


--- trunk/Source/WebCore/platform/efl/MainThreadSharedTimerEfl.cpp	                        (rev 0)
+++ trunk/Source/WebCore/platform/efl/MainThreadSharedTimerEfl.cpp	2015-10-30 13:25:26 UTC (rev 191789)
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2008 Kenneth Rohde Christiansen
+ *           (C) 2008 Afonso Rabelo Costa Jr.
+ *           (C) 2009-2010 ProFUSION embedded systems
+ *           (C) 2009-2010 Samsung Electronics
+ *
+ * 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 "MainThreadSharedTimer.h"
+
+#include <Ecore.h>
+#include <wtf/Assertions.h>
+#include <wtf/CurrentTime.h>
+#include <wtf/MainThread.h>
+
+namespace WebCore {
+
+static Ecore_Timer* sharedTimer;
+
+static Eina_Bool timerEvent(void*)
+{
+    sharedTimer = nullptr;
+    MainThreadSharedTimer::singleton().fired();
+    return ECORE_CALLBACK_CANCEL;
+}
+
+void MainThreadSharedTimer::stop()
+{
+    if (sharedTimer) {
+        ecore_timer_del(sharedTimer);
+        sharedTimer = nullptr;
+    }
+}
+
+void MainThreadSharedTimer::setFireInterval(double interval)
+{
+    stop();
+    sharedTimer = ecore_timer_loop_add(interval, timerEvent, nullptr);
+}
+
+void MainThreadSharedTimer::invalidate()
+{
+}
+
+}
+

Deleted: trunk/Source/WebCore/platform/efl/SharedTimerEfl.cpp (191788 => 191789)


--- trunk/Source/WebCore/platform/efl/SharedTimerEfl.cpp	2015-10-30 12:46:55 UTC (rev 191788)
+++ trunk/Source/WebCore/platform/efl/SharedTimerEfl.cpp	2015-10-30 13:25:26 UTC (rev 191789)
@@ -1,82 +0,0 @@
-/*
- * Copyright (C) 2008 Kenneth Rohde Christiansen
- *           (C) 2008 Afonso Rabelo Costa Jr.
- *           (C) 2009-2010 ProFUSION embedded systems
- *           (C) 2009-2010 Samsung Electronics
- *
- * 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 "SharedTimer.h"
-
-#include <Ecore.h>
-#include <wtf/Assertions.h>
-#include <wtf/CurrentTime.h>
-#include <wtf/MainThread.h>
-
-namespace WebCore {
-
-static Ecore_Timer *_sharedTimer = 0;
-
-static void (*_timerFunction)();
-
-void setSharedTimerFiredFunction(void (*func)())
-{
-    _timerFunction = func;
-}
-
-static Eina_Bool timerEvent(void*)
-{
-    _sharedTimer = 0;
-    if (_timerFunction)
-        _timerFunction();
-
-    return ECORE_CALLBACK_CANCEL;
-}
-
-void stopSharedTimer()
-{
-    if (_sharedTimer) {
-        ecore_timer_del(_sharedTimer);
-        _sharedTimer = 0;
-    }
-}
-
-void addNewTimer(double interval)
-{
-    stopSharedTimer();
-
-    _sharedTimer = ecore_timer_loop_add(interval, timerEvent, 0);
-}
-
-void setSharedTimerFireInterval(double interval)
-{
-    addNewTimer(interval);
-}
-
-void invalidateSharedTimer()
-{
-}
-
-}
-

Copied: trunk/Source/WebCore/platform/gtk/MainThreadSharedTimerGtk.cpp (from rev 191788, trunk/Source/WebCore/platform/gtk/SharedTimerGtk.cpp) (0 => 191789)


--- trunk/Source/WebCore/platform/gtk/MainThreadSharedTimerGtk.cpp	                        (rev 0)
+++ trunk/Source/WebCore/platform/gtk/MainThreadSharedTimerGtk.cpp	2015-10-30 13:25:26 UTC (rev 191789)
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2006 Apple Inc.  All rights reserved.
+ * Copyright (C) 2006 Michael Emmel [email protected]
+ * 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 "MainThreadSharedTimer.h"
+
+#include <wtf/glib/GMainLoopSource.h>
+
+namespace WebCore {
+
+static GMainLoopSource gSharedTimer;
+
+void MainThreadSharedTimer::setFireInterval(double interval)
+{
+    ASSERT(m_firedFunction);
+
+    // This is GDK_PRIORITY_REDRAW, but we don't want to depend on GDK here just to use a constant.
+    static const int priority = G_PRIORITY_HIGH_IDLE + 20;
+    gSharedTimer.scheduleAfterDelay("[WebKit] sharedTimerTimeoutCallback", [this] { fired(); },
+        std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::duration<double>(interval)), priority);
+}
+
+void MainThreadSharedTimer::stop()
+{
+    gSharedTimer.cancel();
+}
+
+void MainThreadSharedTimer::invalidate()
+{
+}
+
+}

Deleted: trunk/Source/WebCore/platform/gtk/SharedTimerGtk.cpp (191788 => 191789)


--- trunk/Source/WebCore/platform/gtk/SharedTimerGtk.cpp	2015-10-30 12:46:55 UTC (rev 191788)
+++ trunk/Source/WebCore/platform/gtk/SharedTimerGtk.cpp	2015-10-30 13:25:26 UTC (rev 191789)
@@ -1,64 +0,0 @@
-/*
- * Copyright (C) 2006 Apple Inc.  All rights reserved.
- * Copyright (C) 2006 Michael Emmel [email protected]
- * 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 "SharedTimer.h"
-
-#include <wtf/glib/GMainLoopSource.h>
-
-namespace WebCore {
-
-static GMainLoopSource gSharedTimer;
-static void (*sharedTimerFiredFunction)();
-
-void setSharedTimerFiredFunction(void (*f)())
-{
-    sharedTimerFiredFunction = f;
-    if (!sharedTimerFiredFunction)
-        gSharedTimer.cancel();
-}
-
-void setSharedTimerFireInterval(double interval)
-{
-    ASSERT(sharedTimerFiredFunction);
-
-    // This is GDK_PRIORITY_REDRAW, but we don't want to depend on GDK here just to use a constant.
-    static const int priority = G_PRIORITY_HIGH_IDLE + 20;
-    gSharedTimer.scheduleAfterDelay("[WebKit] sharedTimerTimeoutCallback", std::function<void()>(sharedTimerFiredFunction),
-        std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::duration<double>(interval)), priority);
-}
-
-void stopSharedTimer()
-{
-    gSharedTimer.cancel();
-}
-
-void invalidateSharedTimer()
-{
-}
-
-}

Copied: trunk/Source/WebCore/platform/win/MainThreadSharedTimerWin.cpp (from rev 191788, trunk/Source/WebCore/platform/win/SharedTimerWin.cpp) (0 => 191789)


--- trunk/Source/WebCore/platform/win/MainThreadSharedTimerWin.cpp	                        (rev 0)
+++ trunk/Source/WebCore/platform/win/MainThreadSharedTimerWin.cpp	2015-10-30 13:25:26 UTC (rev 191789)
@@ -0,0 +1,198 @@
+/*
+ * Copyright (C) 2006 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 "MainThreadSharedTimer.h"
+
+#include "Page.h"
+#include "Settings.h"
+#include "WebCoreInstanceHandle.h"
+#include "Widget.h"
+#include <wtf/Assertions.h>
+#include <wtf/CurrentTime.h>
+#include <wtf/WindowsExtras.h>
+
+#include <mmsystem.h>
+
+// These aren't in winuser.h with the MSVS 2003 Platform SDK, 
+// so use default values in that case.
+#ifndef USER_TIMER_MINIMUM
+#define USER_TIMER_MINIMUM 0x0000000A
+#endif
+
+#ifndef USER_TIMER_MAXIMUM
+#define USER_TIMER_MAXIMUM 0x7FFFFFFF
+#endif
+
+#ifndef QS_RAWINPUT
+#define QS_RAWINPUT         0x0400
+#endif
+
+namespace WebCore {
+
+static UINT timerID;
+
+static HANDLE timer;
+static HWND timerWindowHandle = 0;
+const LPCWSTR kTimerWindowClassName = L"TimerWindowClass";
+
+static UINT timerFiredMessage = 0;
+static HANDLE timerQueue;
+static bool highResTimerActive;
+static bool processingCustomTimerMessage = false;
+static LONG pendingTimers;
+
+const int timerResolution = 1; // To improve timer resolution, we call timeBeginPeriod/timeEndPeriod with this value to increase timer resolution to 1ms.
+const int highResolutionThresholdMsec = 16; // Only activate high-res timer for sub-16ms timers (Windows can fire timers at 16ms intervals without changing the system resolution).
+const int stopHighResTimerInMsec = 300; // Stop high-res timer after 0.3 seconds to lessen power consumption (we don't use a smaller time since oscillating between high and low resolution breaks timer accuracy on XP).
+
+enum {
+    sharedTimerID = 1000,
+    endHighResTimerID = 1001,
+};
+
+LRESULT CALLBACK TimerWindowWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
+{
+    if (message == WM_TIMER) {
+        if (wParam == sharedTimerID) {
+            KillTimer(timerWindowHandle, sharedTimerID);
+            MainThreadSharedTimer::singleton().fired();
+        } else if (wParam == endHighResTimerID) {
+            KillTimer(timerWindowHandle, endHighResTimerID);
+            highResTimerActive = false;
+            timeEndPeriod(timerResolution);
+        }
+    } else if (message == timerFiredMessage) {
+        InterlockedExchange(&pendingTimers, 0);
+        processingCustomTimerMessage = true;
+        MainThreadSharedTimer::singleton().fired();
+        processingCustomTimerMessage = false;
+    } else
+        return DefWindowProc(hWnd, message, wParam, lParam);
+
+    return 0;
+}
+
+static void initializeOffScreenTimerWindow()
+{
+    if (timerWindowHandle)
+        return;
+
+    WNDCLASSEX wcex;
+    memset(&wcex, 0, sizeof(WNDCLASSEX));
+    wcex.cbSize = sizeof(WNDCLASSEX);
+
+    wcex.lpfnWndProc    = TimerWindowWndProc;
+    wcex.hInstance      = WebCore::instanceHandle();
+    wcex.lpszClassName  = kTimerWindowClassName;
+    RegisterClassEx(&wcex);
+
+    timerWindowHandle = CreateWindow(kTimerWindowClassName, 0, 0,
+       CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, HWND_MESSAGE, 0, WebCore::instanceHandle(), 0);
+
+    timerFiredMessage = RegisterWindowMessage(L"com.apple.WebKit.TimerFired");
+}
+
+static void NTAPI queueTimerProc(PVOID, BOOLEAN)
+{
+    if (InterlockedIncrement(&pendingTimers) == 1)
+        PostMessage(timerWindowHandle, timerFiredMessage, 0, 0);
+}
+
+void MainThreadSharedTimer::setFireInterval(double interval)
+{
+    ASSERT(m_firedFunction);
+
+    unsigned intervalInMS;
+    interval *= 1000;
+    if (interval > USER_TIMER_MAXIMUM)
+        intervalInMS = USER_TIMER_MAXIMUM;
+    else
+        intervalInMS = static_cast<unsigned>(interval);
+
+    initializeOffScreenTimerWindow();
+    bool timerSet = false;
+
+    if (Settings::shouldUseHighResolutionTimers()) {
+        if (interval < highResolutionThresholdMsec) {
+            if (!highResTimerActive) {
+                highResTimerActive = true;
+                timeBeginPeriod(timerResolution);
+            }
+            SetTimer(timerWindowHandle, endHighResTimerID, stopHighResTimerInMsec, 0);
+        }
+
+        DWORD queueStatus = LOWORD(GetQueueStatus(QS_PAINT | QS_MOUSEBUTTON | QS_KEY | QS_RAWINPUT));
+
+        // Win32 has a tri-level queue with application messages > user input > WM_PAINT/WM_TIMER.
+
+        // If the queue doesn't contains input events, we use a higher priorty timer event posting mechanism.
+        if (!(queueStatus & (QS_MOUSEBUTTON | QS_KEY | QS_RAWINPUT))) {
+            if (intervalInMS < USER_TIMER_MINIMUM && !processingCustomTimerMessage && !(queueStatus & QS_PAINT)) {
+                // Call PostMessage immediately if the timer is already expired, unless a paint is pending.
+                // (we prioritize paints over timers)
+                if (InterlockedIncrement(&pendingTimers) == 1)
+                    PostMessage(timerWindowHandle, timerFiredMessage, 0, 0);
+                timerSet = true;
+            } else {
+                // Otherwise, delay the PostMessage via a CreateTimerQueueTimer
+                if (!timerQueue)
+                    timerQueue = CreateTimerQueue();
+                if (timer)
+                    DeleteTimerQueueTimer(timerQueue, timer, 0);
+                timerSet = CreateTimerQueueTimer(&timer, timerQueue, queueTimerProc, 0, intervalInMS, 0, WT_EXECUTEINTIMERTHREAD | WT_EXECUTEONLYONCE);
+            }
+        }
+    }
+
+    if (timerSet) {
+        if (timerID) {
+            KillTimer(timerWindowHandle, timerID);
+            timerID = 0;
+        }
+    } else {
+        timerID = SetTimer(timerWindowHandle, sharedTimerID, intervalInMS, 0);
+        timer = 0;
+    }
+}
+
+void MainThreadSharedTimer::stop()
+{
+    if (timerQueue && timer) {
+        DeleteTimerQueueTimer(timerQueue, timer, 0);
+        timer = 0;
+    }
+
+    if (timerID) {
+        KillTimer(timerWindowHandle, timerID);
+        timerID = 0;
+    }
+}
+
+void MainThreadSharedTimer::invalidate()
+{
+}
+
+}

Deleted: trunk/Source/WebCore/platform/win/SharedTimerWin.cpp (191788 => 191789)


--- trunk/Source/WebCore/platform/win/SharedTimerWin.cpp	2015-10-30 12:46:55 UTC (rev 191788)
+++ trunk/Source/WebCore/platform/win/SharedTimerWin.cpp	2015-10-30 13:25:26 UTC (rev 191789)
@@ -1,205 +0,0 @@
-/*
- * Copyright (C) 2006 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 "SharedTimer.h"
-
-#include "Page.h"
-#include "Settings.h"
-#include "WebCoreInstanceHandle.h"
-#include "Widget.h"
-#include <wtf/Assertions.h>
-#include <wtf/CurrentTime.h>
-#include <wtf/WindowsExtras.h>
-
-#include <mmsystem.h>
-
-// These aren't in winuser.h with the MSVS 2003 Platform SDK, 
-// so use default values in that case.
-#ifndef USER_TIMER_MINIMUM
-#define USER_TIMER_MINIMUM 0x0000000A
-#endif
-
-#ifndef USER_TIMER_MAXIMUM
-#define USER_TIMER_MAXIMUM 0x7FFFFFFF
-#endif
-
-#ifndef QS_RAWINPUT
-#define QS_RAWINPUT         0x0400
-#endif
-
-namespace WebCore {
-
-static UINT timerID;
-static void (*sharedTimerFiredFunction)();
-
-static HANDLE timer;
-static HWND timerWindowHandle = 0;
-const LPCWSTR kTimerWindowClassName = L"TimerWindowClass";
-
-static UINT timerFiredMessage = 0;
-static HANDLE timerQueue;
-static bool highResTimerActive;
-static bool processingCustomTimerMessage = false;
-static LONG pendingTimers;
-
-const int timerResolution = 1; // To improve timer resolution, we call timeBeginPeriod/timeEndPeriod with this value to increase timer resolution to 1ms.
-const int highResolutionThresholdMsec = 16; // Only activate high-res timer for sub-16ms timers (Windows can fire timers at 16ms intervals without changing the system resolution).
-const int stopHighResTimerInMsec = 300; // Stop high-res timer after 0.3 seconds to lessen power consumption (we don't use a smaller time since oscillating between high and low resolution breaks timer accuracy on XP).
-
-enum {
-    sharedTimerID = 1000,
-    endHighResTimerID = 1001,
-};
-
-LRESULT CALLBACK TimerWindowWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
-{
-    if (message == WM_TIMER) {
-        if (wParam == sharedTimerID) {
-            KillTimer(timerWindowHandle, sharedTimerID);
-            sharedTimerFiredFunction();
-        }
-        else if (wParam == endHighResTimerID) {
-            KillTimer(timerWindowHandle, endHighResTimerID);
-            highResTimerActive = false;
-            timeEndPeriod(timerResolution);
-        }
-    } else if (message == timerFiredMessage) {
-        InterlockedExchange(&pendingTimers, 0);
-        processingCustomTimerMessage = true;
-        sharedTimerFiredFunction();
-        processingCustomTimerMessage = false;
-    } else
-        return DefWindowProc(hWnd, message, wParam, lParam);
-
-    return 0;
-}
-
-static void initializeOffScreenTimerWindow()
-{
-    if (timerWindowHandle)
-        return;
-
-    WNDCLASSEX wcex;
-    memset(&wcex, 0, sizeof(WNDCLASSEX));
-    wcex.cbSize = sizeof(WNDCLASSEX);
-
-    wcex.lpfnWndProc    = TimerWindowWndProc;
-    wcex.hInstance      = WebCore::instanceHandle();
-    wcex.lpszClassName  = kTimerWindowClassName;
-    RegisterClassEx(&wcex);
-
-    timerWindowHandle = CreateWindow(kTimerWindowClassName, 0, 0,
-       CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, HWND_MESSAGE, 0, WebCore::instanceHandle(), 0);
-
-    timerFiredMessage = RegisterWindowMessage(L"com.apple.WebKit.TimerFired");
-}
-
-void setSharedTimerFiredFunction(void (*f)())
-{
-    sharedTimerFiredFunction = f;
-}
-
-static void NTAPI queueTimerProc(PVOID, BOOLEAN)
-{
-    if (InterlockedIncrement(&pendingTimers) == 1)
-        PostMessage(timerWindowHandle, timerFiredMessage, 0, 0);
-}
-
-void setSharedTimerFireInterval(double interval)
-{
-    ASSERT(sharedTimerFiredFunction);
-
-    unsigned intervalInMS;
-    interval *= 1000;
-    if (interval > USER_TIMER_MAXIMUM)
-        intervalInMS = USER_TIMER_MAXIMUM;
-    else
-        intervalInMS = static_cast<unsigned>(interval);
-
-    initializeOffScreenTimerWindow();
-    bool timerSet = false;
-
-    if (Settings::shouldUseHighResolutionTimers()) {
-        if (interval < highResolutionThresholdMsec) {
-            if (!highResTimerActive) {
-                highResTimerActive = true;
-                timeBeginPeriod(timerResolution);
-            }
-            SetTimer(timerWindowHandle, endHighResTimerID, stopHighResTimerInMsec, 0);
-        }
-
-        DWORD queueStatus = LOWORD(GetQueueStatus(QS_PAINT | QS_MOUSEBUTTON | QS_KEY | QS_RAWINPUT));
-
-        // Win32 has a tri-level queue with application messages > user input > WM_PAINT/WM_TIMER.
-
-        // If the queue doesn't contains input events, we use a higher priorty timer event posting mechanism.
-        if (!(queueStatus & (QS_MOUSEBUTTON | QS_KEY | QS_RAWINPUT))) {
-            if (intervalInMS < USER_TIMER_MINIMUM && !processingCustomTimerMessage && !(queueStatus & QS_PAINT)) {
-                // Call PostMessage immediately if the timer is already expired, unless a paint is pending.
-                // (we prioritize paints over timers)
-                if (InterlockedIncrement(&pendingTimers) == 1)
-                    PostMessage(timerWindowHandle, timerFiredMessage, 0, 0);
-                timerSet = true;
-            } else {
-                // Otherwise, delay the PostMessage via a CreateTimerQueueTimer
-                if (!timerQueue)
-                    timerQueue = CreateTimerQueue();
-                if (timer)
-                    DeleteTimerQueueTimer(timerQueue, timer, 0);
-                timerSet = CreateTimerQueueTimer(&timer, timerQueue, queueTimerProc, 0, intervalInMS, 0, WT_EXECUTEINTIMERTHREAD | WT_EXECUTEONLYONCE);
-            }
-        }
-    }
-
-    if (timerSet) {
-        if (timerID) {
-            KillTimer(timerWindowHandle, timerID);
-            timerID = 0;
-        }
-    } else {
-        timerID = SetTimer(timerWindowHandle, sharedTimerID, intervalInMS, 0);
-        timer = 0;
-    }
-}
-
-void stopSharedTimer()
-{
-    if (timerQueue && timer) {
-        DeleteTimerQueueTimer(timerQueue, timer, 0);
-        timer = 0;
-    }
-
-    if (timerID) {
-        KillTimer(timerWindowHandle, timerID);
-        timerID = 0;
-    }
-}
-
-void invalidateSharedTimer()
-{
-}
-
-}

Modified: trunk/Source/WebCore/workers/WorkerRunLoop.cpp (191788 => 191789)


--- trunk/Source/WebCore/workers/WorkerRunLoop.cpp	2015-10-30 12:46:55 UTC (rev 191788)
+++ trunk/Source/WebCore/workers/WorkerRunLoop.cpp	2015-10-30 13:25:26 UTC (rev 191789)
@@ -41,26 +41,20 @@
 
 namespace WebCore {
 
-class WorkerSharedTimer : public SharedTimer {
+class WorkerSharedTimer final : public SharedTimer {
 public:
-    WorkerSharedTimer()
-        : m_sharedTimerFunction(0)
-        , m_nextFireTime(0)
-    {
-    }
-
     // SharedTimer interface.
-    virtual void setFiredFunction(void (*function)()) { m_sharedTimerFunction = function; }
-    virtual void setFireInterval(double interval) { m_nextFireTime = interval + currentTime(); }
-    virtual void stop() { m_nextFireTime = 0; }
+    virtual void setFiredFunction(std::function<void()>&& function) override { m_sharedTimerFunction = WTF::move(function); }
+    virtual void setFireInterval(double interval) override { m_nextFireTime = interval + currentTime(); }
+    virtual void stop() override { m_nextFireTime = 0; }
 
     bool isActive() { return m_sharedTimerFunction && m_nextFireTime; }
     double fireTime() { return m_nextFireTime; }
     void fire() { m_sharedTimerFunction(); }
 
 private:
-    void (*m_sharedTimerFunction)();
-    double m_nextFireTime;
+    std::function<void()> m_sharedTimerFunction;
+    double m_nextFireTime { 0 };
 };
 
 class ModePredicate {
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to