Changeset 240030 in webkit
- Timestamp:
- Jan 15, 2019 8:57:54 PM (5 years ago)
- Location:
- trunk/Source/WebKit
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/ChangeLog
r240029 r240030 1 2019-01-15 Alex Christensen <achristensen@webkit.org> 2 3 Remove more NetworkProcess::singleton use 4 https://bugs.webkit.org/show_bug.cgi?id=193484 5 6 Reviewed by Geoffrey Garen. 7 8 This removes the use of NetworkProcess::singleton in the LegacyCustomProtocolManager. 9 This is the kind of awful duct tape code that keeps me awake at night, but it's necessary 10 because we can't quite remove LegacyCustomProtocolManager yet but we need to allow more than 11 one NetworkProcess object. To make it work well enough until we remove LegacyCustomProtocolManager, 12 use the last NetworkProcess object that has been created. 13 14 * NetworkProcess/CustomProtocols/Cocoa/LegacyCustomProtocolManagerCocoa.mm: 15 (newestNetworkProcess): 16 (LegacyCustomProtocolManager::networkProcessCreated): 17 (+[WKCustomProtocol canInitWithRequest:]): 18 (-[WKCustomProtocol initWithRequest:cachedResponse:client:]): 19 (-[WKCustomProtocol startLoading]): 20 (-[WKCustomProtocol stopLoading]): 21 * NetworkProcess/CustomProtocols/LegacyCustomProtocolManager.cpp: 22 (WebKit::LegacyCustomProtocolManager::LegacyCustomProtocolManager): 23 (WebKit::LegacyCustomProtocolManager::startLoading): 24 (WebKit::LegacyCustomProtocolManager::stopLoading): 25 * NetworkProcess/CustomProtocols/LegacyCustomProtocolManager.h: 26 * NetworkProcess/NetworkProcess.cpp: 27 (WebKit::NetworkProcess::NetworkProcess): 28 1 29 2019-01-15 Alex Christensen <achristensen@webkit.org> 2 30 -
trunk/Source/WebKit/NetworkProcess/CustomProtocols/Cocoa/LegacyCustomProtocolManagerCocoa.mm
r238771 r240030 40 40 using namespace WebKit; 41 41 42 static RefPtr<NetworkProcess>& firstNetworkProcess() 43 { 44 static NeverDestroyed<RefPtr<NetworkProcess>> networkProcess; 45 return networkProcess.get(); 46 } 47 48 void LegacyCustomProtocolManager::networkProcessCreated(NetworkProcess& networkProcess) 49 { 50 auto hasRegisteredSchemes = [] (auto* legacyCustomProtocolManager) { 51 if (!legacyCustomProtocolManager) 52 return false; 53 LockHolder locker(legacyCustomProtocolManager->m_registeredSchemesMutex); 54 return !legacyCustomProtocolManager->m_registeredSchemes.isEmpty(); 55 }; 56 57 RELEASE_ASSERT(!firstNetworkProcess() || !hasRegisteredSchemes(firstNetworkProcess()->supplement<LegacyCustomProtocolManager>())); 58 firstNetworkProcess() = &networkProcess; 59 } 60 42 61 @interface WKCustomProtocol : NSURLProtocol { 43 62 @private … … 55 74 + (BOOL)canInitWithRequest:(NSURLRequest *)request 56 75 { 57 if (auto* customProtocolManager = NetworkProcess::singleton().supplement<LegacyCustomProtocolManager>())76 if (auto* customProtocolManager = firstNetworkProcess()->supplement<LegacyCustomProtocolManager>()) 58 77 return customProtocolManager->supportsScheme([[[request URL] scheme] lowercaseString]); 59 78 return NO; … … 76 95 return nil; 77 96 78 if (auto* customProtocolManager = NetworkProcess::singleton().supplement<LegacyCustomProtocolManager>())97 if (auto* customProtocolManager = firstNetworkProcess()->supplement<LegacyCustomProtocolManager>()) 79 98 _customProtocolID = customProtocolManager->addCustomProtocol(self); 80 99 _initializationRunLoop = CFRunLoopGetCurrent(); … … 90 109 - (void)startLoading 91 110 { 92 if (auto* customProtocolManager = NetworkProcess::singleton().supplement<LegacyCustomProtocolManager>())111 if (auto* customProtocolManager = firstNetworkProcess()->supplement<LegacyCustomProtocolManager>()) 93 112 customProtocolManager->startLoading(self.customProtocolID, [self request]); 94 113 } … … 96 115 - (void)stopLoading 97 116 { 98 if (auto* customProtocolManager = NetworkProcess::singleton().supplement<LegacyCustomProtocolManager>()) {117 if (auto* customProtocolManager = firstNetworkProcess()->supplement<LegacyCustomProtocolManager>()) { 99 118 customProtocolManager->stopLoading(self.customProtocolID); 100 119 customProtocolManager->removeCustomProtocol(self.customProtocolID); -
trunk/Source/WebKit/NetworkProcess/CustomProtocols/LegacyCustomProtocolManager.cpp
r221743 r240030 28 28 #include "LegacyCustomProtocolManager.h" 29 29 30 #include "ChildProcess.h"31 30 #include "LegacyCustomProtocolManagerMessages.h" 32 31 #include "LegacyCustomProtocolManagerProxyMessages.h" 32 #include "NetworkProcess.h" 33 33 #include "NetworkProcessCreationParameters.h" 34 34 #include "WebCoreArgumentCoders.h" … … 48 48 } 49 49 50 LegacyCustomProtocolManager::LegacyCustomProtocolManager( ChildProcess& childProcess)51 : m_ childProcess(childProcess)50 LegacyCustomProtocolManager::LegacyCustomProtocolManager(NetworkProcess& networkProcess) 51 : m_networkProcess(networkProcess) 52 52 { 53 m_ childProcess.addMessageReceiver(Messages::LegacyCustomProtocolManager::messageReceiverName(), *this);53 m_networkProcess.addMessageReceiver(Messages::LegacyCustomProtocolManager::messageReceiverName(), *this); 54 54 } 55 55 … … 78 78 void LegacyCustomProtocolManager::startLoading(uint64_t customProtocolID, const WebCore::ResourceRequest& request) 79 79 { 80 m_ childProcess.send(Messages::LegacyCustomProtocolManagerProxy::StartLoading(customProtocolID, request));80 m_networkProcess.send(Messages::LegacyCustomProtocolManagerProxy::StartLoading(customProtocolID, request)); 81 81 } 82 82 83 83 void LegacyCustomProtocolManager::stopLoading(uint64_t customProtocolID) 84 84 { 85 m_ childProcess.send(Messages::LegacyCustomProtocolManagerProxy::StopLoading(customProtocolID), 0);85 m_networkProcess.send(Messages::LegacyCustomProtocolManagerProxy::StopLoading(customProtocolID), 0); 86 86 } 87 87 -
trunk/Source/WebKit/NetworkProcess/CustomProtocols/LegacyCustomProtocolManager.h
r227364 r240030 60 60 namespace WebKit { 61 61 62 class ChildProcess;62 class NetworkProcess; 63 63 struct NetworkProcessCreationParameters; 64 64 … … 66 66 WTF_MAKE_NONCOPYABLE(LegacyCustomProtocolManager); 67 67 public: 68 explicit LegacyCustomProtocolManager( ChildProcess&);68 explicit LegacyCustomProtocolManager(NetworkProcess&); 69 69 70 70 static const char* supplementName(); … … 97 97 #if PLATFORM(COCOA) 98 98 void registerProtocolClass(NSURLSessionConfiguration*); 99 static void networkProcessCreated(NetworkProcess&); 99 100 #endif 100 101 … … 114 115 void registerProtocolClass(); 115 116 116 ChildProcess& m_childProcess;117 NetworkProcess& m_networkProcess; 117 118 118 119 typedef HashMap<uint64_t, CustomProtocol> CustomProtocolMap; -
trunk/Source/WebKit/NetworkProcess/NetworkProcess.cpp
r239817 r240030 143 143 #if ENABLE(LEGACY_CUSTOM_PROTOCOL_MANAGER) 144 144 addSupplement<LegacyCustomProtocolManager>(); 145 #if PLATFORM(COCOA) 146 LegacyCustomProtocolManager::networkProcessCreated(*this); 147 #endif 145 148 #endif 146 149 #if ENABLE(PROXIMITY_NETWORKING)
Note: See TracChangeset
for help on using the changeset viewer.