Changeset 90825 in webkit


Ignore:
Timestamp:
Jul 12, 2011 10:51:16 AM (13 years ago)
Author:
psolanki@apple.com
Message:

Reviewed by David Kilzer.

Add NSURLResponse wrapper in ResourceResponse when USE(CFNETWORK) is enabled
https://bugs.webkit.org/show_bug.cgi?id=63286

When USE(CFNETWORK) is enabled on Mac, keep an NSURLResponse object along with the
CFURLResponseRef so that WebKit can continue using the NSURLResponse.

No new tests because no change in functionality and option is not enabled on Mac.

  • platform/network/cf/ResourceResponse.h:

(WebCore::ResourceResponse::ResourceResponse):

  • platform/network/mac/ResourceResponseMac.mm:

(WebCore::ResourceResponse::initNSURLResponse):
(WebCore::ResourceResponse::nsURLResponse):
(WebCore::ResourceResponse::ResourceResponse):

Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r90819 r90825  
     12011-07-12  Pratik Solanki  <psolanki@apple.com>
     2
     3        Reviewed by David Kilzer.
     4
     5        Add NSURLResponse wrapper in ResourceResponse when USE(CFNETWORK) is enabled
     6        https://bugs.webkit.org/show_bug.cgi?id=63286
     7
     8        When USE(CFNETWORK) is enabled on Mac, keep an NSURLResponse object along with the
     9        CFURLResponseRef so that WebKit can continue using the NSURLResponse.
     10
     11        No new tests because no change in functionality and option is not enabled on Mac.
     12
     13        * platform/network/cf/ResourceResponse.h:
     14        (WebCore::ResourceResponse::ResourceResponse):
     15        * platform/network/mac/ResourceResponseMac.mm:
     16        (WebCore::ResourceResponse::initNSURLResponse):
     17        (WebCore::ResourceResponse::nsURLResponse):
     18        (WebCore::ResourceResponse::ResourceResponse):
     19
    1202011-07-12  Pavel Podivilov  <podivilov@chromium.org>
    221
     
    88107        (WebCore::HTMLInputElement::setChecked):
    89108
    90 2011-06-23  Pratik Solanki  <psolanki@apple.com>
     1092011-07-11  Pratik Solanki  <psolanki@apple.com>
    91110
    92111        Reviewed by David Kilzer.
  • trunk/Source/WebCore/platform/network/cf/ResourceResponse.h

    r87460 r90825  
    3232#if USE(CFNETWORK)
    3333typedef struct _CFURLResponse* CFURLResponseRef;
    34 #else
     34#endif
     35
    3536#ifdef __OBJC__
    3637@class NSURLResponse;
    3738#else
    3839class NSURLResponse;
    39 #endif
    4040#endif
    4141
     
    5656        m_isNull = !cfResponse;
    5757    }
     58#if PLATFORM(MAC)
     59    ResourceResponse(NSURLResponse *);
     60#endif
    5861#else
    59     ResourceResponse(NSURLResponse* nsResponse)
     62    ResourceResponse(NSURLResponse *nsResponse)
    6063        : m_nsResponse(nsResponse)
    6164        , m_initLevel(Uninitialized)
     
    8588#if USE(CFNETWORK)
    8689    CFURLResponseRef cfURLResponse() const;
    87 #else
     90#endif
     91#if PLATFORM(MAC)
    8892    NSURLResponse *nsURLResponse() const;
    8993#endif
     
    9599    PassOwnPtr<CrossThreadResourceResponseData> doPlatformCopyData(PassOwnPtr<CrossThreadResourceResponseData> data) const { return data; }
    96100    void doPlatformAdopt(PassOwnPtr<CrossThreadResourceResponseData>) { }
     101#if PLATFORM(MAC)
     102    void initNSURLResponse() const;
     103#endif
    97104
    98105    static bool platformCompare(const ResourceResponse& a, const ResourceResponse& b);
     
    100107#if USE(CFNETWORK)
    101108    mutable RetainPtr<CFURLResponseRef> m_cfResponse;
    102 #else
     109#endif
     110#if PLATFORM(MAC)
    103111    mutable RetainPtr<NSURLResponse> m_nsResponse;
    104112#endif
  • trunk/Source/WebCore/platform/network/mac/ResourceResponseMac.mm

    r87460 r90825  
    2727#import "ResourceResponse.h"
    2828
    29 #if !USE(CFNETWORK)
    30 
    3129#import "HTTPParsers.h"
    3230#import "WebCoreURLResponse.h"
     
    3735#include <wtf/text/CString.h>
    3836
    39 @interface NSURLResponse (FoundationSecretsWebCoreKnowsAbout)
     37using namespace std;
     38
     39@interface NSURLResponse (WebNSURLResponseDetails)
    4040- (NSTimeInterval)_calculatedExpiration;
     41- (id)_initWithCFURLResponse:(CFURLResponseRef)response;
     42- (CFURLResponseRef) _CFURLResponse;
     43+ (id)_responseWithCFURLResponse:(CFURLResponseRef)response;
    4144@end
    4245
     
    4952static const int numCommonHeaderFields = sizeof(commonHeaderFields) / sizeof(AtomicString*);
    5053
     54void ResourceResponse::initNSURLResponse() const
     55{
     56    // Work around a mistake in the NSURLResponse class - <rdar://problem/3346574>.
     57    // The init function takes an NSInteger, even though the accessor returns a long long.
     58    // For values that won't fit in an NSInteger, pass -1 instead.
     59    NSInteger expectedContentLength;
     60    if (m_expectedContentLength < 0 || m_expectedContentLength > numeric_limits<NSInteger>::max())
     61        expectedContentLength = -1;
     62    else
     63        expectedContentLength = static_cast<NSInteger>(m_expectedContentLength);
     64    m_nsResponse.adoptNS([[NSURLResponse alloc] initWithURL:m_url MIMEType:m_mimeType expectedContentLength:expectedContentLength textEncodingName:m_textEncodingName]);
     65}
     66
     67#if USE(CFNETWORK)
     68
    5169NSURLResponse *ResourceResponse::nsURLResponse() const
    5270{
    53     if (!m_nsResponse && !m_isNull) {
    54         // Work around a mistake in the NSURLResponse class.
    55         // The init function takes an NSInteger, even though the accessor returns a long long.
    56         // For values that won't fit in an NSInteger, pass -1 instead.
    57         NSInteger expectedContentLength;
    58         if (m_expectedContentLength < 0 || m_expectedContentLength > std::numeric_limits<NSInteger>::max())
    59             expectedContentLength = -1;
    60         else
    61             expectedContentLength = static_cast<NSInteger>(m_expectedContentLength);
    62         const_cast<ResourceResponse*>(this)->m_nsResponse.adoptNS([[NSURLResponse alloc] initWithURL:m_url MIMEType:m_mimeType expectedContentLength:expectedContentLength textEncodingName:m_textEncodingName]);
     71    if (!m_nsResponse && !m_cfResponse && !m_isNull) {
     72        initNSURLResponse();
     73        m_cfResponse = [m_nsResponse.get() _CFURLResponse];
    6374    }
     75
     76    if (!m_cfResponse)
     77        return nil;
     78
     79    if (!m_nsResponse)
     80        m_nsResponse.adoptNS([[NSURLResponse _responseWithCFURLResponse:m_cfResponse.get()] retain]);
     81
     82    return m_nsResponse.get();
     83}
     84
     85ResourceResponse::ResourceResponse(NSURLResponse* nsResponse)
     86    : m_cfResponse([nsResponse _CFURLResponse])
     87    , m_nsResponse(nsResponse)
     88    , m_initLevel(Uninitialized)
     89{
     90    m_isNull = !nsResponse;
     91}
     92
     93#else
     94
     95NSURLResponse *ResourceResponse::nsURLResponse() const
     96{
     97    if (!m_nsResponse && !m_isNull)
     98        initNSURLResponse();
    6499    return m_nsResponse.get();
    65100}
     
    137172}
    138173
     174#endif // USE(CFNETWORK)
     175
    139176} // namespace WebCore
    140177
    141 #endif // !USE(CFNETWORK)
Note: See TracChangeset for help on using the changeset viewer.