Title: [88123] trunk/Source
Revision
88123
Author
[email protected]
Date
2011-06-04 14:03:29 -0700 (Sat, 04 Jun 2011)

Log Message

2011-06-04  Darin Adler  <[email protected]>

        Reviewed by Anders Carlsson.

        [Mac WebKit2] REGRESSION (r86692): Synchronous XMLHttpRequest hangs in credential shim (affects Netgear ReadyNAS admin page)
        https://bugs.webkit.org/show_bug.cgi?id=62094
        rdar://problem/9539204

        * WebCore.exp.in: Export ResourceHandle::synchronousLoadRunLoopMode.
        * platform/network/ResourceHandle.h: Add synchronousLoadRunLoopMode.
        * platform/network/cf/ResourceHandleCFNet.cpp:
        (WebCore::ResourceHandle::synchronousLoadRunLoopMode): Added.
        (WebCore::ResourceHandle::loadResourceSynchronously): Call synchronousLoadRunLoopMode.
        * platform/network/mac/ResourceHandleMac.mm:
        (WebCore::ResourceHandle::synchronousLoadRunLoopMode): Added.
        (WebCore::ResourceHandle::loadResourceSynchronously): Call synchronousLoadRunLoopMode.
2011-06-04  Darin Adler  <[email protected]>

        Reviewed by Anders Carlsson.

        [Mac WebKit2] REGRESSION (r86692): Synchronous XMLHttpRequest hangs in credential shim (affects Netgear ReadyNAS admin page)
        https://bugs.webkit.org/show_bug.cgi?id=62094
        rdar://problem/9539204

        * WebKit2.xcodeproj/project.pbxproj: Added new source files.
        * WebProcess/mac/CoreIPCClientRunLoop.h: Added.
        * WebProcess/mac/CoreIPCClientRunLoop.mm: Added.
        (-[WKFunctionAdapter perform]): Added.
        (WebKit::createCoreIPCRunLoopModesArray): Added.
        (WebKit::coreIPCRunLoopModesArray): Added.
        (WebKit::callOnCoreIPCClientRunLoopAndWait): Added.

        * WebProcess/mac/KeychainItemShimMethods.mm:
        (WebKit::webFreeAttributeListContent): Use callOnCoreIPCClientRunLoopAndWait.
        (WebKit::webFreeKeychainItemContent): Ditto.
        (WebKit::webSecKeychainItemCopyContent): Ditto.
        (WebKit::webSecKeychainItemCreateFromContent): Ditto.
        (WebKit::webSecKeychainItemModifyContent): Ditto.
        * WebProcess/mac/SecItemShimMethods.mm:
        (WebKit::webSecItemCopyMatching): Ditto.
        (WebKit::webSecItemAdd): Ditto.
        (WebKit::webSecItemUpdate): Ditto.
        (WebKit::webSecItemDelete): Ditto.

Modified Paths

Added Paths

Property Changed

Diff

Modified: trunk/Source/WebCore/ChangeLog (88122 => 88123)


--- trunk/Source/WebCore/ChangeLog	2011-06-04 19:34:29 UTC (rev 88122)
+++ trunk/Source/WebCore/ChangeLog	2011-06-04 21:03:29 UTC (rev 88123)
@@ -1,3 +1,20 @@
+2011-06-04  Darin Adler  <[email protected]>
+
+        Reviewed by Anders Carlsson.
+
+        [Mac WebKit2] REGRESSION (r86692): Synchronous XMLHttpRequest hangs in credential shim (affects Netgear ReadyNAS admin page)
+        https://bugs.webkit.org/show_bug.cgi?id=62094
+        rdar://problem/9539204
+
+        * WebCore.exp.in: Export ResourceHandle::synchronousLoadRunLoopMode.
+        * platform/network/ResourceHandle.h: Add synchronousLoadRunLoopMode.
+        * platform/network/cf/ResourceHandleCFNet.cpp:
+        (WebCore::ResourceHandle::synchronousLoadRunLoopMode): Added.
+        (WebCore::ResourceHandle::loadResourceSynchronously): Call synchronousLoadRunLoopMode.
+        * platform/network/mac/ResourceHandleMac.mm:
+        (WebCore::ResourceHandle::synchronousLoadRunLoopMode): Added.
+        (WebCore::ResourceHandle::loadResourceSynchronously): Call synchronousLoadRunLoopMode.
+
 2011-06-04  Eric Seidel  <[email protected]>
 
         Reviewed by Adam Barth.

Modified: trunk/Source/WebCore/WebCore.exp.in (88122 => 88123)


--- trunk/Source/WebCore/WebCore.exp.in	2011-06-04 19:34:29 UTC (rev 88122)
+++ trunk/Source/WebCore/WebCore.exp.in	2011-06-04 21:03:29 UTC (rev 88123)
@@ -359,6 +359,7 @@
 __ZN7WebCore14FrameSelectionC1EPNS_5FrameE
 __ZN7WebCore14ResourceHandle12releaseProxyEv
 __ZN7WebCore14ResourceHandle20forceContentSniffingEv
+__ZN7WebCore14ResourceHandle26synchronousLoadRunLoopModeEv
 __ZN7WebCore14ResourceLoader14cancelledErrorEv
 __ZN7WebCore14ResourceLoader19setShouldBufferDataEb
 __ZN7WebCore14SVGSMILElement13isSMILElementEPNS_4NodeE

Modified: trunk/Source/WebCore/platform/network/ResourceHandle.h (88122 => 88123)


--- trunk/Source/WebCore/platform/network/ResourceHandle.h	2011-06-04 19:34:29 UTC (rev 88122)
+++ trunk/Source/WebCore/platform/network/ResourceHandle.h	2011-06-04 21:03:29 UTC (rev 88123)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2004, 2006 Apple Computer, Inc.  All rights reserved.
+ * Copyright (C) 2004, 2006, 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
@@ -48,7 +48,6 @@
 typedef LPVOID HINTERNET;
 #endif
 
-
 #if PLATFORM(MAC)
 #include <wtf/RetainPtr.h>
 #ifdef __OBJC__
@@ -79,7 +78,6 @@
 
 class AuthenticationChallenge;
 class Credential;
-class FormData;
 class Frame;
 class KURL;
 class ProtectionSpace;
@@ -207,6 +205,10 @@
     using RefCounted<ResourceHandle>::ref;
     using RefCounted<ResourceHandle>::deref;
 
+#if PLATFORM(MAC) || USE(CFNETWORK)
+    static CFStringRef synchronousLoadRunLoopMode();
+#endif
+
 protected:
     ResourceHandle(const ResourceRequest&, ResourceHandleClient*, bool defersLoading, bool shouldContentSniff);
 

Modified: trunk/Source/WebCore/platform/network/cf/ResourceHandleCFNet.cpp (88122 => 88123)


--- trunk/Source/WebCore/platform/network/cf/ResourceHandleCFNet.cpp	2011-06-04 19:34:29 UTC (rev 88122)
+++ trunk/Source/WebCore/platform/network/cf/ResourceHandleCFNet.cpp	2011-06-04 21:03:29 UTC (rev 88123)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2004, 2005, 2006, 2007, 2009 Apple Inc. All rights reserved.
+ * Copyright (C) 2004, 2005, 2006, 2007, 2009, 2010, 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
@@ -27,8 +27,6 @@
 
 #if USE(CFNETWORK)
 
-#include "ResourceHandle.h"
-#include "ResourceHandleClient.h"
 #include "ResourceHandleInternal.h"
 
 #include "AuthenticationCF.h"
@@ -44,6 +42,7 @@
 #include "Logging.h"
 #include "MIMETypeRegistry.h"
 #include "ResourceError.h"
+#include "ResourceHandleClient.h"
 #include "ResourceResponse.h"
 #include "SharedBuffer.h"
 #include <CFNetwork/CFNetwork.h>
@@ -66,8 +65,6 @@
 
 namespace WebCore {
 
-static CFStringRef WebCoreSynchronousLoaderRunLoopMode = CFSTR("WebCoreSynchronousLoaderRunLoopMode");
-
 class WebCoreSynchronousLoaderClient : public ResourceHandleClient {
 public:
     static PassOwnPtr<WebCoreSynchronousLoaderClient> create(ResourceResponse& response, ResourceError& error)
@@ -621,6 +618,11 @@
     return d->m_connection.releaseRef();
 }
 
+CFStringRef ResourceHandle::synchronousLoadRunLoopMode()
+{
+    return CFSTR("WebCoreSynchronousLoaderRunLoopMode");
+}
+
 void ResourceHandle::loadResourceSynchronously(NetworkingContext* context, const ResourceRequest& request, StoredCredentials storedCredentials, ResourceError& error, ResourceResponse& response, Vector<char>& vector)
 {
     LOG(Network, "ResourceHandle::loadResourceSynchronously:%s allowStoredCredentials:%u", request.url().string().utf8().data(), storedCredentials);
@@ -644,12 +646,12 @@
 
     handle->createCFURLConnection(storedCredentials == AllowStoredCredentials, ResourceHandle::shouldContentSniffURL(request.url()));
 
-    CFURLConnectionScheduleWithRunLoop(handle->connection(), CFRunLoopGetCurrent(), WebCoreSynchronousLoaderRunLoopMode);
-    CFURLConnectionScheduleDownloadWithRunLoop(handle->connection(), CFRunLoopGetCurrent(), WebCoreSynchronousLoaderRunLoopMode);
+    CFURLConnectionScheduleWithRunLoop(handle->connection(), CFRunLoopGetCurrent(), synchronousLoadRunLoopMode());
+    CFURLConnectionScheduleDownloadWithRunLoop(handle->connection(), CFRunLoopGetCurrent(), synchronousLoadRunLoopMode());
     CFURLConnectionStart(handle->connection());
 
     while (!client->isDone())
-        CFRunLoopRunInMode(WebCoreSynchronousLoaderRunLoopMode, UINT_MAX, true);
+        CFRunLoopRunInMode(synchronousLoadRunLoopMode(), UINT_MAX, true);
 
     CFURLConnectionCancel(handle->connection());
     

Modified: trunk/Source/WebCore/platform/network/mac/ResourceHandleMac.mm (88122 => 88123)


--- trunk/Source/WebCore/platform/network/mac/ResourceHandleMac.mm	2011-06-04 19:34:29 UTC (rev 88122)
+++ trunk/Source/WebCore/platform/network/mac/ResourceHandleMac.mm	2011-06-04 21:03:29 UTC (rev 88123)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2004, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved.
+ * Copyright (C) 2004, 2006, 2007, 2008, 2009, 2010, 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
@@ -54,7 +54,6 @@
 #import <wtf/text/CString.h>
 #import <wtf/UnusedParam.h>
 
-
 using namespace WebCore;
 
 @interface WebCoreResourceHandleAsDelegate : NSObject <NSURLConnectionDelegate> {
@@ -83,7 +82,6 @@
 - (id)_propertyForKey:(NSString *)key;
 @end
 
-
 class WebCoreSynchronousLoaderClient : public ResourceHandleClient {
 public:
     static PassOwnPtr<WebCoreSynchronousLoaderClient> create()
@@ -127,12 +125,8 @@
     bool m_isDone;
 };
 
-static NSString *WebCoreSynchronousLoaderRunLoopMode = @"WebCoreSynchronousLoaderRunLoopMode";
-
-
 namespace WebCore {
 
-
 #ifndef NDEBUG
 static bool isInitializingConnection;
 #endif
@@ -423,6 +417,11 @@
     return nsURLResponse;
 }
 
+CFStringRef ResourceHandle::synchronousLoadRunLoopMode()
+{
+    return CFSTR("WebCoreSynchronousLoaderRunLoopMode");
+}
+
 void ResourceHandle::loadResourceSynchronously(NetworkingContext* context, const ResourceRequest& request, StoredCredentials storedCredentials, ResourceError& error, ResourceResponse& response, Vector<char>& data)
 {
     LOG(Network, "ResourceHandle::loadResourceSynchronously:%@ allowStoredCredentials:%u", request.nsURLRequest(), storedCredentials);
@@ -454,11 +453,11 @@
         storedCredentials == AllowStoredCredentials,
         handle->shouldContentSniff() || (context && context->localFileContentSniffingEnabled()));
 
-    [handle->connection() scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:WebCoreSynchronousLoaderRunLoopMode];
+    [handle->connection() scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:(NSString *)synchronousLoadRunLoopMode()];
     [handle->connection() start];
     
     while (!client->isDone())
-        [[NSRunLoop currentRunLoop] runMode:WebCoreSynchronousLoaderRunLoopMode beforeDate:[NSDate distantFuture]];
+        [[NSRunLoop currentRunLoop] runMode:(NSString *)synchronousLoadRunLoopMode() beforeDate:[NSDate distantFuture]];
 
     result = client->data();
     nsURLResponse = client->response();

Modified: trunk/Source/WebKit2/ChangeLog (88122 => 88123)


--- trunk/Source/WebKit2/ChangeLog	2011-06-04 19:34:29 UTC (rev 88122)
+++ trunk/Source/WebKit2/ChangeLog	2011-06-04 21:03:29 UTC (rev 88123)
@@ -1,3 +1,31 @@
+2011-06-04  Darin Adler  <[email protected]>
+
+        Reviewed by Anders Carlsson.
+
+        [Mac WebKit2] REGRESSION (r86692): Synchronous XMLHttpRequest hangs in credential shim (affects Netgear ReadyNAS admin page)
+        https://bugs.webkit.org/show_bug.cgi?id=62094
+        rdar://problem/9539204
+
+        * WebKit2.xcodeproj/project.pbxproj: Added new source files.
+        * WebProcess/mac/CoreIPCClientRunLoop.h: Added.
+        * WebProcess/mac/CoreIPCClientRunLoop.mm: Added.
+        (-[WKFunctionAdapter perform]): Added.
+        (WebKit::createCoreIPCRunLoopModesArray): Added.
+        (WebKit::coreIPCRunLoopModesArray): Added.
+        (WebKit::callOnCoreIPCClientRunLoopAndWait): Added.
+
+        * WebProcess/mac/KeychainItemShimMethods.mm:
+        (WebKit::webFreeAttributeListContent): Use callOnCoreIPCClientRunLoopAndWait.
+        (WebKit::webFreeKeychainItemContent): Ditto.
+        (WebKit::webSecKeychainItemCopyContent): Ditto.
+        (WebKit::webSecKeychainItemCreateFromContent): Ditto.
+        (WebKit::webSecKeychainItemModifyContent): Ditto.
+        * WebProcess/mac/SecItemShimMethods.mm:
+        (WebKit::webSecItemCopyMatching): Ditto.
+        (WebKit::webSecItemAdd): Ditto.
+        (WebKit::webSecItemUpdate): Ditto.
+        (WebKit::webSecItemDelete): Ditto.
+
 2011-06-04  Sam Weinig  <[email protected]>
 
         Reviewed by Anders Carlsson.

Modified: trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj (88122 => 88123)


--- trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj	2011-06-04 19:34:29 UTC (rev 88122)
+++ trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj	2011-06-04 21:03:29 UTC (rev 88123)
@@ -410,6 +410,8 @@
 		9391F2CB121B67AD00EBF7E8 /* WebFrameNetworkingContext.h in Headers */ = {isa = PBXBuildFile; fileRef = 9391F283121B38F500EBF7E8 /* WebFrameNetworkingContext.h */; };
 		939AE7661316E99C00AE06A6 /* WebCoreArgumentCoders.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 939AE7651316E99C00AE06A6 /* WebCoreArgumentCoders.cpp */; };
 		939AE7681316E9AD00AE06A6 /* WebCoreArgumentCodersCG.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 939AE7671316E9AD00AE06A6 /* WebCoreArgumentCodersCG.cpp */; };
+		93C01DAC139AC91700ED51D7 /* CoreIPCClientRunLoop.h in Headers */ = {isa = PBXBuildFile; fileRef = 93C01DAA139AC91700ED51D7 /* CoreIPCClientRunLoop.h */; };
+		93C01DAD139AC91700ED51D7 /* CoreIPCClientRunLoop.mm in Sources */ = {isa = PBXBuildFile; fileRef = 93C01DAB139AC91700ED51D7 /* CoreIPCClientRunLoop.mm */; };
 		93FC67BD12D3CCF200A60610 /* DecoderAdapter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 93FC679D12D3CC7400A60610 /* DecoderAdapter.cpp */; };
 		93FC67BE12D3CCF200A60610 /* DecoderAdapter.h in Headers */ = {isa = PBXBuildFile; fileRef = 93FC679E12D3CC7400A60610 /* DecoderAdapter.h */; };
 		93FC67BF12D3CCF200A60610 /* EncoderAdapter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 93FC679F12D3CC7400A60610 /* EncoderAdapter.cpp */; };
@@ -1346,6 +1348,8 @@
 		9391F284121B38F500EBF7E8 /* WebFrameNetworkingContext.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebFrameNetworkingContext.mm; sourceTree = "<group>"; };
 		939AE7651316E99C00AE06A6 /* WebCoreArgumentCoders.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebCoreArgumentCoders.cpp; sourceTree = "<group>"; };
 		939AE7671316E9AD00AE06A6 /* WebCoreArgumentCodersCG.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebCoreArgumentCodersCG.cpp; sourceTree = "<group>"; };
+		93C01DAA139AC91700ED51D7 /* CoreIPCClientRunLoop.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CoreIPCClientRunLoop.h; sourceTree = "<group>"; };
+		93C01DAB139AC91700ED51D7 /* CoreIPCClientRunLoop.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = CoreIPCClientRunLoop.mm; sourceTree = "<group>"; };
 		93FC679D12D3CC7400A60610 /* DecoderAdapter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DecoderAdapter.cpp; sourceTree = "<group>"; };
 		93FC679E12D3CC7400A60610 /* DecoderAdapter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DecoderAdapter.h; sourceTree = "<group>"; };
 		93FC679F12D3CC7400A60610 /* EncoderAdapter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = EncoderAdapter.cpp; sourceTree = "<group>"; };
@@ -2028,6 +2032,8 @@
 		1A6FA01C11E1526300DB1371 /* mac */ = {
 			isa = PBXGroup;
 			children = (
+				93C01DAA139AC91700ED51D7 /* CoreIPCClientRunLoop.h */,
+				93C01DAB139AC91700ED51D7 /* CoreIPCClientRunLoop.mm */,
 				E1BB1688132018BA00F49431 /* FullKeyboardAccessWatcher.h */,
 				E1BB1689132018BA00F49431 /* FullKeyboardAccessWatcher.mm */,
 				512DF6D6138C181A00A22FC6 /* KeychainItemShimMethods.h */,
@@ -3818,6 +3824,7 @@
 				512DF6FF138C254600A22FC6 /* SecKeychainItemRequestData.h in Headers */,
 				512DF701138C254600A22FC6 /* SecKeychainItemResponseData.h in Headers */,
 				512DF70B138C26C700A22FC6 /* KeychainAttribute.h in Headers */,
+				93C01DAC139AC91700ED51D7 /* CoreIPCClientRunLoop.h in Headers */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
@@ -4485,6 +4492,7 @@
 				512DF6FE138C254600A22FC6 /* SecKeychainItemRequestData.cpp in Sources */,
 				512DF700138C254600A22FC6 /* SecKeychainItemResponseData.cpp in Sources */,
 				512DF70A138C26C700A22FC6 /* KeychainAttribute.cpp in Sources */,
+				93C01DAD139AC91700ED51D7 /* CoreIPCClientRunLoop.mm in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};

Added: trunk/Source/WebKit2/WebProcess/mac/CoreIPCClientRunLoop.h (0 => 88123)


--- trunk/Source/WebKit2/WebProcess/mac/CoreIPCClientRunLoop.h	                        (rev 0)
+++ trunk/Source/WebKit2/WebProcess/mac/CoreIPCClientRunLoop.h	2011-06-04 21:03:29 UTC (rev 88123)
@@ -0,0 +1,34 @@
+/*
+ * 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.
+ */
+
+namespace WebKit {
+
+typedef void (*FunctionWithContext)(void* context);
+
+// Call the function on a thread where it's safe to send a synchronous CoreIPC message.
+// We can't use WTF's callOnMainThreadAndWait because it doesn't support enough run loop modes.
+void callOnCoreIPCClientRunLoopAndWait(FunctionWithContext, void* context);
+
+}
Property changes on: trunk/Source/WebKit2/WebProcess/mac/CoreIPCClientRunLoop.h
___________________________________________________________________

Added: svn:eol-style

Added: trunk/Source/WebKit2/WebProcess/mac/CoreIPCClientRunLoop.mm (0 => 88123)


--- trunk/Source/WebKit2/WebProcess/mac/CoreIPCClientRunLoop.mm	                        (rev 0)
+++ trunk/Source/WebKit2/WebProcess/mac/CoreIPCClientRunLoop.mm	2011-06-04 21:03:29 UTC (rev 88123)
@@ -0,0 +1,80 @@
+/*
+ * 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.
+ */
+
+#import "config.h"
+#import "CoreIPCClientRunLoop.h"
+
+#import <WebCore/ResourceHandle.h>
+#import <wtf/RetainPtr.h>
+
+using namespace WebCore;
+
+@interface WKFunctionAdapter : NSObject
+{
+@public
+    WebKit::FunctionWithContext function;
+    void* context;
+}
+- (void)perform;
+@end
+
+@implementation WKFunctionAdapter
+
+- (void)perform
+{
+    function(context);
+}
+
+@end
+
+namespace WebKit {
+
+static CFArrayRef createCoreIPCRunLoopModesArray()
+{
+    // Ideally we'd like to list all modes here that might be used for run loops while we are handling networking.
+    // We have to explicitly include the run loop mode used for synchronous loads in WebCore so we don't get deadlock
+    // when those loads call security functions that are shimmed.
+    const void* values[2] = { kCFRunLoopCommonModes, ResourceHandle::synchronousLoadRunLoopMode() };
+    return CFArrayCreate(0, values, 2, &kCFTypeArrayCallBacks);
+}
+
+static NSArray *coreIPCRunLoopModesArray()
+{
+    static CFArrayRef modes = createCoreIPCRunLoopModesArray();
+    return (NSArray *)modes;
+}
+
+void callOnCoreIPCClientRunLoopAndWait(FunctionWithContext function, void* context)
+{
+    // FIXME: It would fit better with WebKit2 coding style to use a WorkItem here.
+    // To do that we'd need to make scheduleWork have an overload that takes an array of run loop modes or find some
+    // other way to specify that we want to include the synchronous load run loop mode.
+    RetainPtr<WKFunctionAdapter> adapter(AdoptNS, [[WKFunctionAdapter alloc] init]);
+    adapter->function = function;
+    adapter->context = context;
+    [adapter.get() performSelectorOnMainThread:@selector(perform) withObject:nil waitUntilDone:YES modes:coreIPCRunLoopModesArray()];
+}
+
+}
Property changes on: trunk/Source/WebKit2/WebProcess/mac/CoreIPCClientRunLoop.mm
___________________________________________________________________

Added: svn:eol-style

Modified: trunk/Source/WebKit2/WebProcess/mac/KeychainItemShimMethods.mm (88122 => 88123)


--- trunk/Source/WebKit2/WebProcess/mac/KeychainItemShimMethods.mm	2011-06-04 19:34:29 UTC (rev 88122)
+++ trunk/Source/WebKit2/WebProcess/mac/KeychainItemShimMethods.mm	2011-06-04 21:03:29 UTC (rev 88123)
@@ -22,18 +22,19 @@
  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
+
 #import "config.h"
 #import "KeychainItemShimMethods.h"
 
 #if defined(BUILDING_ON_SNOW_LEOPARD)
 
+#import "CoreIPCClientRunLoop.h"
 #import "SecKeychainItemRequestData.h"
 #import "SecKeychainItemResponseData.h"
 #import "WebProcess.h"
 #import "WebProcessProxyMessages.h"
 #import "WebProcessShim.h"
 #import <dlfcn.h>
-#import <wtf/Threading.h>
 
 namespace WebKit {
 
@@ -137,7 +138,7 @@
     FreeAttributeListContext context;
     context.attrList = attrList;
     
-    callOnMainThreadAndWait(webFreeAttributeListContentOnMainThread, &context);
+    callOnCoreIPCClientRunLoopAndWait(webFreeAttributeListContentOnMainThread, &context);
 
     return context.freed;
 }
@@ -166,7 +167,7 @@
     FreeKeychainItemDataContext context;
     context.data = ""
     
-    callOnMainThreadAndWait(webFreeKeychainItemContentOnMainThread, &context);
+    callOnCoreIPCClientRunLoopAndWait(webFreeKeychainItemContentOnMainThread, &context);
 
     return context.freed;
 }
@@ -215,7 +216,7 @@
     context.resultLength = length;
     context.resultData = outData;
 
-    callOnMainThreadAndWait(webSecKeychainItemCopyContentOnMainThread, &context);
+    callOnCoreIPCClientRunLoopAndWait(webSecKeychainItemCopyContentOnMainThread, &context);
 
     // FIXME: should return context.resultCode. Returning noErr is a workaround for <rdar://problem/9520886>;
     // the authentication should fail anyway, since on error no data will be returned.
@@ -248,7 +249,7 @@
     context.length = length;
     context.data = ""
     
-    callOnMainThreadAndWait(webSecKeychainItemCreateFromContentOnMainThread, &context);
+    callOnCoreIPCClientRunLoopAndWait(webSecKeychainItemCreateFromContentOnMainThread, &context);
     
     if (item)
         *item = context.item;
@@ -281,7 +282,7 @@
     context.length = length;
     context.data = ""
     
-    callOnMainThreadAndWait(webSecKeychainItemModifyContentOnMainThread, &context);
+    callOnCoreIPCClientRunLoopAndWait(webSecKeychainItemModifyContentOnMainThread, &context);
     
     return context.resultCode;
 }
Property changes on: trunk/Source/WebKit2/WebProcess/mac/KeychainItemShimMethods.mm
___________________________________________________________________

Added: svn:eol-style

Modified: trunk/Source/WebKit2/WebProcess/mac/SecItemShimMethods.mm (88122 => 88123)


--- trunk/Source/WebKit2/WebProcess/mac/SecItemShimMethods.mm	2011-06-04 19:34:29 UTC (rev 88122)
+++ trunk/Source/WebKit2/WebProcess/mac/SecItemShimMethods.mm	2011-06-04 21:03:29 UTC (rev 88123)
@@ -22,11 +22,13 @@
  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
+
 #import "config.h"
 #import "SecItemShimMethods.h"
 
 #if !defined(BUILDING_ON_SNOW_LEOPARD)
 
+#import "CoreIPCClientRunLoop.h"
 #import "SecItemRequestData.h"
 #import "SecItemResponseData.h"
 #import "WebProcess.h"
@@ -34,7 +36,6 @@
 #import "WebProcessShim.h"
 #import <Security/SecItem.h>
 #import <dlfcn.h>
-#import <wtf/Threading.h>
 
 namespace WebKit {
 
@@ -70,7 +71,7 @@
     SecItemAPIContext context;
     context.query = query;
     
-    callOnMainThreadAndWait(webSecItemCopyMatchingMainThread, &context);
+    callOnCoreIPCClientRunLoopAndWait(webSecItemCopyMatchingMainThread, &context);
     
     if (result)
         *result = context.resultObject;
@@ -98,7 +99,7 @@
     SecItemAPIContext context;
     context.query = query;
     
-    callOnMainThreadAndWait(webSecItemAddOnMainThread, &context);
+    callOnCoreIPCClientRunLoopAndWait(webSecItemAddOnMainThread, &context);
     
     if (result)
         *result = context.resultObject;
@@ -126,7 +127,7 @@
     context.query = query;
     context.attributesToUpdate = attributesToUpdate;
     
-    callOnMainThreadAndWait(webSecItemUpdateOnMainThread, &context);
+    callOnCoreIPCClientRunLoopAndWait(webSecItemUpdateOnMainThread, &context);
     
     return context.resultCode;
 }
@@ -151,7 +152,7 @@
     SecItemAPIContext context;
     context.query = query;
     
-    callOnMainThreadAndWait(webSecItemDeleteOnMainThread, &context);
+    callOnCoreIPCClientRunLoopAndWait(webSecItemDeleteOnMainThread, &context);
 
     return context.resultCode;
 }
Property changes on: trunk/Source/WebKit2/WebProcess/mac/SecItemShimMethods.mm
___________________________________________________________________

Added: svn:eol-style

_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to