Changeset 158895 in webkit


Ignore:
Timestamp:
Nov 7, 2013 6:47:20 PM (11 years ago)
Author:
andersca@apple.com
Message:

Encode and decode NSURLResponse objects using NSCoder
https://bugs.webkit.org/show_bug.cgi?id=124028

Reviewed by Andreas Kling.

  • Shared/mac/WebCoreArgumentCodersMac.mm:

(CoreIPC::::encodePlatformData):
(CoreIPC::::decodePlatformData):

Location:
trunk/Source/WebKit2
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r158892 r158895  
     12013-11-07  Anders Carlsson  <andersca@apple.com>
     2
     3        Encode and decode NSURLResponse objects using NSCoder
     4        https://bugs.webkit.org/show_bug.cgi?id=124028
     5
     6        Reviewed by Andreas Kling.
     7
     8        * Shared/mac/WebCoreArgumentCodersMac.mm:
     9        (CoreIPC::::encodePlatformData):
     10        (CoreIPC::::decodePlatformData):
     11
    1122013-11-07  Anders Carlsson  <andersca@apple.com>
    213
  • trunk/Source/WebKit2/Shared/mac/WebCoreArgumentCodersMac.mm

    r157842 r158895  
    2828
    2929#import "ArgumentCodersCF.h"
     30#import "DataReference.h"
    3031#import "PlatformCertificateInfo.h"
    3132#import "WebKitSystemInterface.h"
     
    106107        return;
    107108
     109#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
     110    RetainPtr<NSMutableData> data = adoptNS([[NSMutableData alloc] init]);
     111    RetainPtr<NSKeyedArchiver> archiver = adoptNS([[NSKeyedArchiver alloc] initForWritingWithMutableData:data.get()]);
     112
     113    [archiver setRequiresSecureCoding:YES];
     114    [archiver.get() encodeObject:resourceResponse.nsURLResponse() forKey:@"response"];
     115    [archiver finishEncoding];
     116
     117    encoder << CoreIPC::DataReference(static_cast<const uint8_t*>([data bytes]), [data length]);
     118#else
    108119    RetainPtr<CFDictionaryRef> dictionary = adoptCF(WKNSURLResponseCreateSerializableRepresentation(resourceResponse.nsURLResponse(), CoreIPC::tokenNullTypeRef()));
    109120    CoreIPC::encode(encoder, dictionary.get());
     121#endif
    110122}
    111123
     
    121133    }
    122134
     135#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
     136    CoreIPC::DataReference dataReference;
     137    if (!decoder.decode(dataReference))
     138        return false;
     139
     140    RetainPtr<NSData> data = adoptNS([[NSData alloc] initWithBytesNoCopy:const_cast<uint8_t*>(dataReference.data()) length:dataReference.size() freeWhenDone:NO]);
     141    RetainPtr<NSKeyedUnarchiver> unarchiver = adoptNS([[NSKeyedUnarchiver alloc] initForReadingWithData:data.get()]);
     142
     143    [unarchiver setRequiresSecureCoding:YES];
     144    NSURLResponse *nsURLResponse = [unarchiver.get() decodeObjectOfClass:[NSURLResponse class] forKey:@"response"];
     145#else
    123146    RetainPtr<CFDictionaryRef> dictionary;
    124147    if (!CoreIPC::decode(decoder, dictionary))
    125148        return false;
    126149
    127     NSURLResponse* nsURLResponse = WKNSURLResponseFromSerializableRepresentation(dictionary.get(), CoreIPC::tokenNullTypeRef());
     150    NSURLResponse *nsURLResponse = WKNSURLResponseFromSerializableRepresentation(dictionary.get(), CoreIPC::tokenNullTypeRef());
     151#endif
     152
    128153    if (!nsURLResponse)
    129154        return false;
Note: See TracChangeset for help on using the changeset viewer.