Reviewed by Darin.
authorandersca <andersca@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 29 Nov 2006 18:29:08 +0000 (18:29 +0000)
committerandersca <andersca@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 29 Nov 2006 18:29:08 +0000 (18:29 +0000)
        Have ResourceResponse hold on to the platform object and do lazy
        initialization of the data members.

        * WebCore.xcodeproj/project.pbxproj:
        * loader/mac/FrameLoaderMac.mm:
        (WebCore::FrameLoader::loadResourceSynchronously):
        * platform/network/ResourceRequest.cpp:
        (WebCore::ResourceRequest::updatePlatformRequest):
        (WebCore::ResourceRequest::updateResourceRequest):
        * platform/network/ResourceResponse.cpp: Added.
        (WebCore::ResourceResponse::url):
        (WebCore::ResourceResponse::mimeType):
        (WebCore::ResourceResponse::expectedContentLength):
        (WebCore::ResourceResponse::textEncodingName):
        (WebCore::ResourceResponse::suggestedFilename):
        (WebCore::ResourceResponse::httpStatusCode):
        (WebCore::ResourceResponse::setHTTPStatusCode):
        (WebCore::ResourceResponse::httpStatusText):
        (WebCore::ResourceResponse::setHTTPStatusText):
        (WebCore::ResourceResponse::httpHeaderField):
        (WebCore::ResourceResponse::httpHeaderFields):
        (WebCore::ResourceResponse::setExpirationDate):
        (WebCore::ResourceResponse::expirationDate):
        (WebCore::ResourceResponse::setLastModifiedDate):
        (WebCore::ResourceResponse::lastModifiedDate):
        (WebCore::ResourceResponse::updateResourceResponse):
        * platform/network/ResourceResponse.h:
        (WebCore::ResourceResponse::ResourceResponse):
        (WebCore::ResourceResponse::isMultipart):
        * platform/network/mac/ResourceHandleMac.mm:
        (WebCore::ResourceHandle::receivedResponse):
        (WebCore::ResourceHandle::willSendRequest):
        * platform/network/mac/ResourceResponseMac.h: Removed.
        * platform/network/mac/ResourceResponseMac.mm:
        (-[NSURLResponse WebCore]):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@17921 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebCore/ChangeLog
WebCore/WebCore.xcodeproj/project.pbxproj
WebCore/loader/mac/FrameLoaderMac.mm
WebCore/platform/network/ResourceRequest.cpp
WebCore/platform/network/ResourceRequest.h
WebCore/platform/network/ResourceResponse.cpp [new file with mode: 0644]
WebCore/platform/network/ResourceResponse.h
WebCore/platform/network/mac/ResourceHandleMac.mm
WebCore/platform/network/mac/ResourceResponseMac.h [deleted file]
WebCore/platform/network/mac/ResourceResponseMac.mm

index fa88cc85f0fb397ec78a23ec210f637e78852836..c0d43721ac21d89b8fad4836a54070a24ae17f7c 100644 (file)
@@ -1,3 +1,43 @@
+2006-11-29  Anders Carlsson  <acarlsson@apple.com>
+
+        Reviewed by Darin.
+
+        Have ResourceResponse hold on to the platform object and do lazy
+        initialization of the data members.
+        
+        * WebCore.xcodeproj/project.pbxproj:
+        * loader/mac/FrameLoaderMac.mm:
+        (WebCore::FrameLoader::loadResourceSynchronously):
+        * platform/network/ResourceRequest.cpp:
+        (WebCore::ResourceRequest::updatePlatformRequest):
+        (WebCore::ResourceRequest::updateResourceRequest):
+        * platform/network/ResourceResponse.cpp: Added.
+        (WebCore::ResourceResponse::url):
+        (WebCore::ResourceResponse::mimeType):
+        (WebCore::ResourceResponse::expectedContentLength):
+        (WebCore::ResourceResponse::textEncodingName):
+        (WebCore::ResourceResponse::suggestedFilename):
+        (WebCore::ResourceResponse::httpStatusCode):
+        (WebCore::ResourceResponse::setHTTPStatusCode):
+        (WebCore::ResourceResponse::httpStatusText):
+        (WebCore::ResourceResponse::setHTTPStatusText):
+        (WebCore::ResourceResponse::httpHeaderField):
+        (WebCore::ResourceResponse::httpHeaderFields):
+        (WebCore::ResourceResponse::setExpirationDate):
+        (WebCore::ResourceResponse::expirationDate):
+        (WebCore::ResourceResponse::setLastModifiedDate):
+        (WebCore::ResourceResponse::lastModifiedDate):
+        (WebCore::ResourceResponse::updateResourceResponse):
+        * platform/network/ResourceResponse.h:
+        (WebCore::ResourceResponse::ResourceResponse):
+        (WebCore::ResourceResponse::isMultipart):
+        * platform/network/mac/ResourceHandleMac.mm:
+        (WebCore::ResourceHandle::receivedResponse):
+        (WebCore::ResourceHandle::willSendRequest):
+        * platform/network/mac/ResourceResponseMac.h: Removed.
+        * platform/network/mac/ResourceResponseMac.mm:
+        (-[NSURLResponse WebCore]):
+
 2006-11-28  Alice Liu  <alice.liu@apple.com>
 
         Reviewed by Maciej.
index 4721787fd9de6486ec325e31cc68217f3567b95e..f39b6fcc2c234ab2db1ba21aba0ac00664c20962 100644 (file)
                1A762C780A074F2600989F5B /* JSXPathNSResolver.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A762C700A074F2600989F5B /* JSXPathNSResolver.h */; };
                1A762C790A074F2600989F5B /* JSXPathResult.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A762C710A074F2600989F5B /* JSXPathResult.cpp */; };
                1A762C7A0A074F2600989F5B /* JSXPathResult.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A762C720A074F2600989F5B /* JSXPathResult.h */; };
+               1A8180A50B1D4E4300CE46C4 /* ResourceResponse.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A8180A40B1D4E4300CE46C4 /* ResourceResponse.cpp */; };
                1A820D910A13EBA600AF843C /* ImageDocument.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A820D8F0A13EBA600AF843C /* ImageDocument.cpp */; };
                1A820D920A13EBA600AF843C /* ImageDocument.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A820D900A13EBA600AF843C /* ImageDocument.h */; };
                1A85B18F0A1B18A200D8C87C /* JSHTMLHtmlElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A85B18D0A1B18A200D8C87C /* JSHTMLHtmlElement.cpp */; };
                6582A17809999EA000BEEB6D /* DeprecatedStringMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 6582A17709999EA000BEEB6D /* DeprecatedStringMac.mm */; };
                658436860AE01B7400E53753 /* FrameLoadRequest.h in Headers */ = {isa = PBXBuildFile; fileRef = 658436850AE01B7400E53753 /* FrameLoadRequest.h */; settings = {ATTRIBUTES = (Private, ); }; };
                658821660AF4CDF700F01D1F /* ResourceResponse.h in Headers */ = {isa = PBXBuildFile; fileRef = 658821650AF4CDF700F01D1F /* ResourceResponse.h */; settings = {ATTRIBUTES = (Private, ); }; };
-               6588216B0AF4CE1200F01D1F /* ResourceResponseMac.h in Headers */ = {isa = PBXBuildFile; fileRef = 658821680AF4CE1200F01D1F /* ResourceResponseMac.h */; };
                6588216C0AF4CE1200F01D1F /* ResourceResponseMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 658821690AF4CE1200F01D1F /* ResourceResponseMac.mm */; };
                65901A4409FC6039005BD752 /* WebCoreStringTruncator.h in Headers */ = {isa = PBXBuildFile; fileRef = 65901A4209FC6039005BD752 /* WebCoreStringTruncator.h */; settings = {ATTRIBUTES = (Private, ); }; };
                65901A4509FC6039005BD752 /* WebCoreStringTruncator.mm in Sources */ = {isa = PBXBuildFile; fileRef = 65901A4309FC6039005BD752 /* WebCoreStringTruncator.mm */; };
                1A762C700A074F2600989F5B /* JSXPathNSResolver.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = JSXPathNSResolver.h; sourceTree = "<group>"; };
                1A762C710A074F2600989F5B /* JSXPathResult.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = JSXPathResult.cpp; sourceTree = "<group>"; };
                1A762C720A074F2600989F5B /* JSXPathResult.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = JSXPathResult.h; sourceTree = "<group>"; };
+               1A8180A40B1D4E4300CE46C4 /* ResourceResponse.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ResourceResponse.cpp; sourceTree = "<group>"; };
                1A820D8F0A13EBA600AF843C /* ImageDocument.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = ImageDocument.cpp; sourceTree = "<group>"; };
                1A820D900A13EBA600AF843C /* ImageDocument.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = ImageDocument.h; sourceTree = "<group>"; };
                1A85B17D0A1B183600D8C87C /* HTMLHtmlElement.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = HTMLHtmlElement.idl; sourceTree = "<group>"; };
                6582A17709999EA000BEEB6D /* DeprecatedStringMac.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = DeprecatedStringMac.mm; sourceTree = "<group>"; };
                658436850AE01B7400E53753 /* FrameLoadRequest.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = FrameLoadRequest.h; sourceTree = "<group>"; };
                658821650AF4CDF700F01D1F /* ResourceResponse.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = ResourceResponse.h; sourceTree = "<group>"; };
-               658821680AF4CE1200F01D1F /* ResourceResponseMac.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = ResourceResponseMac.h; sourceTree = "<group>"; };
                658821690AF4CE1200F01D1F /* ResourceResponseMac.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = ResourceResponseMac.mm; sourceTree = "<group>"; };
                65901A4209FC6039005BD752 /* WebCoreStringTruncator.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = WebCoreStringTruncator.h; sourceTree = "<group>"; };
                65901A4309FC6039005BD752 /* WebCoreStringTruncator.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = WebCoreStringTruncator.mm; sourceTree = "<group>"; };
                                656B84DF0AEA1D3100A095B4 /* ResourceHandleInternal.h */,
                                1AD8CFCD0B1CED8900696DE0 /* ResourceRequest.cpp */,
                                6522BCDE09C9DAA800C9BA7A /* ResourceRequest.h */,
+                               1A8180A40B1D4E4300CE46C4 /* ResourceResponse.cpp */,
                                658821650AF4CDF700F01D1F /* ResourceResponse.h */,
                        );
                        path = network;
                                65DAD9FF0AFD86BF00CE53ED /* FormDataStreamMac.mm */,
                                656B84EA0AEA1DDA00A095B4 /* ResourceHandleMac.mm */,
                                650E3F680AF6C168001FA3AD /* ResourceRequestMac.mm */,
-                               658821680AF4CE1200F01D1F /* ResourceResponseMac.h */,
                                658821690AF4CE1200F01D1F /* ResourceResponseMac.mm */,
                        );
                        path = mac;
                                148A00110AF59F3F008CC700 /* FontPlatformData.h in Headers */,
                                93E22A730AF5E94C00D48324 /* PageState.h in Headers */,
                                658821660AF4CDF700F01D1F /* ResourceResponse.h in Headers */,
-                               6588216B0AF4CE1200F01D1F /* ResourceResponseMac.h in Headers */,
                                93CCF0270AF6C52900018E89 /* NavigationAction.h in Headers */,
                                B2A015A90AF6CD53006BCE0E /* GraphicsContext.h in Headers */,
                                B2A015AB0AF6CD53006BCE0E /* GraphicsTypes.h in Headers */,
                                A7352C190B1BB89D00A986D0 /* RenderSVGBlock.cpp in Sources */,
                                1AD8CFCE0B1CED8900696DE0 /* ResourceRequest.cpp in Sources */,
                                06027CB30B1CC03D00884B2D /* ContextMenuItemMac.mm in Sources */,
+                               1A8180A50B1D4E4300CE46C4 /* ResourceResponse.cpp in Sources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
index 78cd64dd6366c421e5fbfa8b49d867551a9e5211..1509394d71c95fce861b45af5a5dd872dfc050f0 100644 (file)
@@ -57,7 +57,6 @@
 #import "Plugin.h"
 #import "ResourceRequest.h"
 #import "ResourceResponse.h"
-#import "ResourceResponseMac.h"
 #import "SubresourceLoader.h"
 #import "SystemTime.h"
 #import "TextResourceDecoder.h"
@@ -1242,7 +1241,7 @@ void FrameLoader::loadResourceSynchronously(const ResourceRequest& request, Vect
     [initialRequest release];
 
     if (error == nil)
-        getResourceResponse(r, response);
+        r = response;
     else {
         r = ResourceResponse(URL, String(), 0, String(), String());
         if ([error domain] == NSURLErrorDomain)
index 0c0d5f78a5d6f62e1780a5aabb5c638bbb5446a7..239727905e639fe815842cc35acd4570f2301b20 100644 (file)
@@ -177,6 +177,7 @@ void ResourceRequest::updatePlatformRequest() const
         return;
     
     const_cast<ResourceRequest*>(this)->doUpdatePlatformRequest();
+    m_platformRequestUpdated = true;
 #endif
 }
 
@@ -187,6 +188,7 @@ void ResourceRequest::updateResourceRequest() const
         return;
 
     const_cast<ResourceRequest*>(this)->doUpdateResourceRequest();
+    m_resourceRequestUpdated = true;
 #endif
 }
 
index 2226fdf1197c4eebdb579601e3a9ef76b652fe8b..2b680d567abf2aed8f4a712014e06e909246dd57 100644 (file)
 #include "HTTPHeaderMap.h"
 
 #if PLATFORM(MAC)
-
 #include "RetainPtr.h"
-
 #ifdef __OBJC__
 @class NSURLRequest;
 #else
 class NSURLRequest;
 #endif
-
 #elif USE(CFNETWORK)
 #include "RetainPtr.h"
 typedef const struct _CFURLRequest* CFURLRequestRef;
@@ -179,8 +176,8 @@ namespace WebCore {
         HTTPHeaderMap m_httpHeaderFields;
         RefPtr<FormData> m_httpBody;
         bool m_allowHTTPCookies;
-        bool m_resourceRequestUpdated;
-        bool m_platformRequestUpdated;
+        mutable bool m_resourceRequestUpdated;
+        mutable bool m_platformRequestUpdated;
 #if PLATFORM(MAC)
         RetainPtr<NSURLRequest> m_nsRequest;
 #elif USE(CFNETWORK)
diff --git a/WebCore/platform/network/ResourceResponse.cpp b/WebCore/platform/network/ResourceResponse.cpp
new file mode 100644 (file)
index 0000000..5e1b0f8
--- /dev/null
@@ -0,0 +1,149 @@
+// -*- mode: c++; c-basic-offset: 4 -*-
+/*
+ * Copyright (C) 2006 Apple Computer, 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 COMPUTER, 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 COMPUTER, 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 "ResourceResponse.h"
+
+namespace WebCore {
+
+const KURL& ResourceResponse::url() const
+{
+    updateResourceResponse();
+    
+    return m_url; 
+}
+
+const String& ResourceResponse::mimeType() const
+{
+    updateResourceResponse();
+
+    return m_mimeType; 
+}
+
+long long ResourceResponse::expectedContentLength() const 
+{
+    updateResourceResponse();
+
+    return m_expectedContentLength;
+}
+
+const String& ResourceResponse::textEncodingName() const
+{
+    updateResourceResponse();
+
+    return m_textEncodingName;
+}
+
+// FIXME should compute this on the fly
+const String& ResourceResponse::suggestedFilename() const
+{
+    updateResourceResponse();
+
+    return m_suggestedFilename;
+}
+
+int ResourceResponse::httpStatusCode() const
+{
+    updateResourceResponse();
+
+    return m_httpStatusCode; 
+}
+
+void ResourceResponse::setHTTPStatusCode(int statusCode)
+{
+    updateResourceResponse();
+
+    m_httpStatusCode = statusCode;
+}
+
+const String& ResourceResponse::httpStatusText() const 
+{
+    updateResourceResponse();
+
+    return m_httpStatusText; 
+}
+
+void ResourceResponse::setHTTPStatusText(const String& statusText) 
+{
+    updateResourceResponse();
+
+    m_httpStatusText = statusText; 
+}
+
+String ResourceResponse::httpHeaderField(const String& name) const
+{
+    updateResourceResponse();
+
+    return m_httpHeaderFields.get(name); 
+}
+
+const HTTPHeaderMap& ResourceResponse::httpHeaderFields() const
+{
+    updateResourceResponse();
+
+    return m_httpHeaderFields; 
+}
+
+void ResourceResponse::setExpirationDate(time_t expirationDate)
+{
+    updateResourceResponse();
+
+    m_expirationDate = expirationDate;
+}
+
+time_t ResourceResponse::expirationDate() const
+{
+    updateResourceResponse();
+
+    return m_expirationDate; 
+}
+
+void ResourceResponse::setLastModifiedDate(time_t lastModifiedDate) 
+{
+    updateResourceResponse();
+
+    m_lastModifiedDate = lastModifiedDate; 
+}
+
+time_t ResourceResponse::lastModifiedDate() const
+{
+    updateResourceResponse();
+
+    return m_lastModifiedDate; 
+}
+
+void ResourceResponse::updateResourceResponse() const
+{
+#if PLATFORM(MAC) || USE(CFNETWORK)
+    if (m_isUpToDate)
+        return;
+    
+    const_cast<ResourceResponse*>(this)->doUpdateResourceResponse();
+    m_isUpToDate = true;
+#endif
+}
+
+}
index 5b5c63aa5b3bd0db2527a0412c97e1193cda997e..32c86464e538e1167fb98e82a814a867270dd9f5 100644 (file)
 #include "HTTPHeaderMap.h"
 #include "KURL.h"
 
+#if PLATFORM(MAC)
+#include "RetainPtr.h"
+#ifdef __OBJC__
+@class NSURLResponse;
+#else
+class NSURLResponse;
+#endif
+#elif USE(CFNETWORK)
+#include "RetainPtr.h"
+typedef struct _CFURLResponse* CFURLResponseRef;
+#endif
+
 namespace WebCore {
 
 class ResourceResponse {
@@ -38,7 +50,8 @@ public:
     ResourceResponse() 
         : m_expectedContentLength(0)
         , m_httpStatusCode(0)
-        , m_expirationDate(0) 
+        , m_expirationDate(0)
+        , m_isUpToDate(true)
     {
     }
 
@@ -50,34 +63,52 @@ public:
         , m_suggestedFilename(filename)
         , m_httpStatusCode(0)
         , m_expirationDate(0)
+        , m_isUpToDate(true)
     {
     }
  
-    const KURL& url() const { return m_url; }
-    const String& mimeType() const { return m_mimeType; }
-    long long expectedContentLength() const { return m_expectedContentLength; }
-    const String& textEncodingName() const { return m_textEncodingName; }
+    const KURL& url() const;
+    const String& mimeType() const;
+    long long expectedContentLength() const;
+    const String& textEncodingName() const;
 
     // FIXME should compute this on the fly
-    const String& suggestedFilename() const { return m_suggestedFilename; }
+    const String& suggestedFilename() const;
 
-    int httpStatusCode() const { return m_httpStatusCode; }
-    void setHTTPStatusCode(int statusCode) { m_httpStatusCode = statusCode; }
-    const String& httpStatusText() const { return m_httpStatusText; }
-    void setHTTPStatusText(const String& statusText) { m_httpStatusText = statusText; }
-    String httpHeaderField(const String& name) const { return m_httpHeaderFields.get(name); }
-    const HTTPHeaderMap& httpHeaderFields() const { return m_httpHeaderFields; }
-    HTTPHeaderMap& httpHeaderFields() { return m_httpHeaderFields; }
+    int httpStatusCode() const;
+    void setHTTPStatusCode(int);
+    
+    const String& httpStatusText() const;
+    void setHTTPStatusText(const String&);
+    
+    String httpHeaderField(const String& name) const;
+    const HTTPHeaderMap& httpHeaderFields() const;
 
-    bool isMultipart() const { return m_mimeType == "multipart/x-mixed-replace"; }
+    bool isMultipart() const { return mimeType() == "multipart/x-mixed-replace"; }
 
-    void setExpirationDate(time_t expirationDate) { m_expirationDate = expirationDate; }
-    time_t expirationDate() const { return m_expirationDate; }
+    void setExpirationDate(time_t);
+    time_t expirationDate() const;
 
-    void setLastModifiedDate(time_t lastModifiedDate) { m_lastModifiedDate = lastModifiedDate; }
-    time_t lastModifiedDate() const { return m_lastModifiedDate; }
+    void setLastModifiedDate(time_t);
+    time_t lastModifiedDate() const;
 
+#if PLATFORM(MAC)
+    ResourceResponse(NSURLResponse* nsResponse)
+        : m_isUpToDate(false)
+        , m_nsResponse(nsResponse) { }
+#elif USE(CFNETWORK)
+    ResourceResponse(CFURLResponseRef cfResponse)
+        : m_isUpToDate(false)
+        , m_cfResponse(cfResponse) { }
+#endif
+    
  private:
+    void updateResourceResponse() const; 
+    
+#if PLATFORM(MAC) || USE(CFNETWORK)
+    void doUpdateResourceResponse();
+#endif
+    
     KURL m_url;
     String m_mimeType;
     long long m_expectedContentLength;
@@ -88,6 +119,13 @@ public:
     HTTPHeaderMap m_httpHeaderFields;
     time_t m_expirationDate;
     time_t m_lastModifiedDate;
+    mutable bool m_isUpToDate;
+#if PLATFORM(MAC)
+    RetainPtr<NSURLResponse> m_nsResponse;
+#elif USE(CFNETWORK)
+    RetainPtr<CFURLResponseRef> m_cfResponse;      
+#endif
+    
 };
 
 } // namespace WebCore
index afe01ca9affe46a38a2b5f8c0b4c4cd8d2f95d37..0baaebe4aac3d27704d9ba94c2323d421883db9d 100644 (file)
@@ -33,7 +33,6 @@
 #import "FrameMac.h"
 #import "ResourceError.h"
 #import "ResourceResponse.h"
-#import "ResourceResponseMac.h"
 #import "SubresourceLoader.h"
 
 namespace WebCore {
@@ -88,9 +87,7 @@ void ResourceHandle::receivedResponse(NSURLResponse* nsResponse)
 
     if (client()) {
         client()->receivedResponse(this, nsResponse);
-        ResourceResponse response;
-        getResourceResponse(response, nsResponse);
-        client()->didReceiveResponse(this, response);
+        client()->didReceiveResponse(this, nsRresponse);
     }
 }
 
@@ -104,9 +101,7 @@ NSURLRequest *ResourceHandle::willSendRequest(NSURLRequest *nsRequest, NSURLResp
     ASSERT(nsRequest);
     if (ResourceHandleClient* c = client()) {
         ResourceRequest request(nsRequest);
-        ResourceResponse redirectResponse;
-        getResourceResponse(redirectResponse, nsRedirectResponse);
-        c->willSendRequest(this, request, redirectResponse);
+        c->willSendRequest(this, request, nsRedirectResponse);
         return request.nsURLRequest();
     }
 
diff --git a/WebCore/platform/network/mac/ResourceResponseMac.h b/WebCore/platform/network/mac/ResourceResponseMac.h
deleted file mode 100644 (file)
index bde1c81..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-// -*- mode: c++; c-basic-offset: 4 -*-
-/*
- * Copyright (C) 2006 Apple Computer, 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 COMPUTER, 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 COMPUTER, 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 ResourceResponseMac_h_
-#define ResourceResponseMac_h_
-
-@class NSURLResponse;
-
-namespace WebCore {
-
-    class ResourceResponse;
-
-    void getResourceResponse(ResourceResponse&, NSURLResponse *);
-
-}
-
-#endif // ResourceResponseMac_h_
index ac0b141ec0924058ba80b71185b2648c3f60b1d4..1f9abfa2ca2bdc516c5729a451ade852dcedff88 100644 (file)
@@ -25,9 +25,8 @@
  */
 
 #import "config.h"
-#import "ResourceResponseMac.h"
-
 #import "ResourceResponse.h"
+
 #import <Foundation/Foundation.h>
 #import <limits>
 
 
 namespace WebCore {
 
-void getResourceResponse(ResourceResponse& response, NSURLResponse *nsResponse)
+void ResourceResponse::doUpdateResourceResponse()
 {
-    response = ResourceResponse([nsResponse URL], [nsResponse MIMEType],
-        [nsResponse expectedContentLength], [nsResponse textEncodingName],
-        [nsResponse suggestedFilename]);
-
+    m_url = [m_nsResponse.get() URL];
+    m_mimeType = [m_nsResponse.get() MIMEType];
+    m_expectedContentLength = [m_nsResponse.get() expectedContentLength];
+    m_textEncodingName = [m_nsResponse.get() textEncodingName];
+    m_suggestedFilename = [m_nsResponse.get() suggestedFilename];
+    
     const time_t maxTime = std::numeric_limits<time_t>::max();
-
-    NSTimeInterval expiration = [nsResponse _calculatedExpiration];
+    
+    NSTimeInterval expiration = [m_nsResponse.get() _calculatedExpiration];
     expiration += kCFAbsoluteTimeIntervalSince1970;
-    response.setExpirationDate(expiration > maxTime ? maxTime : static_cast<time_t>(expiration));
-
-    if ([nsResponse isKindOfClass:[NSHTTPURLResponse class]]) {
-        NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *)nsResponse;
-
-        response.setHTTPStatusCode([httpResponse statusCode]);
-
+    m_expirationDate = expiration > maxTime ? maxTime : static_cast<time_t>(expiration);
+    
+    if ([m_nsResponse.get() isKindOfClass:[NSHTTPURLResponse class]]) {
+        NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *)m_nsResponse.get();
+        
+        m_httpStatusCode = [httpResponse statusCode];
+        
         // FIXME: it would be nice to have a way to get the real status text eventually.
-        response.setHTTPStatusText("OK");
-       
+        m_httpStatusText = "OK";
+        
         NSDictionary *headers = [httpResponse allHeaderFields];
         NSEnumerator *e = [headers keyEnumerator];
         while (NSString *name = [e nextObject])
-            response.httpHeaderFields().set(name, [headers objectForKey:name]);
-   } 
+            m_httpHeaderFields.set(name, [headers objectForKey:name]);
+    } 
+    
 }
 
 }