Changeset 83695 in webkit
- Timestamp:
- Apr 12, 2011 9:30:11 PM (13 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r83694 r83695 1 2011-04-12 Luiz Agostini <luiz.agostini@openbossa.org> 2 3 Reviewed by Andreas Kling. 4 5 [Qt] QNetworkReplyHandler refactoring: remove nested event loop. 6 https://bugs.webkit.org/show_bug.cgi?id=58375 7 8 As QNAM now makes actual synchronous loads there is no need for a nested event loop 9 in ResourceHandleQt. 10 11 Moving the call for QNetworkReplyWrapper::synchronousLoad from 12 ResourceHandle::loadResourceSynchronously to QNetworkReplyHandler::start for the 13 redirections to work in synchronous requests. 14 15 * platform/network/qt/QNetworkReplyHandler.cpp: 16 (WebCore::QNetworkReplyHandler::start): 17 * platform/network/qt/QNetworkReplyHandler.h: 18 * platform/network/qt/ResourceHandleQt.cpp: 19 (WebCore::WebCoreSynchronousLoader::WebCoreSynchronousLoader): 20 (WebCore::WebCoreSynchronousLoader::didReceiveResponse): 21 (WebCore::WebCoreSynchronousLoader::didReceiveData): 22 (WebCore::WebCoreSynchronousLoader::didFinishLoading): 23 (WebCore::WebCoreSynchronousLoader::didFail): 24 (WebCore::ResourceHandle::loadResourceSynchronously): 25 1 26 2011-04-12 Vangelis Kokkevis <vangelis@chromium.org> 2 27 -
trunk/Source/WebCore/platform/network/qt/QNetworkReplyHandler.cpp
r83691 r83695 631 631 632 632 if (m_loadType == SynchronousLoad && m_replyWrapper->reply()->isFinished()) { 633 m_replyWrapper->synchronousLoad(); 633 634 // If supported, a synchronous request will be finished at this point, no need to hook up the signals. 634 635 return; … … 639 640 } 640 641 641 void QNetworkReplyHandler::synchronousLoad()642 {643 if (m_replyWrapper)644 m_replyWrapper->synchronousLoad();645 }646 647 642 } 648 643 -
trunk/Source/WebCore/platform/network/qt/QNetworkReplyHandler.h
r83691 r83695 110 110 QNetworkReply* release(); 111 111 112 void synchronousLoad();113 114 112 public slots: 115 113 void finish(); -
trunk/Source/WebCore/platform/network/qt/ResourceHandleQt.cpp
r83691 r83695 54 54 class WebCoreSynchronousLoader : public ResourceHandleClient { 55 55 public: 56 WebCoreSynchronousLoader(); 56 WebCoreSynchronousLoader(ResourceError& error, ResourceResponse& response, Vector<char>& data) 57 : m_error(error) 58 , m_response(response) 59 , m_data(data) 60 {} 57 61 58 void waitForCompletion(); 59 60 virtual void didReceiveResponse(ResourceHandle*, const ResourceResponse&); 61 virtual void didReceiveData(ResourceHandle*, const char*, int, int lengthReceived); 62 virtual void didFinishLoading(ResourceHandle*, double /*finishTime*/); 63 virtual void didFail(ResourceHandle*, const ResourceError&); 64 65 ResourceResponse resourceResponse() const { return m_response; } 66 ResourceError resourceError() const { return m_error; } 67 Vector<char> data() const { return m_data; } 68 69 void setReplyFinished(bool finished) { m_replyFinished = finished; } 70 62 virtual void didReceiveResponse(ResourceHandle*, const ResourceResponse& response) { m_response = response; } 63 virtual void didReceiveData(ResourceHandle*, const char* data, int length, int) { m_data.append(data, length); } 64 virtual void didFinishLoading(ResourceHandle*, double /*finishTime*/) {} 65 virtual void didFail(ResourceHandle*, const ResourceError& error) { m_error = error; } 71 66 private: 72 ResourceResponse m_response; 73 ResourceError m_error; 74 Vector<char> m_data; 75 QEventLoop m_eventLoop; 76 bool m_replyFinished; 67 ResourceError& m_error; 68 ResourceResponse& m_response; 69 Vector<char>& m_data; 77 70 }; 78 79 WebCoreSynchronousLoader::WebCoreSynchronousLoader()80 : m_replyFinished(false)81 {82 }83 84 void WebCoreSynchronousLoader::didReceiveResponse(ResourceHandle*, const ResourceResponse& response)85 {86 m_response = response;87 }88 89 void WebCoreSynchronousLoader::didReceiveData(ResourceHandle*, const char* data, int length, int)90 {91 m_data.append(data, length);92 }93 94 void WebCoreSynchronousLoader::didFinishLoading(ResourceHandle*, double)95 {96 if (!m_replyFinished)97 m_eventLoop.exit();98 }99 100 void WebCoreSynchronousLoader::didFail(ResourceHandle*, const ResourceError& error)101 {102 m_error = error;103 if (!m_replyFinished)104 m_eventLoop.exit();105 }106 107 void WebCoreSynchronousLoader::waitForCompletion()108 {109 m_eventLoop.exec(QEventLoop::ExcludeUserInputEvents);110 }111 71 112 72 ResourceHandleInternal::~ResourceHandleInternal() … … 192 152 void ResourceHandle::loadResourceSynchronously(NetworkingContext* context, const ResourceRequest& request, StoredCredentials /*storedCredentials*/, ResourceError& error, ResourceResponse& response, Vector<char>& data) 193 153 { 194 WebCoreSynchronousLoader syncLoader ;154 WebCoreSynchronousLoader syncLoader(error, response, data); 195 155 RefPtr<ResourceHandle> handle = adoptRef(new ResourceHandle(request, &syncLoader, true, false)); 196 156 … … 205 165 } 206 166 d->m_context = context; 207 d->m_job = new QNetworkReplyHandler(handle.get(), QNetworkReplyHandler::SynchronousLoad);208 167 209 QNetworkReply* reply = d->m_job->reply(); 210 // When using synchronous calls, we are finished when reaching this point. 211 if (reply->isFinished()) { 212 syncLoader.setReplyFinished(true); 213 d->m_job->synchronousLoad(); 214 } else 215 syncLoader.waitForCompletion(); 216 217 error = syncLoader.resourceError(); 218 data = syncLoader.data(); 219 response = syncLoader.resourceResponse(); 168 // starting in deferred mode gives d->m_job the chance of being set before sending the request. 169 d->m_job = new QNetworkReplyHandler(handle.get(), QNetworkReplyHandler::SynchronousLoad, true); 170 d->m_job->setLoadingDeferred(false); 220 171 } 221 172
Note: See TracChangeset
for help on using the changeset viewer.