Title: [89534] trunk/Source/WebCore
Revision
89534
Author
psola...@apple.com
Date
2011-06-22 23:00:22 -0700 (Wed, 22 Jun 2011)

Log Message

2011-06-22  Pratik Solanki  <psola...@apple.com>

        Reviewed by Darin Adler.

        Add NSError wrapper functions in ResourceError when USE(CFNETWORK) is enabled
        https://bugs.webkit.org/show_bug.cgi?id=63155

        Add wrapper functions to ResourceError when building with USE(CFNETWORK). We need to create
        a new NSError in ResourceError::nsError() since Safari has category methods on NSError and
        passing a CFErrorRef back does not work even though CFErrorRef/NSErrror are toll-free
        bridged.

        No tests because no change in functionality.

        * WebCore.exp.in:
        * platform/network/cf/ResourceError.h:
        * platform/network/mac/ResourceErrorMac.mm:
        (WebCore::ResourceError::ResourceError):
        (WebCore::ResourceError::nsError):
        (WebCore::ResourceError::operator NSError *):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (89533 => 89534)


--- trunk/Source/WebCore/ChangeLog	2011-06-23 05:59:29 UTC (rev 89533)
+++ trunk/Source/WebCore/ChangeLog	2011-06-23 06:00:22 UTC (rev 89534)
@@ -1,3 +1,24 @@
+2011-06-22  Pratik Solanki  <psola...@apple.com>
+
+        Reviewed by Darin Adler.
+
+        Add NSError wrapper functions in ResourceError when USE(CFNETWORK) is enabled
+        https://bugs.webkit.org/show_bug.cgi?id=63155
+
+        Add wrapper functions to ResourceError when building with USE(CFNETWORK). We need to create
+        a new NSError in ResourceError::nsError() since Safari has category methods on NSError and
+        passing a CFErrorRef back does not work even though CFErrorRef/NSErrror are toll-free
+        bridged.
+
+        No tests because no change in functionality.
+
+        * WebCore.exp.in:
+        * platform/network/cf/ResourceError.h:
+        * platform/network/mac/ResourceErrorMac.mm:
+        (WebCore::ResourceError::ResourceError):
+        (WebCore::ResourceError::nsError):
+        (WebCore::ResourceError::operator NSError *):
+
 2011-06-22  Dominic Cooney  <domin...@chromium.org>
 
         Reviewed by Mark Rowe.

Modified: trunk/Source/WebCore/WebCore.exp.in (89533 => 89534)


--- trunk/Source/WebCore/WebCore.exp.in	2011-06-23 05:59:29 UTC (rev 89533)
+++ trunk/Source/WebCore/WebCore.exp.in	2011-06-23 06:00:22 UTC (rev 89534)
@@ -1896,7 +1896,9 @@
 #endif
 
 #if USE(CFNETWORK)
+__ZNK7WebCore13ResourceErrorcvP9__CFErrorEv
 __ZN7WebCore12SchedulePairC1EP11__CFRunLoopPK10__CFString
 #else
+__ZNK7WebCore13ResourceErrorcvP7NSErrorEv
 __ZN7WebCore12SchedulePairC1EP9NSRunLoopPK10__CFString
 #endif

Modified: trunk/Source/WebCore/platform/network/cf/ResourceError.h (89533 => 89534)


--- trunk/Source/WebCore/platform/network/cf/ResourceError.h	2011-06-23 05:59:29 UTC (rev 89533)
+++ trunk/Source/WebCore/platform/network/cf/ResourceError.h	2011-06-23 06:00:22 UTC (rev 89534)
@@ -31,14 +31,13 @@
 #include <wtf/RetainPtr.h>
 #if USE(CFNETWORK)
 #include <CoreFoundation/CFStream.h>
-#else
+#endif
 
 #ifdef __OBJC__
 @class NSError;
 #else
 class NSError;
 #endif
-#endif
 
 namespace WebCore {
 
@@ -68,7 +67,9 @@
     ResourceError(CFStreamError error);
     CFStreamError cfStreamError() const;
     operator CFStreamError() const;
-#else
+#endif
+
+#if PLATFORM(MAC)
     ResourceError(NSError *);
     NSError *nsError() const;
     operator NSError *() const;
@@ -84,6 +85,9 @@
     bool m_dataIsUpToDate;
 #if USE(CFNETWORK)
     mutable RetainPtr<CFErrorRef> m_platformError;
+#if PLATFORM(MAC)
+    mutable RetainPtr<NSError> m_platformNSError;
+#endif
 #if PLATFORM(WIN)
     RetainPtr<CFDataRef> m_certificate;
 #endif

Modified: trunk/Source/WebCore/platform/network/mac/ResourceErrorMac.mm (89533 => 89534)


--- trunk/Source/WebCore/platform/network/mac/ResourceErrorMac.mm	2011-06-23 05:59:29 UTC (rev 89533)
+++ trunk/Source/WebCore/platform/network/mac/ResourceErrorMac.mm	2011-06-23 06:00:22 UTC (rev 89534)
@@ -37,6 +37,36 @@
 
 namespace WebCore {
 
+#if USE(CFNETWORK)
+
+ResourceError::ResourceError(NSError *error)
+    : m_dataIsUpToDate(false)
+    , m_platformError(reinterpret_cast<CFErrorRef>(error))
+{
+    m_isNull = !error;
+}
+
+NSError *ResourceError::nsError() const
+{
+    if (m_isNull) {
+        ASSERT(!m_platformError);
+        return nil;
+    }
+    if (!m_platformNSError) {
+        CFErrorRef error = m_platformError.get();
+        RetainPtr<NSDictionary> userInfo(AdoptCF, (NSDictionary *) CFErrorCopyUserInfo(error));
+        m_platformNSError.adoptNS([[NSError alloc] initWithDomain:(NSString *)CFErrorGetDomain(error) code:CFErrorGetCode(error) userInfo:userInfo.get()]);
+    }
+    return m_platformNSError.get();
+}
+
+ResourceError::operator NSError *() const
+{
+    return nsError();
+}
+
+#else
+
 ResourceError::ResourceError(NSError *nsError)
     : m_dataIsUpToDate(false)
     , m_platformError(nsError)
@@ -117,4 +147,6 @@
     return cfError();
 }
 
+#endif // USE(CFNETWORK)
+
 } // namespace WebCore
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to