Changeset 244246 in webkit
- Timestamp:
- Apr 14, 2019 9:08:23 AM (5 years ago)
- Location:
- trunk/Source/WebKit
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/ChangeLog
r244245 r244246 1 2019-04-14 Andy Estes <aestes@apple.com> 2 3 [Cocoa] WKCustomProtocolLoader should store a WeakPtr to its LegacyCustomProtocolManagerProxy 4 https://bugs.webkit.org/show_bug.cgi?id=196893 5 <rdar://problem/48318983> 6 7 Reviewed by Anders Carlsson. 8 9 In addition to manually invalidating each WKCustomProtocolLoader's _customProtocolManagerProxy 10 pointer when the LegacyCustomProtocolManagerClient is invalidated, use a WeakPtr in case the 11 LegacyCustomProtocolManagerProxy is ever destroyed without first invalidating the client. 12 Also add null pointer checks to NSURLConnectionDelegate methods, which might be called after 13 the LegacyCustomProtocolManagerProxy has been destroyed. 14 15 * UIProcess/Cocoa/LegacyCustomProtocolManagerClient.mm: 16 (-[WKCustomProtocolLoader initWithLegacyCustomProtocolManagerProxy:customProtocolID:request:]): 17 (-[WKCustomProtocolLoader cancel]): 18 (-[WKCustomProtocolLoader connection:didFailWithError:]): 19 (-[WKCustomProtocolLoader connection:didReceiveResponse:]): 20 (-[WKCustomProtocolLoader connection:didReceiveData:]): 21 (-[WKCustomProtocolLoader connection:willSendRequest:redirectResponse:]): 22 (-[WKCustomProtocolLoader connectionDidFinishLoading:]): 23 (WebKit::LegacyCustomProtocolManagerClient::startLoading): 24 (WebKit::LegacyCustomProtocolManagerClient::invalidate): 25 (-[WKCustomProtocolLoader customProtocolManagerProxyDestroyed]): Deleted. 26 * UIProcess/Network/CustomProtocols/LegacyCustomProtocolManagerProxy.h: 27 1 28 2019-04-14 Don Olmstead <don.olmstead@sony.com> 2 29 -
trunk/Source/WebKit/UIProcess/Cocoa/LegacyCustomProtocolManagerClient.mm
r235935 r244246 35 35 @interface WKCustomProtocolLoader : NSObject <NSURLConnectionDelegate> { 36 36 @private 37 We bKit::LegacyCustomProtocolManagerProxy*_customProtocolManagerProxy;37 WeakPtr<WebKit::LegacyCustomProtocolManagerProxy> _customProtocolManagerProxy; 38 38 uint64_t _customProtocolID; 39 39 NSURLCacheStoragePolicy _storagePolicy; 40 40 NSURLConnection *_urlConnection; 41 41 } 42 - (id)initWithLegacyCustomProtocolManagerProxy:(WebKit::LegacyCustomProtocolManagerProxy *)customProtocolManagerProxy customProtocolID:(uint64_t)customProtocolID request:(NSURLRequest *)request;43 - (void)c ustomProtocolManagerProxyDestroyed;42 - (id)initWithLegacyCustomProtocolManagerProxy:(WebKit::LegacyCustomProtocolManagerProxy&)customProtocolManagerProxy customProtocolID:(uint64_t)customProtocolID request:(NSURLRequest *)request; 43 - (void)cancel; 44 44 @end 45 45 46 46 @implementation WKCustomProtocolLoader 47 47 48 - (id)initWithLegacyCustomProtocolManagerProxy:(WebKit::LegacyCustomProtocolManagerProxy *)customProtocolManagerProxy customProtocolID:(uint64_t)customProtocolID request:(NSURLRequest *)request48 - (id)initWithLegacyCustomProtocolManagerProxy:(WebKit::LegacyCustomProtocolManagerProxy&)customProtocolManagerProxy customProtocolID:(uint64_t)customProtocolID request:(NSURLRequest *)request 49 49 { 50 50 self = [super init]; … … 52 52 return nil; 53 53 54 ASSERT(customProtocolManagerProxy);55 54 ASSERT(request); 56 _customProtocolManagerProxy = customProtocolManagerProxy;55 _customProtocolManagerProxy = makeWeakPtr(customProtocolManagerProxy); 57 56 _customProtocolID = customProtocolID; 58 57 _storagePolicy = NSURLCacheStorageNotAllowed; … … 73 72 } 74 73 75 - (void)c ustomProtocolManagerProxyDestroyed74 - (void)cancel 76 75 { 77 76 ASSERT(_customProtocolManagerProxy); … … 82 81 - (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error 83 82 { 83 if (!_customProtocolManagerProxy) 84 return; 85 84 86 WebCore::ResourceError coreError(error); 85 87 _customProtocolManagerProxy->didFailWithError(_customProtocolID, coreError); … … 96 98 - (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response 97 99 { 100 if (!_customProtocolManagerProxy) 101 return; 102 98 103 WebCore::ResourceResponse coreResponse(response); 99 104 _customProtocolManagerProxy->didReceiveResponse(_customProtocolID, coreResponse, _storagePolicy); … … 102 107 - (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data 103 108 { 109 if (!_customProtocolManagerProxy) 110 return; 111 104 112 IPC::DataReference coreData(static_cast<const uint8_t*>([data bytes]), [data length]); 105 113 _customProtocolManagerProxy->didLoadData(_customProtocolID, coreData); … … 108 116 - (NSURLRequest *)connection:(NSURLConnection *)connection willSendRequest:(NSURLRequest *)request redirectResponse:(NSURLResponse *)redirectResponse 109 117 { 118 if (!_customProtocolManagerProxy) 119 return nil; 120 110 121 if (redirectResponse) { 111 122 _customProtocolManagerProxy->wasRedirectedToRequest(_customProtocolID, request, redirectResponse); … … 117 128 - (void)connectionDidFinishLoading:(NSURLConnection *)connection 118 129 { 130 if (!_customProtocolManagerProxy) 131 return; 132 119 133 _customProtocolManagerProxy->didFinishLoading(_customProtocolID); 120 134 _customProtocolManagerProxy->stopLoading(_customProtocolID); … … 132 146 return; 133 147 134 WKCustomProtocolLoader *loader = [[WKCustomProtocolLoader alloc] initWithLegacyCustomProtocolManagerProxy: &manager customProtocolID:customProtocolID request:request];148 WKCustomProtocolLoader *loader = [[WKCustomProtocolLoader alloc] initWithLegacyCustomProtocolManagerProxy:manager customProtocolID:customProtocolID request:request]; 135 149 ASSERT(loader); 136 150 ASSERT(!m_loaderMap.contains(customProtocolID)); … … 149 163 auto loader = m_loaderMap.take(m_loaderMap.begin()->key); 150 164 ASSERT(loader); 151 [loader c ustomProtocolManagerProxyDestroyed];165 [loader cancel]; 152 166 } 153 167 } -
trunk/Source/WebKit/UIProcess/Network/CustomProtocols/LegacyCustomProtocolManagerProxy.h
r219664 r244246 28 28 #include "MessageReceiver.h" 29 29 30 #include <wtf/WeakPtr.h> 31 30 32 #if PLATFORM(COCOA) 31 33 #include <wtf/HashMap.h> … … 48 50 class NetworkProcessProxy; 49 51 50 class LegacyCustomProtocolManagerProxy : public IPC::MessageReceiver {52 class LegacyCustomProtocolManagerProxy : public CanMakeWeakPtr<LegacyCustomProtocolManagerProxy>, public IPC::MessageReceiver { 51 53 public: 52 54 LegacyCustomProtocolManagerProxy(NetworkProcessProxy&);
Note: See TracChangeset
for help on using the changeset viewer.