[SCM] WebKit Debian packaging branch, webkit-1.3, updated. upstream/1.3.7-4207-g178b198

aroben at apple.com aroben at apple.com
Mon Feb 21 00:11:23 UTC 2011


The following commit has been merged in the webkit-1.3 branch:
commit 34cd1e02edc8af8292cccd4df19f5a054ff1f3ad
Author: aroben at apple.com <aroben at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Fri Jan 28 20:16:02 2011 +0000

    Change BinarySemaphore to wrap an auto-reset Win32 event on Windows
    
    Fixes <http://webkit.org/b/53208> <rdar://problem/8922490>.
    
    Reviewed by Dave Hyatt.
    
    Source/WebKit2:
    
    * Platform/CoreIPC/BinarySemaphore.cpp: Wrap this implementation in #if !PLATFORM(WIN).
    
    * Platform/CoreIPC/BinarySemaphore.h: Make the Windows implementation have a single HANDLE
    member that holds the event.
    
    * Platform/CoreIPC/win/BinarySemaphoreWin.cpp: Copied from Source/WebKit2/Platform/CoreIPC/BinarySemaphore.cpp.
    (CoreIPC::BinarySemaphore::BinarySemaphore): Create our event.
    (CoreIPC::BinarySemaphore::~BinarySemaphore): Destory our event.
    (CoreIPC::BinarySemaphore::signal): Signal the event.
    (CoreIPC::BinarySemaphore::wait): Convert the absolute time to a wait interval, then wait
    for the event to be signaled or for the interval to elapse.
    
    * win/WebKit2.vcproj: Added BinarySemaphoreWin.cpp. Also let VS have its way with the file.
    
    Source/JavaScriptCore:
    
    Extract code to convert a WTF absolute time to a Win32 wait interval into a separate
    function
    
    * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def: Export the new function.
    
    * wtf/ThreadingPrimitives.h: Declare the new function.
    
    * wtf/ThreadingWin.cpp:
    (WTF::ThreadCondition::timedWait): Moved code to convert the absolute time to a wait
    interval from here...
    (WTF::absoluteTimeToWaitTimeoutInterval): ...to here.
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@76967 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/Source/JavaScriptCore/ChangeLog b/Source/JavaScriptCore/ChangeLog
index e2b6980..bde0be9 100644
--- a/Source/JavaScriptCore/ChangeLog
+++ b/Source/JavaScriptCore/ChangeLog
@@ -1,3 +1,22 @@
+2011-01-27  Adam Roben  <aroben at apple.com>
+
+        Extract code to convert a WTF absolute time to a Win32 wait interval into a separate
+        function
+
+        Fixes <http://webkit.org/b/53208> <rdar://problem/8922490> BinarySemaphore should wrap a
+        Win32 event
+
+        Reviewed by Dave Hyatt.
+
+        * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def: Export the new function.
+
+        * wtf/ThreadingPrimitives.h: Declare the new function.
+
+        * wtf/ThreadingWin.cpp:
+        (WTF::ThreadCondition::timedWait): Moved code to convert the absolute time to a wait
+        interval from here...
+        (WTF::absoluteTimeToWaitTimeoutInterval): ...to here.
+
 2011-01-28  Sam Weinig  <sam at webkit.org>
 
         Reviewed by Maciej Stachowiak.
diff --git a/Source/JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def b/Source/JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def
index 013736a..f8786b5 100644
--- a/Source/JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def
+++ b/Source/JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def
@@ -43,6 +43,7 @@ EXPORTS
     ??8JSC@@YA_NABVUString at 0@0 at Z
     ??8WTF@@YA_NABVCString at 0@0 at Z
     ?NaN at JSC@@3NB
+    ?absoluteTimeToWaitTimeoutInterval at WTF@@YAKN at Z
     ?add at Identifier@JSC@@SA?AV?$PassRefPtr at VStringImpl@WTF@@@WTF@@PAVExecState at 2@PBD at Z
     ?add at PropertyNameArray@JSC@@QAEXPAVStringImpl at WTF@@@Z
     ?addBytes at MD5@WTF@@QAEXPBEI at Z
diff --git a/Source/JavaScriptCore/wtf/ThreadingPrimitives.h b/Source/JavaScriptCore/wtf/ThreadingPrimitives.h
index 809c3e2..7596e6d 100644
--- a/Source/JavaScriptCore/wtf/ThreadingPrimitives.h
+++ b/Source/JavaScriptCore/wtf/ThreadingPrimitives.h
@@ -150,10 +150,20 @@ private:
     PlatformCondition m_condition;
 };
 
+#if PLATFORM(WIN)
+// The absoluteTime is in seconds, starting on January 1, 1970. The time is assumed to use the same time zone as WTF::currentTime().
+// Returns an interval in milliseconds suitable for passing to one of the Win32 wait functions (e.g., ::WaitForSingleObject).
+DWORD absoluteTimeToWaitTimeoutInterval(double absoluteTime);
+#endif
+
 } // namespace WTF
 
 using WTF::Mutex;
 using WTF::MutexLocker;
 using WTF::ThreadCondition;
 
+#if PLATFORM(WIN)
+using WTF::absoluteTimeToWaitTimeoutInterval;
+#endif
+
 #endif // ThreadingPrimitives_h
diff --git a/Source/JavaScriptCore/wtf/ThreadingWin.cpp b/Source/JavaScriptCore/wtf/ThreadingWin.cpp
index 00319a4..9775994 100644
--- a/Source/JavaScriptCore/wtf/ThreadingWin.cpp
+++ b/Source/JavaScriptCore/wtf/ThreadingWin.cpp
@@ -458,20 +458,15 @@ void ThreadCondition::wait(Mutex& mutex)
 
 bool ThreadCondition::timedWait(Mutex& mutex, double absoluteTime)
 {
-    double currentTime = WTF::currentTime();
+    DWORD interval = absoluteTimeToWaitTimeoutInterval(absoluteTime);
 
-    // Time is in the past - return immediately.
-    if (absoluteTime < currentTime)
+    if (!interval) {
+        // Consider the wait to have timed out, even if our condition has already been signaled, to
+        // match the pthreads implementation.
         return false;
-
-    // Time is too far in the future (and would overflow unsigned long) - wait forever.
-    if (absoluteTime - currentTime > static_cast<double>(INT_MAX) / 1000.0) {
-        wait(mutex);
-        return true;
     }
 
-    double intervalMilliseconds = (absoluteTime - currentTime) * 1000.0;
-    return m_condition.timedWait(mutex.impl(), static_cast<unsigned long>(intervalMilliseconds));
+    return m_condition.timedWait(mutex.impl(), interval);
 }
 
 void ThreadCondition::signal()
@@ -484,4 +479,19 @@ void ThreadCondition::broadcast()
     m_condition.signal(true); // Unblock all threads.
 }
 
+DWORD absoluteTimeToWaitTimeoutInterval(double absoluteTime)
+{
+    double currentTime = WTF::currentTime();
+
+    // Time is in the past - return immediately.
+    if (absoluteTime < currentTime)
+        return 0;
+
+    // Time is too far in the future (and would overflow unsigned long) - wait forever.
+    if (absoluteTime - currentTime > static_cast<double>(INT_MAX) / 1000.0)
+        return INFINITE;
+
+    return (absoluteTime - currentTime) * 1000;
+}
+
 } // namespace WTF
diff --git a/Source/WebKit2/ChangeLog b/Source/WebKit2/ChangeLog
index aa0b6ad..81c2c08 100644
--- a/Source/WebKit2/ChangeLog
+++ b/Source/WebKit2/ChangeLog
@@ -1,3 +1,25 @@
+2011-01-27  Adam Roben  <aroben at apple.com>
+
+        Change BinarySemaphore to wrap an auto-reset Win32 event on Windows
+
+        Fixes <http://webkit.org/b/53208> <rdar://problem/8922490>.
+
+        Reviewed by Dave Hyatt.
+
+        * Platform/CoreIPC/BinarySemaphore.cpp: Wrap this implementation in #if !PLATFORM(WIN).
+
+        * Platform/CoreIPC/BinarySemaphore.h: Make the Windows implementation have a single HANDLE
+        member that holds the event.
+
+        * Platform/CoreIPC/win/BinarySemaphoreWin.cpp: Copied from Source/WebKit2/Platform/CoreIPC/BinarySemaphore.cpp.
+        (CoreIPC::BinarySemaphore::BinarySemaphore): Create our event.
+        (CoreIPC::BinarySemaphore::~BinarySemaphore): Destory our event.
+        (CoreIPC::BinarySemaphore::signal): Signal the event.
+        (CoreIPC::BinarySemaphore::wait): Convert the absolute time to a wait interval, then wait
+        for the event to be signaled or for the interval to elapse.
+
+        * win/WebKit2.vcproj: Added BinarySemaphoreWin.cpp. Also let VS have its way with the file.
+
 2011-01-27  Chris Marrin  <cmarrin at apple.com>
 
         Reviewed by Anders Carlsson.
diff --git a/Source/WebKit2/Platform/CoreIPC/BinarySemaphore.cpp b/Source/WebKit2/Platform/CoreIPC/BinarySemaphore.cpp
index 73b3cfc..d4d9e7d 100644
--- a/Source/WebKit2/Platform/CoreIPC/BinarySemaphore.cpp
+++ b/Source/WebKit2/Platform/CoreIPC/BinarySemaphore.cpp
@@ -28,6 +28,8 @@
 
 namespace CoreIPC {
 
+#if !PLATFORM(WIN)
+
 BinarySemaphore::BinarySemaphore()
     : m_isSet(false)
 {
@@ -61,5 +63,6 @@ bool BinarySemaphore::wait(double absoluteTime)
     return true;
 }
 
+#endif // !PLATFORM(WIN)
 
 } // namespace CoreIPC
diff --git a/Source/WebKit2/Platform/CoreIPC/BinarySemaphore.h b/Source/WebKit2/Platform/CoreIPC/BinarySemaphore.h
index 8113236..32b5b02 100644
--- a/Source/WebKit2/Platform/CoreIPC/BinarySemaphore.h
+++ b/Source/WebKit2/Platform/CoreIPC/BinarySemaphore.h
@@ -42,10 +42,14 @@ public:
     bool wait(double absoluteTime);
 
 private:
+#if PLATFORM(WIN)
+    HANDLE m_event;
+#else
     bool m_isSet;
 
     Mutex m_mutex;
     ThreadCondition m_condition;
+#endif
 };
 
 } // namespace CoreIPC
diff --git a/Source/WebKit2/Platform/CoreIPC/win/BinarySemaphoreWin.cpp b/Source/WebKit2/Platform/CoreIPC/win/BinarySemaphoreWin.cpp
new file mode 100644
index 0000000..9b26a9a
--- /dev/null
+++ b/Source/WebKit2/Platform/CoreIPC/win/BinarySemaphoreWin.cpp
@@ -0,0 +1,74 @@
+/*
+ * Copyright (C) 2011 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 "BinarySemaphore.h"
+
+namespace CoreIPC {
+
+BinarySemaphore::BinarySemaphore()
+    : m_event(::CreateEventW(0, FALSE, FALSE, 0))
+{
+}
+
+BinarySemaphore::~BinarySemaphore()
+{
+    ::CloseHandle(m_event);
+}
+
+void BinarySemaphore::signal()
+{
+    ::SetEvent(m_event);
+}
+
+bool BinarySemaphore::wait(double absoluteTime)
+{
+    DWORD interval = absoluteTimeToWaitTimeoutInterval(absoluteTime);
+    if (!interval) {
+        // Consider the wait to have timed out, even if the event has already been signaled, to
+        // match the WTF::ThreadCondition implementation.
+        return false;
+    }
+
+    DWORD result = ::WaitForSingleObjectEx(m_event, interval, FALSE);
+    switch (result) {
+    case WAIT_OBJECT_0:
+        // The event was signaled.
+        return true;
+
+    case WAIT_TIMEOUT:
+        // The wait timed out.
+        return false;
+
+    case WAIT_FAILED:
+        ASSERT_WITH_MESSAGE(false, "::WaitForSingleObjectEx failed with error %lu", ::GetLastError());
+        return false;
+    default:
+        ASSERT_WITH_MESSAGE(false, "::WaitForSingleObjectEx returned unexpected result %lu", result);
+        return false;
+    }
+}
+
+} // namespace CoreIPC
diff --git a/Source/WebKit2/win/WebKit2.vcproj b/Source/WebKit2/win/WebKit2.vcproj
index 19ccd7b..0f6cbe9 100755
--- a/Source/WebKit2/win/WebKit2.vcproj
+++ b/Source/WebKit2/win/WebKit2.vcproj
@@ -399,14 +399,6 @@
 				>
 			</File>
 			<File
-				RelativePath="..\Shared\ShareableBitmap.cpp"
-				>
-			</File>
-			<File
-				RelativePath="..\Shared\ShareableBitmap.h"
-				>
-			</File>
-			<File
 				RelativePath="..\Shared\CacheModel.h"
 				>
 			</File>
@@ -515,6 +507,14 @@
 				>
 			</File>
 			<File
+				RelativePath="..\Shared\ShareableBitmap.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\Shared\ShareableBitmap.h"
+				>
+			</File>
+			<File
 				RelativePath="..\Shared\StringPairVector.h"
 				>
 			</File>
@@ -1808,23 +1808,23 @@
 							>
 						</File>
 						<File
-							RelativePath="..\WebProcess\InjectedBundle\API\c\WKBundleInspector.cpp"
+							RelativePath="..\WebProcess\InjectedBundle\API\c\WKBundleHitTestResult.cpp"
 							>
 						</File>
 						<File
-							RelativePath="..\WebProcess\InjectedBundle\API\c\WKBundleInspector.h"
+							RelativePath="..\WebProcess\InjectedBundle\API\c\WKBundleHitTestResult.h"
 							>
 						</File>
 						<File
-							RelativePath="..\WebProcess\InjectedBundle\API\c\WKBundleHitTestResult.cpp"
+							RelativePath="..\WebProcess\InjectedBundle\API\c\WKBundleInitialize.h"
 							>
 						</File>
 						<File
-							RelativePath="..\WebProcess\InjectedBundle\API\c\WKBundleHitTestResult.h"
+							RelativePath="..\WebProcess\InjectedBundle\API\c\WKBundleInspector.cpp"
 							>
 						</File>
 						<File
-							RelativePath="..\WebProcess\InjectedBundle\API\c\WKBundleInitialize.h"
+							RelativePath="..\WebProcess\InjectedBundle\API\c\WKBundleInspector.h"
 							>
 						</File>
 						<File
@@ -2977,6 +2977,10 @@
 					Name="win"
 					>
 					<File
+						RelativePath="..\Platform\CoreIPC\win\BinarySemaphoreWin.cpp"
+						>
+					</File>
+					<File
 						RelativePath="..\Platform\CoreIPC\win\ConnectionWin.cpp"
 						>
 					</File>

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list