Reviewed by Darin.
authorweinig <weinig@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 3 Jul 2007 23:19:14 +0000 (23:19 +0000)
committerweinig <weinig@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 3 Jul 2007 23:19:14 +0000 (23:19 +0000)
        Twelfth round of fixes for implicit 64-32 bit conversion errors.
        <rdar://problem/5292262>

        - Add casts and accompanying FIXMEs to avoid remaining compiler errors.

        * WebCore.xcodeproj/project.pbxproj:
        * loader/FrameLoader.cpp:
        (WebCore::FrameLoader::opened):
        (WebCore::FrameLoader::sendRemainingDelegateMessages):
        * loader/FrameLoader.h:
        * loader/ResourceLoader.cpp:
        (WebCore::ResourceLoader::didReceiveData):
        * platform/network/mac/ResourceHandleMac.mm:
        (-[WebCoreResourceHandleAsDelegate connection:didReceiveData:lengthReceived:]):
        (-[WebCoreResourceHandleAsDelegate connection:willStopBufferingData:]):
        * platform/network/mac/ResourceResponseMac.mm:
        (WebCore::ResourceResponse::nsURLResponse):

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

WebCore/ChangeLog
WebCore/loader/FrameLoader.cpp
WebCore/loader/FrameLoader.h
WebCore/loader/ResourceLoader.cpp
WebCore/platform/network/mac/ResourceHandleMac.mm
WebCore/platform/network/mac/ResourceResponseMac.mm

index dbb9f06eac40755b5636c5004050a406a2717ce1..3e10b09765d35ccf9dcc03e5cedc5801676be32f 100644 (file)
@@ -1,3 +1,25 @@
+2007-07-03  Sam Weinig  <sam@webkit.org>
+
+        Reviewed by Darin.
+
+        Twelfth round of fixes for implicit 64-32 bit conversion errors.
+        <rdar://problem/5292262>
+
+        - Add casts and accompanying FIXMEs to avoid remaining compiler errors.
+
+        * WebCore.xcodeproj/project.pbxproj:
+        * loader/FrameLoader.cpp:
+        (WebCore::FrameLoader::opened):
+        (WebCore::FrameLoader::sendRemainingDelegateMessages):
+        * loader/FrameLoader.h:
+        * loader/ResourceLoader.cpp:
+        (WebCore::ResourceLoader::didReceiveData):
+        * platform/network/mac/ResourceHandleMac.mm:
+        (-[WebCoreResourceHandleAsDelegate connection:didReceiveData:lengthReceived:]):
+        (-[WebCoreResourceHandleAsDelegate connection:willStopBufferingData:]):
+        * platform/network/mac/ResourceResponseMac.mm:
+        (WebCore::ResourceResponse::nsURLResponse):
+
 2007-07-03  Anders Carlsson  <andersca@apple.com>
 
         Reviewed by Adam.
index a1372aaf9fe928a96d340781c98551225d3d34ff..fa00f38dac6645d5c3a7b0ca8e1f5af412ba9cd6 100644 (file)
@@ -3279,7 +3279,10 @@ void FrameLoader::opened()
             unsigned long identifier;
             ResourceRequest request(response.url());
             requestFromDelegate(request, identifier, error);
-            sendRemainingDelegateMessages(identifier, response, response.expectedContentLength(), error);
+            // FIXME: If we get a resource with more than 2B bytes, this code won't do the right thing.
+            // However, with today's computers and networking speeds, this won't happen in practice.
+            // Could be an issue with a giant local file.
+            sendRemainingDelegateMessages(identifier, response, static_cast<int>(response.expectedContentLength()), error);
         }
         
         pageCache()->remove(m_currentHistoryItem.get());
@@ -3472,7 +3475,7 @@ void FrameLoader::continueLoadAfterNewWindowPolicy(const ResourceRequest& reques
     mainFrame->loader()->load(request, NavigationAction(), FrameLoadTypeStandard, formState);
 }
 
-void FrameLoader::sendRemainingDelegateMessages(unsigned long identifier, const ResourceResponse& response, unsigned length, const ResourceError& error)
+void FrameLoader::sendRemainingDelegateMessages(unsigned long identifier, const ResourceResponse& response, int length, const ResourceError& error)
 {    
     if (!response.isNull())
         dispatchDidReceiveResponse(m_documentLoader.get(), identifier, response);
index 137982e2a663bf61973715d471f4b3ff7d631694..bf9f193cffdef6419a4babaa060d48c3b3bb8ace 100644 (file)
@@ -258,7 +258,7 @@ namespace WebCore {
 
         bool isQuickRedirectComing() const;
 
-        void sendRemainingDelegateMessages(unsigned long identifier, const ResourceResponse&, unsigned length, const ResourceError&);
+        void sendRemainingDelegateMessages(unsigned long identifier, const ResourceResponse&, int length, const ResourceError&);
         void requestFromDelegate(ResourceRequest&, unsigned long& identifier, ResourceError&);
         void loadedResourceFromMemoryCache(const ResourceRequest&, const ResourceResponse&, int length);
 
index 877e61b4b23fb0dba2fb3467b922bb4f64c997a3..8ba007d2e3e7b03cca74c1eb76b126cc169a5150 100644 (file)
@@ -211,8 +211,11 @@ void ResourceLoader::didReceiveData(const char* data, int length, long long leng
     RefPtr<ResourceLoader> protector(this);
 
     addData(data, length, allAtOnce);
+    // FIXME: If we get a resource with more than 2B bytes, this code won't do the right thing.
+    // However, with today's computers and networking speeds, this won't happen in practice.
+    // Could be an issue with a giant local file.
     if (m_sendResourceLoadCallbacks && m_frame)
-        frameLoader()->didReceiveData(this, data, length, lengthReceived);
+        frameLoader()->didReceiveData(this, data, length, static_cast<int>(lengthReceived));
 }
 
 void ResourceLoader::willStopBufferingData(const char* data, int length)
index cc296f35087380406ab37f1868bd1526d344778f..5788d5878fa7c0faff986d2e4b5e6cb80da9f195 100644 (file)
@@ -347,8 +347,11 @@ void ResourceHandle::receivedCancellation(const AuthenticationChallenge& challen
 {
     if (!m_handle)
         return;
+    // FIXME: If we get more than 2B bytes in a single chunk, this code won't do the right thing.
+    // However, with today's computers and networking speeds, this won't happen in practice.
+    // Could be an issue with a giant local file.
     ++inNSURLConnectionCallback;
-    m_handle->client()->didReceiveData(m_handle, (const char*)[data bytes], [data length], lengthReceived);
+    m_handle->client()->didReceiveData(m_handle, (const char*)[data bytes], [data length], static_cast<int>(lengthReceived));
     --inNSURLConnectionCallback;
 }
 
@@ -356,8 +359,11 @@ void ResourceHandle::receivedCancellation(const AuthenticationChallenge& challen
 {
     if (!m_handle)
         return;
+    // FIXME: If we get a resource with more than 2B bytes, this code won't do the right thing.
+    // However, with today's computers and networking speeds, this won't happen in practice.
+    // Could be an issue with a giant local file.
     ++inNSURLConnectionCallback;
-    m_handle->client()->willStopBufferingData(m_handle, (const char*)[data bytes], [data length]);
+    m_handle->client()->willStopBufferingData(m_handle, (const char*)[data bytes], static_cast<int>([data length]));
     --inNSURLConnectionCallback;
 }
 
index c804bb2a446c1d143a5179cafb6549840c897cd3..7d6c53c79161baa56c54d83841a6e284e022aa27 100644 (file)
 - (NSTimeInterval)_calculatedExpiration;
 @end
 
+#ifdef BUILDING_ON_TIGER
+typedef int NSInteger;
+#endif
+
 namespace WebCore {
 
 NSURLResponse *ResourceResponse::nsURLResponse() const
 {
-    if (!m_nsResponse && !m_isNull)
-        const_cast<ResourceResponse*>(this)->m_nsResponse.adoptNS([[NSURLResponse alloc] initWithURL:m_url.getNSURL() MIMEType:m_mimeType expectedContentLength:m_expectedContentLength textEncodingName:m_textEncodingName]);
-    
+    if (!m_nsResponse && !m_isNull) {
+        // Work around a mistake in the NSURLResponse class.
+        // The init function takes an NSInteger, even though the accessor returns a long long.
+        // For values that won't fit in an NSInteger, pass -1 instead.
+        NSInteger expectedContentLength;
+        if (m_expectedContentLength < 0 || m_expectedContentLength > std::numeric_limits<NSInteger>::max())
+            expectedContentLength = -1;
+        else
+            expectedContentLength = static_cast<NSInteger>(m_expectedContentLength);
+        const_cast<ResourceResponse*>(this)->m_nsResponse.adoptNS([[NSURLResponse alloc] initWithURL:m_url.getNSURL() MIMEType:m_mimeType expectedContentLength:expectedContentLength textEncodingName:m_textEncodingName]);
+    }
     return m_nsResponse.get();
 }