RESOLVED FIXED Bug 57049
[Qt] QNetworkReplyHandler refactoring: signal sequence.
https://bugs.webkit.org/show_bug.cgi?id=57049
Summary [Qt] QNetworkReplyHandler refactoring: signal sequence.
Luiz Agostini
Reported 2011-03-24 13:28:44 PDT
This is the first step in QNetworkReplyHandler. The main objective here is to create simple invariants: 1 - that the signals metadatachanged, readyRead and finished will come in this order. 2 - that signals metadatachanged and finished will come for sure. Having these invariants further simplifications will be possible and will come in future patches.
Attachments
patch (21.63 KB, patch)
2011-03-24 13:46 PDT, Luiz Agostini
no flags
patch (21.92 KB, patch)
2011-03-29 11:54 PDT, Luiz Agostini
kenneth: review+
Luiz Agostini
Comment 1 2011-03-24 13:46:48 PDT
Kenneth Rohde Christiansen
Comment 2 2011-03-24 13:56:29 PDT
Kling, Jocelyn can you have a look at this?
Benjamin Poulain
Comment 3 2011-03-25 02:42:19 PDT
Could you give a bit of context? Which bugs is this fixing? About the new enforced invariants: 1 - that the signals metadatachanged, readyRead and finished will come in this order. 2 - that signals metadatachanged and finished will come for sure. In which case are they not met with the current code?
Luiz Agostini
Comment 4 2011-03-25 02:49:07 PDT
(In reply to comment #3) > Could you give a bit of context? Which bugs is this fixing? > > About the new enforced invariants: > 1 - that the signals metadatachanged, readyRead and finished will come in this order. > 2 - that signals metadatachanged and finished will come for sure. > > In which case are they not met with the current code? The current code expects the signals to come in any sequence. Slots forwardData() and finish() call sendResponseIfNeeded() and a flag named m_responseSent is kept to indicate if sendResponseIfNeeded() is been called for the second time. All those slots (forwardData, finish and sendResponseIfNeeded) are connected to a QNetworkReply object.
Luiz Agostini
Comment 5 2011-03-25 03:05:55 PDT
This is a refactoring that will make further changes. I tried to provide patches that are easy to understand each one alone. But the whole refactoring is much larger. Basically the strategy is to: 1 - create a wrapper that will enforce the invariants that I need and will be the place to add further logic as mime sniffing. (bug 57049) 2 - separate the 'deferred' logic from the actual content processing logic. (bug 57075) 3 - separate the logic for redirection from the logic for receive meta data. (bug 57083) 4 - cleanup. (bug 57092) 5 - create a separated class to be used in synchronous requests.
Jocelyn Turcotte
Comment 6 2011-03-28 07:37:17 PDT
Concerns: - I'm not sure why you need to disconnect and reconnect the reply at each signal received. This could have performance impacts, especially for readyRead. - In QNetworkReplyWrapper::receiveMetaData, each time you will receive readyRead from the reply, you will do the mime type dance and emit metadataChanged. Doing it once the first time should be enough. - The QNetworkReplyWrapper class name doesn't define much it's responsibility, though I can't find a better name myself so... This whole refactoring is awesome but it moves more tiny networking bug fixes than it may look. I think it would be better not to get this in QtWebKit 2.2 unless of course there is a clear gain and we put additional efforts to test this code.
Luiz Agostini
Comment 7 2011-03-28 12:26:14 PDT
(In reply to comment #6) > Concerns: > - I'm not sure why you need to disconnect and reconnect the reply at each signal received. This could have performance impacts, especially for readyRead. At construction time all signals from QNetworkReply are connected to receiveMetaData and they are disconnected as soon as the first one come. The slot receiveMetaData is not used form this point on. If needed, the signals from QNetworkReply will be connected to other slots. Specifically, readyRead signal form QNetworkReply will only trigger QNetworkReplyWrapper's own readyRead signal. 214 connect(m_reply, SIGNAL(readyRead()), this, SIGNAL(readyRead())); 215 connect(m_reply, SIGNAL(finished()), this, SLOT(receiveFinished())); > - In QNetworkReplyWrapper::receiveMetaData, each time you will receive readyRead from the reply, you will do the mime type dance and emit metadataChanged. Doing it once the first time should be enough. The slot receiveMetaData is only be used to receive the first signal from QNetwrokReply. Signal metadataChanged is emitted only once. The mime type dance will only happen exactly once. > - The QNetworkReplyWrapper class name doesn't define much it's responsibility, though I can't find a better name myself so... > > This whole refactoring is awesome but it moves more tiny networking bug fixes than it may look. I think it would be better not to get this in QtWebKit 2.2 unless of course there is a clear gain and we put additional efforts to test this code. Ok, the whole refactoring may be too much for this time but this first patch was designed to be clearly sane and to prepare the way to mime sniffing integration. Please then consider integrating this patch alone for this first time.
Jocelyn Turcotte
Comment 8 2011-03-29 05:31:42 PDT
(In reply to comment #7) > At construction time all signals from QNetworkReply are connected to receiveMetaData and they are disconnected as soon as the first one come. The slot receiveMetaData is not used form this point on. If needed, the signals from QNetworkReply will be connected to other slots. Specifically, readyRead signal form QNetworkReply will only trigger QNetworkReplyWrapper's own readyRead signal. > > 214 connect(m_reply, SIGNAL(readyRead()), this, SIGNAL(readyRead())); > 215 connect(m_reply, SIGNAL(finished()), this, SLOT(receiveFinished())); > > > - In QNetworkReplyWrapper::receiveMetaData, each time you will receive readyRead from the reply, you will do the mime type dance and emit metadataChanged. Doing it once the first time should be enough. > > The slot receiveMetaData is only be used to receive the first signal from QNetwrokReply. Signal metadataChanged is emitted only once. The mime type dance will only happen exactly once. Ahh, I missed that part, it makes more sense. Please add a comment somewhere to highlight this. > > Ok, the whole refactoring may be too much for this time but this first patch was designed to be clearly sane and to prepare the way to mime sniffing integration. Please then consider integrating this patch alone for this first time. I have nothing against having it in trunk, as long as we are aware of the risk. In worst conditions we can revert it in the future branch.
Luiz Agostini
Comment 9 2011-03-29 11:54:07 PDT
Created attachment 87382 [details] patch adding the comments requested by Jocelyn.
Kenneth Rohde Christiansen
Comment 10 2011-03-29 14:29:23 PDT
Comment on attachment 87382 [details] patch View in context: https://bugs.webkit.org/attachment.cgi?id=87382&action=review This is pretty readable and understandable > Source/WebCore/ChangeLog:11 > + 2 - that signals metadatachanged and finished will will be called exactly once. two will's there > Source/WebCore/platform/network/qt/QNetworkReplyHandler.cpp:176 > + disconnect(reply, 0, this, 0); Isn't there a disconnectAll or so? > Source/WebCore/platform/network/qt/QNetworkReplyHandler.cpp:189 > + // this slot is only used to receive the first signal from the QNetworkReply object. comments should start with capital - basically they should be real sentences > Source/WebCore/platform/network/qt/QNetworkReplyHandler.cpp:207 > + // if not finished, connect to the slots that will be used from this point on. same here > Source/WebCore/platform/network/qt/QNetworkReplyHandler.cpp:209 > + connect(m_reply, SIGNAL(finished()), this, SLOT(receiveFinished())); receive_d_Finished? more webkit like, didReceiveFinished > Source/WebCore/platform/network/qt/QNetworkReplyHandler.cpp:226 > + // disconnecting will make sure that nothing will happen after emiting finished signal. Disco...* after emitting (two t's) THE finished signal > Source/WebCore/platform/network/qt/QNetworkReplyHandler.h:48 > + QUrl redirectUrl() const { return m_redirectUrl; } I think redirectionUrl would be more correct. or redirectionTargetUrl() > Source/WebCore/platform/network/qt/QNetworkReplyHandler.h:50 > + QString officialMimeType() const { return m_officialMimeType; } I don't like the official part of the name? maybe "advertisedMimeType"?
Kenneth Rohde Christiansen
Comment 11 2011-03-29 14:33:56 PDT
Have you tried measuring the performance impact of this change? I think it might be a good think to do, even though we think it won't affect it.
Luiz Agostini
Comment 12 2011-03-30 11:44:03 PDT
(In reply to comment #11) > Have you tried measuring the performance impact of this change? I think it might be a good think to do, even though we think it won't affect it. I have made some only simple tests with QtTestBrowser in robot mode using a master build as reference. I did not see any differences.
WebKit Review Bot
Comment 13 2011-03-30 12:26:15 PDT
http://trac.webkit.org/changeset/82478 might have broken Leopard Intel Release (Tests) The following tests are not passing: canvas/philip/tests/2d.text.draw.align.center.html fast/blockflow/broken-ideographic-font.html
Luiz Agostini
Comment 14 2011-03-30 16:41:00 PDT
M Source/WebCore/ChangeLog M Source/WebCore/platform/network/qt/QNetworkReplyHandler.cpp M Source/WebCore/platform/network/qt/QNetworkReplyHandler.h Committed r82478
Note You need to log in before you can comment on or make changes to this bug.