Title: [158895] trunk/Source/WebKit2
- Revision
- 158895
- Author
- [email protected]
- Date
- 2013-11-07 18:47:20 -0800 (Thu, 07 Nov 2013)
Log 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):
Modified Paths
Diff
Modified: trunk/Source/WebKit2/ChangeLog (158894 => 158895)
--- trunk/Source/WebKit2/ChangeLog 2013-11-08 02:43:22 UTC (rev 158894)
+++ trunk/Source/WebKit2/ChangeLog 2013-11-08 02:47:20 UTC (rev 158895)
@@ -1,5 +1,16 @@
2013-11-07 Anders Carlsson <[email protected]>
+ 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):
+
+2013-11-07 Anders Carlsson <[email protected]>
+
Move m_destinationID to MessageDecoder
https://bugs.webkit.org/show_bug.cgi?id=124026
Modified: trunk/Source/WebKit2/Shared/mac/WebCoreArgumentCodersMac.mm (158894 => 158895)
--- trunk/Source/WebKit2/Shared/mac/WebCoreArgumentCodersMac.mm 2013-11-08 02:43:22 UTC (rev 158894)
+++ trunk/Source/WebKit2/Shared/mac/WebCoreArgumentCodersMac.mm 2013-11-08 02:47:20 UTC (rev 158895)
@@ -27,6 +27,7 @@
#import "WebCoreArgumentCoders.h"
#import "ArgumentCodersCF.h"
+#import "DataReference.h"
#import "PlatformCertificateInfo.h"
#import "WebKitSystemInterface.h"
#import <WebCore/KeyboardEvent.h>
@@ -105,8 +106,19 @@
if (!responseIsPresent)
return;
+#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
+ RetainPtr<NSMutableData> data = "" alloc] init]);
+ RetainPtr<NSKeyedArchiver> archiver = adoptNS([[NSKeyedArchiver alloc] initForWritingWithMutableData:data.get()]);
+
+ [archiver setRequiresSecureCoding:YES];
+ [archiver.get() encodeObject:resourceResponse.nsURLResponse() forKey:@"response"];
+ [archiver finishEncoding];
+
+ encoder << CoreIPC::DataReference(static_cast<const uint8_t*>([data bytes]), [data length]);
+#else
RetainPtr<CFDictionaryRef> dictionary = adoptCF(WKNSURLResponseCreateSerializableRepresentation(resourceResponse.nsURLResponse(), CoreIPC::tokenNullTypeRef()));
CoreIPC::encode(encoder, dictionary.get());
+#endif
}
bool ArgumentCoder<ResourceResponse>::decodePlatformData(ArgumentDecoder& decoder, ResourceResponse& resourceResponse)
@@ -120,11 +132,24 @@
return true;
}
+#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
+ CoreIPC::DataReference dataReference;
+ if (!decoder.decode(dataReference))
+ return false;
+
+ RetainPtr<NSData> data = "" alloc] initWithBytesNoCopy:const_cast<uint8_t*>(dataReference.data()) length:dataReference.size() freeWhenDone:NO]);
+ RetainPtr<NSKeyedUnarchiver> unarchiver = adoptNS([[NSKeyedUnarchiver alloc] initForReadingWithData:data.get()]);
+
+ [unarchiver setRequiresSecureCoding:YES];
+ NSURLResponse *nsURLResponse = [unarchiver.get() decodeObjectOfClass:[NSURLResponse class] forKey:@"response"];
+#else
RetainPtr<CFDictionaryRef> dictionary;
if (!CoreIPC::decode(decoder, dictionary))
return false;
- NSURLResponse* nsURLResponse = WKNSURLResponseFromSerializableRepresentation(dictionary.get(), CoreIPC::tokenNullTypeRef());
+ NSURLResponse *nsURLResponse = WKNSURLResponseFromSerializableRepresentation(dictionary.get(), CoreIPC::tokenNullTypeRef());
+#endif
+
if (!nsURLResponse)
return false;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes