RESOLVED FIXED Bug 59070
[Qt] Fix QNetworkReplyWrapper to not depend on QNetworkReply::isFinished() method
https://bugs.webkit.org/show_bug.cgi?id=59070
Summary [Qt] Fix QNetworkReplyWrapper to not depend on QNetworkReply::isFinished() me...
Caio Marcelo de Oliveira Filho
Reported 2011-04-20 20:49:06 PDT
[Qt] Fix QNetworkReplyWrapper to not depend on QNetworkReply::isFinished() method
Attachments
Patch (9.29 KB, patch)
2011-04-20 21:03 PDT, Caio Marcelo de Oliveira Filho
no flags
patch v2, rebased (11.19 KB, patch)
2011-04-20 21:55 PDT, Caio Marcelo de Oliveira Filho
kling: review+
patch v3, using dynamic property (10.83 KB, patch)
2011-04-28 17:30 PDT, Caio Marcelo de Oliveira Filho
luiz: review-
patch v4, use fact that synchronous loads are always finished (9.93 KB, patch)
2011-05-02 14:54 PDT, Caio Marcelo de Oliveira Filho
no flags
patch v4 (second take), use the fact that synchronous loads are always finished (9.93 KB, patch)
2011-05-02 15:00 PDT, Caio Marcelo de Oliveira Filho
kling: review+
patch v5, better comment (9.94 KB, patch)
2011-05-02 17:15 PDT, Caio Marcelo de Oliveira Filho
kling: review+
eric: commit-queue-
Caio Marcelo de Oliveira Filho
Comment 1 2011-04-20 21:03:25 PDT
Caio Marcelo de Oliveira Filho
Comment 2 2011-04-20 21:07:00 PDT
Luiz, could you take a look at this? I've decided to make receiveMetaDataWhenFinished() to avoid depending on the order of the connections.
Caio Marcelo de Oliveira Filho
Comment 3 2011-04-20 21:55:05 PDT
Created attachment 90491 [details] patch v2, rebased
Andreas Kling
Comment 4 2011-04-26 16:52:33 PDT
Comment on attachment 90491 [details] patch v2, rebased r=me. Sucky, but unavoidable.
Luiz Agostini
Comment 5 2011-04-27 21:07:46 PDT
I don't like it that much. It is too complex. A crazy idea: why don't we take advantage of the fact that QNetworkReply is a QObject and store a dynamic property on it to keep the flag that we need? I think that if we just create a slot in QNRW that sets that dynamic property on QNR and connect it in QNRW constructor it is done (take care to never disconnect it). The flag will be in the QNR object only (as it should) and we can avoid all other connections, parameters, flags that are replicated in two classes, ... I don't think that it is a problem to trust on the signal emission sequence because it is a well known feature of Qt that is well documented. Anyway, I think that with the proposed patch we might have problems with synchronous requests. Are layout tests ok?
Caio Marcelo de Oliveira Filho
Comment 6 2011-04-28 05:30:59 PDT
Luiz, thanks for looking into this :-) (In reply to comment #5) > I don't like it that much. It is too complex. > > A crazy idea: why don't we take advantage of the fact that QNetworkReply is a QObject and store a dynamic property on it to keep the flag that we need? > I think that if we just create a slot in QNRW that sets that dynamic property on QNR and connect it in QNRW constructor it is done (take care to never disconnect it). The flag will be in the QNR object only (as it should) and we can avoid all other connections, parameters, flags that are replicated in two classes, ... I see your point. I will try to implement this idea today and we can see how it goes. :-) > I don't think that it is a problem to trust on the signal emission sequence because it is a well known feature of Qt that is well documented. OK. I do trust the sequence, I was avoiding depend on the connect lines having to respect a strict order, but I guess a comment would be enough. > Anyway, I think that with the proposed patch we might have problems with synchronous requests. Are layout tests ok? What kind of problems? Both wrapper and sniffer are per-reply, so one reply will not affect others. In practice, this shouldn't change anything for non-fake replies -- which is the case for layout tests. How can I test the synchronous requests? Do we have autotests for that or only in layout tests?
Caio Marcelo de Oliveira Filho
Comment 7 2011-04-28 16:10:37 PDT
The dynamic approach indeed looks better and avoids complicating the logic. > > Anyway, I think that with the proposed patch we might have problems with synchronous requests. Are layout tests ok? > > What kind of problems? Both wrapper and sniffer are per-reply, so one reply will not affect others. In practice, this shouldn't change anything for non-fake replies -- which is the case for layout tests. Ok. I've found the problems, manually tracking the finished works only if we can catch the signal. That's where the fake replies heuristic of emitting finished() after a 0-timer come from, they need to give time for the :-) What I plan to do is to make our isFinished check both the dynamic property AND the m_reply property. This way we catch asynchronous and synchronous loads for Qt network replies, and also asynchronous loads for fake network replies. If I understand correct, until Qt 4.8 (where we can set finished) we can't really have autotests for synchronous load with custom replies. Makes sense? > How can I test the synchronous requests? Do we have autotests for that or only in layout tests? I've found LayoutTests/http. Are there others?
Caio Marcelo de Oliveira Filho
Comment 8 2011-04-28 16:25:03 PDT
(In reply to comment #7) > Ok. I've found the problems, manually tracking the finished works only if we can catch the signal. That's where the fake replies heuristic of emitting finished() after a 0-timer come from, they need to give time for the :-) ...give time for the signal connections. :-)
Caio Marcelo de Oliveira Filho
Comment 9 2011-04-28 17:30:32 PDT
Created attachment 91603 [details] patch v3, using dynamic property
Luiz Agostini
Comment 10 2011-04-29 16:03:32 PDT
Comment on attachment 91603 [details] patch v3, using dynamic property View in context: https://bugs.webkit.org/attachment.cgi?id=91603&action=review > Source/WebCore/platform/network/qt/QNetworkReplyHandler.cpp:663 > - if (m_loadType == SynchronousLoad && m_replyWrapper->reply()->isFinished()) { > + if (m_loadType == SynchronousLoad && m_replyWrapper->isFinished()) { > m_replyWrapper->synchronousLoad(); > // If supported, a synchronous request will be finished at this point, no need to hook up the signals. > return; For synchronous requests we should call m_replyWrapper->synchronousLoad() and return anyway. My suggestion now is that we do not check for isFinished at this point and that we call QNetworkReplyWrapper::setFinished() from QNetworkReplyWrapper::synchronousLoad(). Then we may avoid using QNetworkReply::isFinished() completely. > Source/WebCore/platform/network/qt/QNetworkReplyHandler.h:84 > + bool isFinished() const { return m_reply->isFinished() || m_reply->property("_q_isFinished").toBool(); } How can we trust on QNetworkReply::isFinished()? We should have a solution that does not rely on it. > Source/WebCore/platform/network/qt/QtMIMETypeSniffer.h:44 > + bool isReplyFinished() const { return m_reply->isFinished() || m_reply->property("_q_isFinished").toBool(); } The same here.
Caio Marcelo de Oliveira Filho
Comment 11 2011-05-02 14:54:33 PDT
Created attachment 91986 [details] patch v4, use fact that synchronous loads are always finished
WebKit Review Bot
Comment 12 2011-05-02 14:56:36 PDT
Attachment 91986 [details] did not pass style-queue: Failed to run "['Tools/Scripts/check-webkit-style', '--diff-files', u'Source/WebCore/ChangeLog', u'Source/WebCor..." exit_code: 1 Source/WebCore/platform/network/qt/QNetworkReplyHandler.h:26: Alphabetical sorting problem. [build/include_order] [4] Total errors found: 1 in 4 files If any of these errors are false positives, please file a bug against check-webkit-style.
Caio Marcelo de Oliveira Filho
Comment 13 2011-05-02 15:00:27 PDT
Created attachment 91988 [details] patch v4 (second take), use the fact that synchronous loads are always finished
Luiz Agostini
Comment 14 2011-05-02 15:34:54 PDT
Comment on attachment 91988 [details] patch v4 (second take), use the fact that synchronous loads are always finished LGTM
Andreas Kling
Comment 15 2011-05-02 16:09:14 PDT
Comment on attachment 91988 [details] patch v4 (second take), use the fact that synchronous loads are always finished View in context: https://bugs.webkit.org/attachment.cgi?id=91988&action=review > Source/WebCore/platform/network/qt/QNetworkReplyHandler.cpp:311 > + // QNetworkReply, the QNetworkReply::isFinished() is never true, so we need to keep track s/the// > Source/WebCore/platform/network/qt/QNetworkReplyHandler.cpp:312 > + // ourselves. This limitation is fixed in 4.8, but we'll still have applications that doesn't s/doesn't/don't/
Caio Marcelo de Oliveira Filho
Comment 16 2011-05-02 17:15:29 PDT
Created attachment 92013 [details] patch v5, better comment
Eric Seidel (no email)
Comment 17 2011-05-04 05:09:51 PDT
Comment on attachment 92013 [details] patch v5, better comment Rejecting attachment 92013 [details] from commit-queue. cmarcelo@webkit.org does not have committer permissions according to http://trac.webkit.org/browser/trunk/Tools/Scripts/webkitpy/common/config/committers.py. - If you do not have committer rights please read http://webkit.org/coding/contributing.html for instructions on how to use bugzilla flags. - If you have committer rights please correct the error in Tools/Scripts/webkitpy/common/config/committers.py by adding yourself to the file (no review needed). The commit-queue restarts itself every 2 hours. After restart the commit-queue will correctly respect your committer rights.
Caio Marcelo de Oliveira Filho
Comment 18 2011-05-04 05:34:02 PDT
Note You need to log in before you can comment on or make changes to this bug.