Changeset 187174 in webkit
- Timestamp:
- Jul 22, 2015, 12:56:16 PM (11 years ago)
- Location:
- trunk/Source/WebKit2
- Files:
-
- 2 edited
-
ChangeLog (modified) (1 diff)
-
Shared/mac/WebCoreArgumentCodersMac.mm (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit2/ChangeLog
r187173 r187174 1 2015-07-22 Sam Weinig <sam@webkit.org> 2 3 Encode/Decode underlying errors when serializing NSErrors 4 <rdar://problem/21818117> 5 https://bugs.webkit.org/show_bug.cgi?id=147199 6 7 Reviewed by Anders Carlsson. 8 9 * Shared/mac/WebCoreArgumentCodersMac.mm: 10 (IPC::ArgumentCoder<CertificateInfo>::decode): 11 (IPC::encodeNSError): 12 (IPC::ArgumentCoder<ResourceError>::encodePlatformData): 13 (IPC::decodeNSError): 14 (IPC::ArgumentCoder<ResourceError>::decodePlatformData): 15 Break out encoding/decoding of the NSErrors into a helpers so they can be called 16 for the underlying error. 17 1 18 2015-07-22 Beth Dakin <bdakin@apple.com> 2 19 -
trunk/Source/WebKit2/Shared/mac/WebCoreArgumentCodersMac.mm
r186812 r187174 192 192 } 193 193 194 void ArgumentCoder<ResourceError>::encodePlatformData(ArgumentEncoder& encoder, const ResourceError& resourceError) 195 { 196 bool errorIsNull = resourceError.isNull(); 197 encoder << errorIsNull; 198 199 if (errorIsNull) 200 return; 201 202 NSError *nsError = resourceError.nsError(); 203 194 static void encodeNSError(ArgumentEncoder& encoder, NSError *nsError) 195 { 204 196 String domain = [nsError domain]; 205 197 encoder << domain; … … 243 235 ASSERT(!peerCertificateChain || [peerCertificateChain isKindOfClass:[NSArray class]]); 244 236 encoder << CertificateInfo((CFArrayRef)peerCertificateChain); 237 238 if (id underlyingError = [userInfo objectForKey:NSUnderlyingErrorKey]) { 239 ASSERT([underlyingError isKindOfClass:[NSError class]]); 240 encoder << true; 241 encodeNSError(encoder, underlyingError); 242 } else 243 encoder << false; 244 } 245 246 void ArgumentCoder<ResourceError>::encodePlatformData(ArgumentEncoder& encoder, const ResourceError& resourceError) 247 { 248 bool errorIsNull = resourceError.isNull(); 249 encoder << errorIsNull; 250 251 if (errorIsNull) 252 return; 253 254 NSError *nsError = resourceError.nsError(); 255 encodeNSError(encoder, nsError); 256 } 257 258 static bool decodeNSError(ArgumentDecoder& decoder, RetainPtr<NSError>& nsError) 259 { 260 String domain; 261 if (!decoder.decode(domain)) 262 return false; 263 264 int64_t code; 265 if (!decoder.decode(code)) 266 return false; 267 268 RetainPtr<CFDictionaryRef> userInfo; 269 if (!IPC::decode(decoder, userInfo)) 270 return false; 271 272 CertificateInfo certificate; 273 if (!decoder.decode(certificate)) 274 return false; 275 276 if (certificate.certificateChain()) { 277 userInfo = adoptCF(CFDictionaryCreateMutableCopy(kCFAllocatorDefault, CFDictionaryGetCount(userInfo.get()) + 1, userInfo.get())); 278 CFDictionarySetValue((CFMutableDictionaryRef)userInfo.get(), CFSTR("NSErrorPeerCertificateChainKey"), (CFArrayRef)certificate.certificateChain()); 279 } 280 281 bool hasUnderlyingError = false; 282 if (!decoder.decode(hasUnderlyingError)) 283 return false; 284 285 if (hasUnderlyingError) { 286 RetainPtr<NSError> underlyingNSError; 287 if (!decodeNSError(decoder, underlyingNSError)) 288 return false; 289 290 userInfo = adoptCF(CFDictionaryCreateMutableCopy(kCFAllocatorDefault, CFDictionaryGetCount(userInfo.get()) + 1, userInfo.get())); 291 CFDictionarySetValue((CFMutableDictionaryRef)userInfo.get(), NSUnderlyingErrorKey, underlyingNSError.get()); 292 } 293 294 nsError = adoptNS([[NSError alloc] initWithDomain:domain code:code userInfo:(NSDictionary *)userInfo.get()]); 295 return true; 245 296 } 246 297 … … 255 306 return true; 256 307 } 257 258 String domain; 259 if (!decoder.decode(domain)) 260 return false; 261 262 int64_t code; 263 if (!decoder.decode(code)) 264 return false; 265 266 RetainPtr<CFDictionaryRef> userInfo; 267 if (!IPC::decode(decoder, userInfo)) 268 return false; 269 270 CertificateInfo certificate; 271 if (!decoder.decode(certificate)) 272 return false; 273 274 if (certificate.certificateChain()) { 275 userInfo = adoptCF(CFDictionaryCreateMutableCopy(kCFAllocatorDefault, CFDictionaryGetCount(userInfo.get()) + 1, userInfo.get())); 276 CFDictionarySetValue((CFMutableDictionaryRef)userInfo.get(), CFSTR("NSErrorPeerCertificateChainKey"), (CFArrayRef)certificate.certificateChain()); 277 } 278 279 RetainPtr<NSError> nsError = adoptNS([[NSError alloc] initWithDomain:domain code:code userInfo:(NSDictionary *)userInfo.get()]); 308 309 RetainPtr<NSError> nsError; 310 if (!decodeNSError(decoder, nsError)) 311 return false; 280 312 281 313 resourceError = ResourceError(nsError.get());
Note:
See TracChangeset
for help on using the changeset viewer.