Changeset 139516 in webkit
- Timestamp:
- Jan 11, 2013, 4:08:30 PM (12 years ago)
- Location:
- trunk/Source/WebKit2
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit2/ChangeLog
r139515 r139516 1 2013-01-11 Alexey Proskuryakov <ap@apple.com> 2 3 [WK2] Network process unblocks all waiting threads when any sync reply arrives 4 https://bugs.webkit.org/show_bug.cgi?id=106713 5 6 Reviewed by Brady Eidson. 7 8 Switch to sending sync CoreIPC messages, which is now possible. 9 10 * NetworkProcess/NetworkConnectionToWebProcess.h: 11 * NetworkProcess/NetworkConnectionToWebProcess.cpp: (WebKit::NetworkConnectionToWebProcess::didClose): 12 We no longer have response maps. 13 14 * NetworkProcess/NetworkResourceLoader.cpp: 15 (WebKit::NetworkResourceLoader::willSendRequest): Just send a sync message. 16 (WebKit::NetworkResourceLoader::canAuthenticateAgainstProtectionSpace): Ditto. 17 (WebKit::NetworkResourceLoader::didReceiveDataArray): Added an unrelated assertion. 18 19 * NetworkProcess/NetworkResourceLoader.h: 20 * NetworkProcess/NetworkResourceLoader.messages.in: 21 Removed no longer used reply messages and their handlers. 22 23 * Shared/BlockingResponseMap.h: Removed a bool version, which was not perfectly 24 safe, and only used in NetworkProcess. 25 (BlockingResponseMap::didReceiveResponse): Updated a still valid FIXME to not refer 26 to network process. 27 (BlockingResponseMap::cancel): Ditto. 28 29 * WebProcess/Network/NetworkProcessConnection.h: 30 * WebProcess/Network/NetworkProcessConnection.cpp: 31 (WebKit::NetworkProcessConnection::didReceiveSyncMessage): 32 Plumbing to handle sync messages. 33 34 * WebProcess/Network/WebResourceLoader.cpp: 35 (WebKit::WebResourceLoader::willSendRequest): 36 (WebKit::WebResourceLoader::canAuthenticateAgainstProtectionSpace): 37 * WebProcess/Network/WebResourceLoader.h: 38 * WebProcess/Network/WebResourceLoader.messages.in: 39 Updated (simplified) sync messages and their handlers. 40 1 41 2013-01-11 Alexey Proskuryakov <ap@apple.com> 2 42 -
trunk/Source/WebKit2/NetworkProcess/NetworkConnectionToWebProcess.cpp
r138413 r139516 104 104 NetworkProcess::shared().removeNetworkConnectionToWebProcess(this); 105 105 106 // Unblock waiting threads.107 m_willSendRequestResponseMap.cancel();108 m_canAuthenticateAgainstProtectionSpaceResponseMap.cancel();109 110 106 Vector<NetworkConnectionToWebProcessObserver*> observers; 111 107 copyToVector(m_observers, observers); -
trunk/Source/WebKit2/NetworkProcess/NetworkConnectionToWebProcess.h
r138301 r139516 63 63 bool isSerialLoadingEnabled() const { return m_serialLoadingEnabled; } 64 64 65 BlockingResponseMap<WebCore::ResourceRequest*>& willSendRequestResponseMap() { return m_willSendRequestResponseMap; }66 BlockingBoolResponseMap& canAuthenticateAgainstProtectionSpaceResponseMap() { return m_canAuthenticateAgainstProtectionSpaceResponseMap; }67 68 65 private: 69 66 NetworkConnectionToWebProcess(CoreIPC::Connection::Identifier); … … 97 94 HashSet<NetworkConnectionToWebProcessObserver*> m_observers; 98 95 99 BlockingResponseMap<WebCore::ResourceRequest*> m_willSendRequestResponseMap;100 BlockingBoolResponseMap m_canAuthenticateAgainstProtectionSpaceResponseMap;101 102 96 bool m_serialLoadingEnabled; 103 97 }; -
trunk/Source/WebKit2/NetworkProcess/NetworkResourceLoader.cpp
r138319 r139516 183 183 } 184 184 185 static uint64_t generateWillSendRequestID()186 {187 static int64_t uniqueWillSendRequestID;188 return atomicIncrement(&uniqueWillSendRequestID);189 }190 191 185 void NetworkResourceLoader::willSendRequest(ResourceHandle*, ResourceRequest& request, const ResourceResponse& redirectResponse) 192 186 { 193 187 // We only expect to get the willSendRequest callback from ResourceHandle as the result of a redirect. 194 188 ASSERT(!redirectResponse.isNull()); 195 196 uint64_t requestID = generateWillSendRequestID(); 197 198 if (!send(Messages::WebResourceLoader::WillSendRequest(requestID, request, redirectResponse))) { 189 ASSERT(!isMainThread()); 190 191 if (!sendSync(Messages::WebResourceLoader::WillSendRequest(request, redirectResponse), Messages::WebResourceLoader::WillSendRequest::Reply(request))) 199 192 request = ResourceRequest(); 200 return;201 }202 203 OwnPtr<ResourceRequest> newRequest = m_connection->willSendRequestResponseMap().waitForResponse(requestID);204 request = newRequest ? *newRequest : ResourceRequest();205 206 RunLoop::main()->dispatch(WTF::bind(&NetworkResourceLoadScheduler::receivedRedirect, &NetworkProcess::shared().networkResourceLoadScheduler(), m_identifier, request.url()));207 }208 209 void NetworkResourceLoader::willSendRequestHandled(uint64_t requestID, const WebCore::ResourceRequest& newRequest)210 {211 m_connection->willSendRequestResponseMap().didReceiveResponse(requestID, adoptPtr(new ResourceRequest(newRequest)));212 193 } 213 194 … … 303 284 304 285 #if USE(PROTECTION_SPACE_AUTH_CALLBACK) 305 static uint64_t generateCanAuthenticateAgainstProtectionSpaceID()306 {307 static int64_t uniqueCanAuthenticateAgainstProtectionSpaceID;308 return atomicIncrement(&uniqueCanAuthenticateAgainstProtectionSpaceID);309 }310 311 286 bool NetworkResourceLoader::canAuthenticateAgainstProtectionSpace(ResourceHandle*, const ProtectionSpace& protectionSpace) 312 287 { 313 uint64_t requestID = generateCanAuthenticateAgainstProtectionSpaceID(); 314 315 if (!send(Messages::WebResourceLoader::CanAuthenticateAgainstProtectionSpace(requestID, protectionSpace))) 288 ASSERT(!isMainThread()); 289 290 bool result; 291 if (!sendSync(Messages::WebResourceLoader::CanAuthenticateAgainstProtectionSpace(protectionSpace), Messages::WebResourceLoader::CanAuthenticateAgainstProtectionSpace::Reply(result))) 316 292 return false; 317 293 318 return m_connection->canAuthenticateAgainstProtectionSpaceResponseMap().waitForResponse(requestID); 319 } 320 321 void NetworkResourceLoader::canAuthenticateAgainstProtectionSpaceHandled(uint64_t requestID, bool canAuthenticate) 322 { 323 m_connection->canAuthenticateAgainstProtectionSpaceResponseMap().didReceiveResponse(requestID, canAuthenticate); 294 return result; 324 295 } 325 296 #endif … … 334 305 void NetworkResourceLoader::didReceiveDataArray(WebCore::ResourceHandle*, CFArrayRef) 335 306 { 307 ASSERT_NOT_REACHED(); 336 308 notImplemented(); 337 309 } -
trunk/Source/WebKit2/NetworkProcess/NetworkResourceLoader.h
r138319 r139516 111 111 NetworkResourceLoader(const NetworkResourceLoadParameters&, ResourceLoadIdentifier, NetworkConnectionToWebProcess*); 112 112 113 void willSendRequestHandled(uint64_t requestID, const WebCore::ResourceRequest&);114 void canAuthenticateAgainstProtectionSpaceHandled(uint64_t requestID, bool canAuthenticate);115 113 void receivedAuthenticationCredential(const WebCore::AuthenticationChallenge&, const WebCore::Credential&); 116 114 void receivedRequestToContinueWithoutAuthenticationCredential(const WebCore::AuthenticationChallenge&); -
trunk/Source/WebKit2/NetworkProcess/NetworkResourceLoader.messages.in
r135179 r139516 24 24 25 25 messages -> NetworkResourceLoader { 26 WillSendRequestHandled(uint64_t requestID, WebCore::ResourceRequest newRequest)27 CanAuthenticateAgainstProtectionSpaceHandled(uint64_t requestID, bool canAuthenticate)28 29 26 ReceivedAuthenticationCredential(WebCore::AuthenticationChallenge challenge, WebCore::Credential credential) 30 27 ReceivedRequestToContinueWithoutAuthenticationCredential(WebCore::AuthenticationChallenge challenge) -
trunk/Source/WebKit2/Shared/BlockingResponseMap.h
r137783 r139516 62 62 63 63 m_responses.set(requestID, response); 64 // FIXME (NetworkProcess): <rdar://problem/12886430>: Waking up all threads is quite inefficient.64 // FIXME: Waking up all threads is quite inefficient. 65 65 m_condition.broadcast(); 66 66 } … … 70 70 m_canceled = true; 71 71 72 // FIXME (NetworkProcess): <rdar://problem/12886430>: Waking up all threads is quite inefficient.72 // FIXME: Waking up all threads is quite inefficient. 73 73 m_condition.broadcast(); 74 74 } … … 82 82 }; 83 83 84 class BlockingBoolResponseMap {85 WTF_MAKE_NONCOPYABLE(BlockingBoolResponseMap);86 public:87 BlockingBoolResponseMap() : m_canceled(false) { }88 ~BlockingBoolResponseMap() { ASSERT(m_responses.isEmpty()); }89 90 bool waitForResponse(uint64_t requestID)91 {92 while (true) {93 MutexLocker locker(m_mutex);94 95 // FIXME: Differentiate between canceled wait and a negative response.96 if (m_canceled)97 return false;98 99 HashMap<uint64_t, bool>::iterator iter = m_responses.find(requestID);100 if (iter != m_responses.end()) {101 bool result = iter->value;102 m_responses.remove(iter);103 return result;104 }105 106 m_condition.wait(m_mutex);107 }108 109 return false;110 }111 112 void didReceiveResponse(uint64_t requestID, bool response)113 {114 MutexLocker locker(m_mutex);115 ASSERT(!m_responses.contains(requestID));116 117 m_responses.set(requestID, response);118 // FIXME (NetworkProcess): <rdar://problem/12886430>: Waking up all threads is quite inefficient.119 m_condition.broadcast();120 }121 122 void cancel()123 {124 m_canceled = true;125 126 // FIXME (NetworkProcess): <rdar://problem/12886430>: Waking up all threads is quite inefficient.127 m_condition.broadcast();128 }129 130 private:131 Mutex m_mutex;132 ThreadCondition m_condition;133 134 HashMap<uint64_t, bool> m_responses;135 bool m_canceled;136 };137 138 84 #endif // BlockingResponseMap_h -
trunk/Source/WebKit2/WebProcess/Network/NetworkProcessConnection.cpp
r138683 r139516 63 63 } 64 64 65 void NetworkProcessConnection::didReceiveSyncMessage(CoreIPC::Connection* connection, CoreIPC::MessageID messageID, CoreIPC::MessageDecoder& decoder, OwnPtr<CoreIPC::MessageEncoder>& replyEncoder) 66 { 67 if (messageID.is<CoreIPC::MessageClassWebResourceLoader>()) { 68 if (WebResourceLoader* webResourceLoader = WebProcess::shared().webResourceLoadScheduler().webResourceLoaderForIdentifier(decoder.destinationID())) 69 webResourceLoader->didReceiveSyncWebResourceLoaderMessage(connection, messageID, decoder, replyEncoder); 70 71 return; 72 } 73 74 ASSERT_NOT_REACHED(); 75 } 76 65 77 void NetworkProcessConnection::didClose(CoreIPC::Connection*) 66 78 { -
trunk/Source/WebKit2/WebProcess/Network/NetworkProcessConnection.h
r135179 r139516 62 62 // CoreIPC::Connection::Client 63 63 virtual void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::MessageDecoder&); 64 virtual void didReceiveSyncMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::MessageDecoder&, OwnPtr<CoreIPC::MessageEncoder>&); 64 65 virtual void didClose(CoreIPC::Connection*); 65 66 virtual void didReceiveInvalidMessage(CoreIPC::Connection*, CoreIPC::StringReference messageReceiverName, CoreIPC::StringReference messageName) OVERRIDE; -
trunk/Source/WebKit2/WebProcess/Network/WebResourceLoader.cpp
r138413 r139516 69 69 } 70 70 71 void WebResourceLoader::willSendRequest( uint64_t requestID, const ResourceRequest& proposedRequest, const ResourceResponse& redirectResponse)71 void WebResourceLoader::willSendRequest(const ResourceRequest& proposedRequest, const ResourceResponse& redirectResponse, ResourceRequest& newRequest) 72 72 { 73 73 LOG(Network, "(WebProcess) WebResourceLoader::willSendRequest to '%s'", proposedRequest.url().string().utf8().data()); 74 74 75 ResourceRequestnewRequest = proposedRequest;75 newRequest = proposedRequest; 76 76 m_coreLoader->willSendRequest(newRequest, redirectResponse); 77 78 send(Messages::NetworkResourceLoader::WillSendRequestHandled(requestID, newRequest));79 77 } 80 78 … … 123 121 } 124 122 125 void WebResourceLoader::canAuthenticateAgainstProtectionSpace( uint64_t requestID, const ProtectionSpace& protectionSpace)123 void WebResourceLoader::canAuthenticateAgainstProtectionSpace(const ProtectionSpace& protectionSpace, bool& result) 126 124 { 127 send(Messages::NetworkResourceLoader::CanAuthenticateAgainstProtectionSpaceHandled(requestID, m_coreLoader->canAuthenticateAgainstProtectionSpace(protectionSpace)));125 result = m_coreLoader->canAuthenticateAgainstProtectionSpace(protectionSpace); 128 126 } 129 127 -
trunk/Source/WebKit2/WebProcess/Network/WebResourceLoader.h
r138387 r139516 67 67 68 68 void didReceiveWebResourceLoaderMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::MessageDecoder&); 69 void didReceiveSyncWebResourceLoaderMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::MessageDecoder&, OwnPtr<CoreIPC::MessageEncoder>&); 69 70 70 71 using RefCounted<WebResourceLoader>::ref; … … 80 81 WebResourceLoader(PassRefPtr<WebCore::ResourceLoader>); 81 82 82 void willSendRequest( uint64_t requestID, const WebCore::ResourceRequest&, const WebCore::ResourceResponse& redirectResponse);83 void willSendRequest(const WebCore::ResourceRequest&, const WebCore::ResourceResponse& redirectResponse, WebCore::ResourceRequest& newRequest); 83 84 void didReceiveResponseWithCertificateInfo(const WebCore::ResourceResponse&, const PlatformCertificateInfo&); 84 85 void didReceiveData(const CoreIPC::DataReference&, int64_t encodedDataLength, bool allAtOnce); … … 87 88 void didReceiveResource(const ShareableResource::Handle&, double finishTime); 88 89 89 void canAuthenticateAgainstProtectionSpace( uint64_t requestID, const WebCore::ProtectionSpace&);90 void canAuthenticateAgainstProtectionSpace(const WebCore::ProtectionSpace&, bool& result); 90 91 void didReceiveAuthenticationChallenge(const WebCore::AuthenticationChallenge&); 91 92 void didCancelAuthenticationChallenge(const WebCore::AuthenticationChallenge&); -
trunk/Source/WebKit2/WebProcess/Network/WebResourceLoader.messages.in
r138206 r139516 24 24 25 25 // FIXME (NetworkProcess): We'll need much more granularity for response messages. 26 WillSendRequest( uint64_t requestID, WebCore::ResourceRequest request, WebCore::ResourceResponse redirectResponse)26 WillSendRequest(WebCore::ResourceRequest request, WebCore::ResourceResponse redirectResponse) -> (WebCore::ResourceRequest newRequest) 27 27 DidReceiveResponseWithCertificateInfo(WebCore::ResourceResponse response, WebKit::PlatformCertificateInfo certificateInfo) 28 28 DidReceiveData(CoreIPC::DataReference data, int64_t encodedDataLength, bool allAtOnce) … … 30 30 DidFailResourceLoad(WebCore::ResourceError error) 31 31 32 CanAuthenticateAgainstProtectionSpace( uint64_t requestID, WebCore::ProtectionSpace protectionSpace)32 CanAuthenticateAgainstProtectionSpace(WebCore::ProtectionSpace protectionSpace) -> (bool response) 33 33 DidReceiveAuthenticationChallenge(WebCore::AuthenticationChallenge challenge) 34 34 DidCancelAuthenticationChallenge(WebCore::AuthenticationChallenge challenge)
Note:
See TracChangeset
for help on using the changeset viewer.