Title: [169854] trunk/Source/WebKit2
Revision
169854
Author
[email protected]
Date
2014-06-11 16:06:43 -0700 (Wed, 11 Jun 2014)

Log Message

[Cocoa] Move CompletionHandlerCallChecker into a separate file
https://bugs.webkit.org/show_bug.cgi?id=133774

Reviewed by Anders Carlsson.

* Shared/Cocoa/CompletionHandlerCallChecker.h: Added.
* Shared/Cocoa/CompletionHandlerCallChecker.mm: Added.
(WebKit::CompletionHandlerCallChecker::create):
(WebKit::CompletionHandlerCallChecker::CompletionHandlerCallChecker):
(WebKit::CompletionHandlerCallChecker::~CompletionHandlerCallChecker):
(WebKit::CompletionHandlerCallChecker::didCallCompletionHandler):
(WebKit::CompletionHandlerCallChecker::classImplementingDelegateMethod):

* UIProcess/Cocoa/UIDelegate.mm:
(WebKit::CompletionHandlerCallChecker::create): Deleted.
(WebKit::CompletionHandlerCallChecker::~CompletionHandlerCallChecker): Deleted.
(WebKit::CompletionHandlerCallChecker::didCallCompletionHandler): Deleted.
(WebKit::CompletionHandlerCallChecker::CompletionHandlerCallChecker): Deleted.
(WebKit::CompletionHandlerCallChecker::classImplementingDelegateMethod): Deleted.
* WebKit2.xcodeproj/project.pbxproj:

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (169853 => 169854)


--- trunk/Source/WebKit2/ChangeLog	2014-06-11 22:55:34 UTC (rev 169853)
+++ trunk/Source/WebKit2/ChangeLog	2014-06-11 23:06:43 UTC (rev 169854)
@@ -1,3 +1,26 @@
+2014-06-11  Dan Bernstein  <[email protected]>
+
+        [Cocoa] Move CompletionHandlerCallChecker into a separate file
+        https://bugs.webkit.org/show_bug.cgi?id=133774
+
+        Reviewed by Anders Carlsson.
+
+        * Shared/Cocoa/CompletionHandlerCallChecker.h: Added.
+        * Shared/Cocoa/CompletionHandlerCallChecker.mm: Added.
+        (WebKit::CompletionHandlerCallChecker::create):
+        (WebKit::CompletionHandlerCallChecker::CompletionHandlerCallChecker):
+        (WebKit::CompletionHandlerCallChecker::~CompletionHandlerCallChecker):
+        (WebKit::CompletionHandlerCallChecker::didCallCompletionHandler):
+        (WebKit::CompletionHandlerCallChecker::classImplementingDelegateMethod):
+
+        * UIProcess/Cocoa/UIDelegate.mm:
+        (WebKit::CompletionHandlerCallChecker::create): Deleted.
+        (WebKit::CompletionHandlerCallChecker::~CompletionHandlerCallChecker): Deleted.
+        (WebKit::CompletionHandlerCallChecker::didCallCompletionHandler): Deleted.
+        (WebKit::CompletionHandlerCallChecker::CompletionHandlerCallChecker): Deleted.
+        (WebKit::CompletionHandlerCallChecker::classImplementingDelegateMethod): Deleted.
+        * WebKit2.xcodeproj/project.pbxproj:
+
 2014-06-11  Martin Hock  <[email protected]>
 
         [iOS] Clear UIProcess visual state after WebProcess crash

Added: trunk/Source/WebKit2/Shared/Cocoa/CompletionHandlerCallChecker.h (0 => 169854)


--- trunk/Source/WebKit2/Shared/Cocoa/CompletionHandlerCallChecker.h	                        (rev 0)
+++ trunk/Source/WebKit2/Shared/Cocoa/CompletionHandlerCallChecker.h	2014-06-11 23:06:43 UTC (rev 169854)
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2014 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 "WKFoundation.h"
+
+#if WK_API_ENABLED
+
+#import <wtf/Forward.h>
+#import <wtf/ThreadSafeRefCounted.h>
+
+namespace WebKit {
+
+class CompletionHandlerCallChecker : public WTF::ThreadSafeRefCounted<CompletionHandlerCallChecker> {
+public:
+    static PassRefPtr<CompletionHandlerCallChecker> create(id delegate, SEL delegateMethodSelector);
+
+    ~CompletionHandlerCallChecker();
+
+    void didCallCompletionHandler();
+
+private:
+    CompletionHandlerCallChecker(Class delegateClass, SEL delegateMethodSelector);
+
+    Class classImplementingDelegateMethod() const;
+
+    Class m_delegateClass;
+    SEL m_delegateMethodSelector;
+    bool m_didCallCompletionHandler;
+};
+
+} // namespace WebKit
+
+#endif // WK_API_ENABLED

Added: trunk/Source/WebKit2/Shared/Cocoa/CompletionHandlerCallChecker.mm (0 => 169854)


--- trunk/Source/WebKit2/Shared/Cocoa/CompletionHandlerCallChecker.mm	                        (rev 0)
+++ trunk/Source/WebKit2/Shared/Cocoa/CompletionHandlerCallChecker.mm	2014-06-11 23:06:43 UTC (rev 169854)
@@ -0,0 +1,80 @@
+/*
+ * Copyright (C) 2014 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 "CompletionHandlerCallChecker.h"
+
+#if WK_API_ENABLED
+
+#import <wtf/PassRefPtr.h>
+#import <objc/runtime.h>
+
+namespace WebKit {
+
+PassRefPtr<CompletionHandlerCallChecker> CompletionHandlerCallChecker::create(id delegate, SEL delegateMethodSelector)
+{
+    return adoptRef(new CompletionHandlerCallChecker(object_getClass(delegate), delegateMethodSelector));
+}
+
+CompletionHandlerCallChecker::CompletionHandlerCallChecker(Class delegateClass, SEL delegateMethodSelector)
+    : m_delegateClass(delegateClass)
+    , m_delegateMethodSelector(delegateMethodSelector)
+    , m_didCallCompletionHandler(false)
+{
+}
+
+CompletionHandlerCallChecker::~CompletionHandlerCallChecker()
+{
+    if (m_didCallCompletionHandler)
+        return;
+
+    Class delegateClass = classImplementingDelegateMethod();
+    [NSException raise:NSInternalInconsistencyException format:@"Completion handler passed to %c[%@ %@] was not called", class_isMetaClass(delegateClass) ? '+' : '-', NSStringFromClass(delegateClass), NSStringFromSelector(m_delegateMethodSelector)];
+}
+
+void CompletionHandlerCallChecker::didCallCompletionHandler()
+{
+    ASSERT(!m_didCallCompletionHandler);
+    m_didCallCompletionHandler = true;
+}
+
+Class CompletionHandlerCallChecker::classImplementingDelegateMethod() const
+{
+    Class delegateClass = m_delegateClass;
+    Method delegateMethod = class_getInstanceMethod(delegateClass, m_delegateMethodSelector);
+
+    for (Class superclass = class_getSuperclass(delegateClass); superclass; superclass = class_getSuperclass(superclass)) {
+        if (class_getInstanceMethod(superclass, m_delegateMethodSelector) != delegateMethod)
+            break;
+
+        delegateClass = superclass;
+    }
+
+    return delegateClass;
+}
+
+} // namespace WebKit
+
+#endif // WK_API_ENABLED

Modified: trunk/Source/WebKit2/UIProcess/Cocoa/UIDelegate.mm (169853 => 169854)


--- trunk/Source/WebKit2/UIProcess/Cocoa/UIDelegate.mm	2014-06-11 22:55:34 UTC (rev 169853)
+++ trunk/Source/WebKit2/UIProcess/Cocoa/UIDelegate.mm	2014-06-11 23:06:43 UTC (rev 169854)
@@ -28,7 +28,7 @@
 
 #if WK_API_ENABLED
 
-#import "_WKFrameHandleInternal.h"
+#import "CompletionHandlerCallChecker.h"
 #import "NavigationActionData.h"
 #import "WKFrameInfoInternal.h"
 #import "WKNavigationActionInternal.h"
@@ -36,60 +36,10 @@
 #import "WKWebViewInternal.h"
 #import "WKWindowFeaturesInternal.h"
 #import "WKUIDelegatePrivate.h"
+#import "_WKFrameHandleInternal.h"
 
 namespace WebKit {
 
-class CompletionHandlerCallChecker : public WTF::ThreadSafeRefCounted<CompletionHandlerCallChecker> {
-public:
-    static PassRefPtr<CompletionHandlerCallChecker> create(id delegate, SEL delegateMethodSelector)
-    {
-        return adoptRef(new CompletionHandlerCallChecker(object_getClass(delegate), delegateMethodSelector));
-    }
-
-    ~CompletionHandlerCallChecker()
-    {
-        if (m_didCallCompletionHandler)
-            return;
-
-        Class delegateClass = classImplementingDelegateMethod();
-        [NSException raise:NSInternalInconsistencyException format:@"Completion handler passed to %c[%@ %@] was not called", class_isMetaClass(delegateClass) ? '+' : '-', NSStringFromClass(delegateClass), NSStringFromSelector(m_delegateMethodSelector)];
-    }
-
-    void didCallCompletionHandler()
-    {
-        ASSERT(!m_didCallCompletionHandler);
-        m_didCallCompletionHandler = true;
-    }
-
-private:
-    CompletionHandlerCallChecker(Class delegateClass, SEL delegateMethodSelector)
-        : m_delegateClass(delegateClass)
-        , m_delegateMethodSelector(delegateMethodSelector)
-        , m_didCallCompletionHandler(false)
-    {
-    }
-
-    Class classImplementingDelegateMethod() const
-    {
-        Class delegateClass = m_delegateClass;
-        Method delegateMethod = class_getInstanceMethod(delegateClass, m_delegateMethodSelector);
-
-        for (Class superclass = class_getSuperclass(delegateClass); superclass; superclass = class_getSuperclass(superclass)) {
-            if (class_getInstanceMethod(superclass, m_delegateMethodSelector) != delegateMethod)
-                break;
-
-            delegateClass = superclass;
-        }
-
-        return delegateClass;
-    }
-
-    Class m_delegateClass;
-    SEL m_delegateMethodSelector;
-    bool m_didCallCompletionHandler;
-};
-
-
 UIDelegate::UIDelegate(WKWebView *webView)
     : m_webView(webView)
 {

Modified: trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj (169853 => 169854)


--- trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj	2014-06-11 22:55:34 UTC (rev 169853)
+++ trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj	2014-06-11 23:06:43 UTC (rev 169854)
@@ -725,6 +725,8 @@
 		37A5E01418BBF93F000A081E /* _WKActivatedElementInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = 37A5E01218BBF937000A081E /* _WKActivatedElementInfo.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		37A64E5518F38E3C00EB30F1 /* _WKFormDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = 37A64E5418F38E3C00EB30F1 /* _WKFormDelegate.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		37A64E5718F38F4600EB30F1 /* _WKFormInputSession.h in Headers */ = {isa = PBXBuildFile; fileRef = 37A64E5618F38F4600EB30F1 /* _WKFormInputSession.h */; settings = {ATTRIBUTES = (Private, ); }; };
+		37BEC4E019491486008B4286 /* CompletionHandlerCallChecker.mm in Sources */ = {isa = PBXBuildFile; fileRef = 37BEC4DE19491486008B4286 /* CompletionHandlerCallChecker.mm */; };
+		37BEC4E119491486008B4286 /* CompletionHandlerCallChecker.h in Headers */ = {isa = PBXBuildFile; fileRef = 37BEC4DF19491486008B4286 /* CompletionHandlerCallChecker.h */; };
 		37BEC4DD1948FC6A008B4286 /* WebCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1AA1C79A100E7FC50078DEBC /* WebCore.framework */; };
 		37BF2F061947DEB400723C48 /* WKNSURLRequest.h in Headers */ = {isa = PBXBuildFile; fileRef = 37BF2F041947DEB400723C48 /* WKNSURLRequest.h */; };
 		37BF2F071947DEB400723C48 /* WKNSURLRequest.mm in Sources */ = {isa = PBXBuildFile; fileRef = 37BF2F051947DEB400723C48 /* WKNSURLRequest.mm */; };
@@ -2708,6 +2710,8 @@
 		37A5E01218BBF937000A081E /* _WKActivatedElementInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = _WKActivatedElementInfo.h; sourceTree = "<group>"; };
 		37A64E5418F38E3C00EB30F1 /* _WKFormDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = _WKFormDelegate.h; sourceTree = "<group>"; };
 		37A64E5618F38F4600EB30F1 /* _WKFormInputSession.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = _WKFormInputSession.h; sourceTree = "<group>"; };
+		37BEC4DE19491486008B4286 /* CompletionHandlerCallChecker.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = CompletionHandlerCallChecker.mm; sourceTree = "<group>"; };
+		37BEC4DF19491486008B4286 /* CompletionHandlerCallChecker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CompletionHandlerCallChecker.h; sourceTree = "<group>"; };
 		37BF2F041947DEB400723C48 /* WKNSURLRequest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKNSURLRequest.h; sourceTree = "<group>"; };
 		37BF2F051947DEB400723C48 /* WKNSURLRequest.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKNSURLRequest.mm; sourceTree = "<group>"; };
 		37C4C08418149C5B003688B9 /* WKBackForwardListItem.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKBackForwardListItem.mm; sourceTree = "<group>"; };
@@ -5024,6 +5028,8 @@
 			isa = PBXGroup;
 			children = (
 				378E1A3B181ED6FF0031007A /* APIObject.mm */,
+				37BEC4DF19491486008B4286 /* CompletionHandlerCallChecker.h */,
+				37BEC4DE19491486008B4286 /* CompletionHandlerCallChecker.mm */,
 				37C4C0921814B3AF003688B9 /* WKNSArray.h */,
 				37C4C0911814B3AF003688B9 /* WKNSArray.mm */,
 				373CEAD4185417AE008C363D /* WKNSData.h */,
@@ -6985,6 +6991,7 @@
 				BC032DA610F437D10058C15A /* ArgumentDecoder.h in Headers */,
 				BC032DA810F437D10058C15A /* ArgumentEncoder.h in Headers */,
 				BC032DA910F437D10058C15A /* Arguments.h in Headers */,
+				37BEC4E119491486008B4286 /* CompletionHandlerCallChecker.h in Headers */,
 				BCEE966D112FAF57006BCC24 /* Attachment.h in Headers */,
 				1A5B1C5518987EDF004FCF9B /* WebDocumentLoader.h in Headers */,
 				E1A31732134CEA6C007C9A4F /* AttributedString.h in Headers */,
@@ -9052,6 +9059,7 @@
 				BCE469531214E6CB000B98EB /* WebFormClient.cpp in Sources */,
 				BCE469551214E6CB000B98EB /* WebFormSubmissionListenerProxy.cpp in Sources */,
 				BC111ADD112F5B9300337BAB /* WebFrame.cpp in Sources */,
+				37BEC4E019491486008B4286 /* CompletionHandlerCallChecker.mm in Sources */,
 				2DA944AE1884E9BA00ED86DB /* WebInspectorProxyIOS.mm in Sources */,
 				BCE469791214F2B4000B98EB /* WebFrameListenerProxy.cpp in Sources */,
 				BC111A5F112F4FBB00337BAB /* WebFrameLoaderClient.cpp in Sources */,
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to