Reviewed by Sam Weinig.
+ Cannot use NSKeyedArchiver in WK2 for ResourceResponses
+ https://bugs.webkit.org/show_bug.cgi?id=50792
+ <rdar://problem/8741799>
+
+ When encoding, first convert the requests and responses to the serializable dictionary representation
+ and use the newly added CF CoreIPC encoders. When decoding, do the opposite.
+
+ * Shared/mac/WebCoreArgumentCodersMac.mm:
+ (CoreIPC::encodeResourceRequest):
+ (CoreIPC::decodeResourceRequest):
+ (CoreIPC::encodeResourceResponse):
+ (CoreIPC::decodeResourceResponse):
+
+2010-12-09 Anders Carlsson <andersca@apple.com>
+
+ Reviewed by Sam Weinig.
+
Add CoreIPC coders for CF types
https://bugs.webkit.org/show_bug.cgi?id=50791
#include "WebCoreArgumentCoders.h"
-namespace CoreIPC {
-
-static void encodeWithNSKeyedArchiver(ArgumentEncoder* encoder, id rootObject)
-{
- NSData *data = [NSKeyedArchiver archivedDataWithRootObject:rootObject];
- encoder->encodeBytes(static_cast<const uint8_t*>([data bytes]), [data length]);
-}
+#include "ArgumentCodersCF.h"
+#include "WebKitSystemInterface.h"
-static id decodeWithNSKeyedArchiver(ArgumentDecoder* decoder)
-{
- Vector<uint8_t> bytes;
- if (!decoder->decodeBytes(bytes))
- return nil;
-
- RetainPtr<NSData> nsData(AdoptNS, [[NSData alloc] initWithBytesNoCopy:bytes.data() length:bytes.size() freeWhenDone:NO]);
- return [NSKeyedUnarchiver unarchiveObjectWithData:nsData.get()];
-}
+namespace CoreIPC {
void encodeResourceRequest(ArgumentEncoder* encoder, const WebCore::ResourceRequest& resourceRequest)
{
- encodeWithNSKeyedArchiver(encoder, resourceRequest.nsURLRequest());
+ RetainPtr<CFDictionaryRef> dictionary(AdoptCF, WKNSURLRequestCreateSerializableRepresentation(resourceRequest.nsURLRequest(), CoreIPC::tokenNullTypeRef()));
+ encode(encoder, dictionary.get());
}
bool decodeResourceRequest(ArgumentDecoder* decoder, WebCore::ResourceRequest& resourceRequest)
{
- NSURLRequest *nsURLRequest = decodeWithNSKeyedArchiver(decoder);
+ RetainPtr<CFDictionaryRef> dictionary;
+ if (!decode(decoder, dictionary))
+ return false;
+
+ NSURLRequest *nsURLRequest = WKNSURLRequestFromSerializableRepresentation(dictionary.get(), CoreIPC::tokenNullTypeRef());
if (!nsURLRequest)
return false;
{
bool responseIsPresent = resourceResponse.nsURLResponse();
encoder->encode(responseIsPresent);
-
- // FIXME: <rdar://problem/8741799> - We can't use NSKeyedArchiver here.
- encodeWithNSKeyedArchiver(encoder, resourceResponse.nsURLResponse());
+
+ if (!responseIsPresent)
+ return;
+
+ RetainPtr<CFDictionaryRef> dictionary(AdoptCF, WKNSURLResponseCreateSerializableRepresentation(resourceResponse.nsURLResponse(), CoreIPC::tokenNullTypeRef()));
+ encode(encoder, dictionary.get());
}
bool decodeResourceResponse(ArgumentDecoder* decoder, WebCore::ResourceResponse& resourceResponse)
{
bool responseIsPresent;
decoder->decode(responseIsPresent);
-
- // FIXME: <rdar://problem/8741799> - We can't use NSKeyedArchiver here.
- NSURLResponse *nsURLResponse = decodeWithNSKeyedArchiver(decoder);
- if (responseIsPresent && !nsURLResponse)
+
+ if (!responseIsPresent) {
+ resourceResponse = WebCore::ResourceResponse();
+ return true;
+ }
+
+ RetainPtr<CFDictionaryRef> dictionary;
+ if (!decode(decoder, dictionary))
return false;
- if (responseIsPresent)
- resourceResponse = WebCore::ResourceResponse(nsURLResponse);
+ NSURLResponse* nsURLResponse = WKNSURLResponseFromSerializableRepresentation(dictionary.get(), CoreIPC::tokenNullTypeRef());
+ if (!nsURLResponse)
+ return false;
+ resourceResponse = WebCore::ResourceResponse(nsURLResponse);
return true;
}
void WKSyncSurfaceToView(NSView *view);
void WKEnableSettingCursorWhenInBackground(void);
+
+CFDictionaryRef WKNSURLRequestCreateSerializableRepresentation(NSURLRequest *request, CFTypeRef tokenNull);
+NSURLRequest *WKNSURLRequestFromSerializableRepresentation(CFDictionaryRef representation, CFTypeRef tokenNull);
+
+CFDictionaryRef WKNSURLResponseCreateSerializableRepresentation(NSURLResponse *response, CFTypeRef tokenNull);
+NSURLResponse *WKNSURLResponseFromSerializableRepresentation(CFDictionaryRef representation, CFTypeRef tokenNull);
+
#endif
#if defined(BUILDING_ON_TIGER) || defined(BUILDING_ON_LEOPARD) || defined(BUILDING_ON_SNOW_LEOPARD)