RESOLVED FIXED Bug 54313
Need didReceiveCachedMetadata, and finishTime for didFinishLoading exposed in ThreadableLoaderClient.
https://bugs.webkit.org/show_bug.cgi?id=54313
Summary Need didReceiveCachedMetadata, and finishTime for didFinishLoading exposed in...
Bill Budge
Reported 2011-02-11 14:14:05 PST
Needs a public setDefersLoading(bool value) method to allow clients to implement WebURLLoader using this class. Need a protected override to the inherited SubresourceLoaderClient::didReceiveCachedMetada method to allow derived classes to invoke the assertion logic when overriding. Grouping these 2 changes into one issue to expedite the upcoming patch.
Attachments
Proposed patch (2.31 KB, patch)
2011-02-11 14:16 PST, Bill Budge
no flags
Proposed patch (3.75 KB, patch)
2011-02-11 14:23 PST, Bill Budge
levin: review-
Proposed Patch (4.63 KB, patch)
2011-02-15 10:02 PST, Bill Budge
levin: review-
Proposed Patch (4.74 KB, patch)
2011-02-15 14:04 PST, Bill Budge
levin: review-
Proposed Patch (17.33 KB, patch)
2011-02-15 17:30 PST, Bill Budge
levin: review-
Proposed Patch (16.66 KB, patch)
2011-02-15 18:08 PST, Bill Budge
no flags
Proposed Patch (16.66 KB, patch)
2011-02-15 18:09 PST, Bill Budge
levin: review-
Proposed Patch (16.92 KB, patch)
2011-02-15 20:52 PST, Bill Budge
levin: review-
commit-queue: commit-queue-
Proposed Patch (16.97 KB, patch)
2011-02-16 07:31 PST, Bill Budge
levin: review-
Proposed Patch (18.40 KB, patch)
2011-02-16 17:01 PST, Bill Budge
levin: review-
Proposed Patch (18.38 KB, patch)
2011-02-16 17:22 PST, Bill Budge
no flags
Bill Budge
Comment 1 2011-02-11 14:16:27 PST
Created attachment 82174 [details] Proposed patch
David Levin
Comment 2 2011-02-11 14:18:39 PST
Comment on attachment 82174 [details] Proposed patch Wrong patch.
Bill Budge
Comment 3 2011-02-11 14:19:42 PST
Comment on attachment 82174 [details] Proposed patch I need to fix the patch.
David Levin
Comment 4 2011-02-11 14:21:24 PST
You may want to try using "webkit-patch upload" at some point (and consider setting the commit-queue flag to ? to indicate that you want your patch to be committed automatically).
Bill Budge
Comment 5 2011-02-11 14:23:00 PST
Created attachment 82178 [details] Proposed patch
Bill Budge
Comment 6 2011-02-11 14:27:49 PST
Comment on attachment 82178 [details] Proposed patch This change also involves making the SubresourceLoaderClient callbacks protected, rather than private, and the addition of an isActive() method, which is needed to implement the static 'create' method in derived classes.
Bill Budge
Comment 7 2011-02-11 14:28:23 PST
I definitely need to improve my workflow here David. Thanks for bearing with me.
David Levin
Comment 8 2011-02-11 14:33:32 PST
Comment on attachment 82178 [details] Proposed patch View in context: https://bugs.webkit.org/attachment.cgi?id=82178&action=review > Source/WebCore/ChangeLog:12 > + (WebCore::DocumentThreadableLoader::didReceiveCachedMetadata): A comment here would say: Make this method as protected instead of private. I wonder why we just don't change the inheritance of SubresourceLoaderClient to be protected instead of private. > Source/WebCore/ChangeLog:16 > +2011-02-11 Bill Budge <bbudge@chromium.org> This shouldn't be here. > Source/WebCore/loader/DocumentThreadableLoader.h:58 > + virtual void setDefersLoading(bool value); No need for "value" here. (It adds no information.)
Bill Budge
Comment 9 2011-02-11 14:43:05 PST
I will try your idea of using protected inheritance. I won't be able to work on this until next Monday fyi. Thanks!
Bill Budge
Comment 10 2011-02-15 10:02:05 PST
Created attachment 82479 [details] Proposed Patch
David Levin
Comment 11 2011-02-15 11:10:58 PST
Comment on attachment 82479 [details] Proposed Patch View in context: https://bugs.webkit.org/attachment.cgi?id=82479&action=review r- to remove unnecessary overload. (If it is needed, give some short explanation and I'll r+.) > Source/WebCore/loader/DocumentThreadableLoader.cpp:240 > +void DocumentThreadableLoader::didReceiveCachedMetadata(SubresourceLoader* loader, const char* data, int lengthReceived) Ditto (with my comment below). > Source/WebCore/loader/DocumentThreadableLoader.h:80 > + virtual void didReceiveCachedMetadata(SubresourceLoader*, const char*, int lengthReceived); Do you need this overload? (I though it was only here because SubresourceLoaderClient was private but that is no longer true.)
Bill Budge
Comment 12 2011-02-15 12:25:03 PST
Comment on attachment 82479 [details] Proposed Patch View in context: https://bugs.webkit.org/attachment.cgi?id=82479&action=review >> Source/WebCore/loader/DocumentThreadableLoader.cpp:240 >> +void DocumentThreadableLoader::didReceiveCachedMetadata(SubresourceLoader* loader, const char* data, int lengthReceived) > > Ditto (with my comment below). See my response, below. >> Source/WebCore/loader/DocumentThreadableLoader.h:80 >> + virtual void didReceiveCachedMetadata(SubresourceLoader*, const char*, int lengthReceived); > > Do you need this overload? (I though it was only here because SubresourceLoaderClient was private but that is no longer true.) I added it so that we could include the assertion logic of the other methods, which verify that it's not called improperly. The method doesn't do anything, but can then be called by any derived classes. In case we ever want to put some logic into this method in DocumentThreadableLoader, we wouldn't have to go change all the derived classes. But I will defer to you on this; if you feel it's better to leave it unimplemented, I will remove it.
Bill Budge
Comment 13 2011-02-15 12:27:09 PST
Another question: In didReceiveData, we check if it's a preflight request, why don't we do the same test for didReceiveCachedMetadata?
Bill Budge
Comment 14 2011-02-15 12:28:01 PST
Let me rephrase that: Do I need to worry about that before calling the client in a derived implementation of didReceiveCachedMetadata?
David Levin
Comment 15 2011-02-15 12:50:30 PST
(In reply to comment #14) > Let me rephrase that: Do I need to worry about that before calling the client in a derived implementation of didReceiveCachedMetadata? Good point! I would. When a request is done that is cross origin, it may trigger a preflight request which is a request to get info from the site to see if the cross origin request is allowed. This preflight request is a basically protocol detail that shouldn't be exposed to the clients so it is nice to check to see if this is happening and not forward along the info to the client. (In reply to comment #12) > (From update of attachment 82479 [details]) > View in context: https://bugs.webkit.org/attachment.cgi?id=82479&action=review > > >> Source/WebCore/loader/DocumentThreadableLoader.h:80 > >> + virtual void didReceiveCachedMetadata(SubresourceLoader*, const char*, int lengthReceived); > > > > Do you need this overload? (I though it was only here because SubresourceLoaderClient was private but that is no longer true.) > > I added it so that we could include the assertion logic of the other methods, which verify that it's not called improperly. Good point. Feel free to leave it.
Bill Budge
Comment 16 2011-02-15 14:04:28 PST
Created attachment 82518 [details] Proposed Patch I added a protected isPreflight() method, so derived classes can filter out events related to the preflight request.
David Levin
Comment 17 2011-02-15 14:31:27 PST
Now I finally get to higher level questions (for which I'm sorry... it took my mind a while to get there.) Why are we doing derivation as opposed to just using the client interface (DocumentThreadableLoaderClient)? I'm concerned about the derivation being fragile (and the client interface seems to support everything you need -- well, you'll need to add in didReceiveCacheMetadata and expose the finishTime to one api, but that seems ok). Also this will hide the preflight request from your callbacks which seems desirable.
Bill Budge
Comment 18 2011-02-15 14:36:56 PST
So you raise an excellent point. If I could modify ThreadableLoaderClient, I could probably do without all of the API changes to DocumentThreadableLoader. I've been operating on the assumption that we shouldn't change interfaces, but if this isn't the case, modifying ThreadableLoaderClient is the way to go. Can I?
David Levin
Comment 19 2011-02-15 14:42:56 PST
(In reply to comment #18) > So you raise an excellent point. If I could modify ThreadableLoaderClient, I could probably do without all of the API changes to DocumentThreadableLoader. I've been operating on the assumption that we shouldn't change interfaces, but if this isn't the case, modifying ThreadableLoaderClient is the way to go. Can I? Yes, sorry for not mentioning/noticing this sooner. These interfaces are only used within WebKit (not some external api) so they aren't set in stone. It just happens that there is more than one implementation. Just make sure to fix up those implementations: http://www.google.com/codesearch?as_q=ThreadableLoaderClient&btnG=Search+Code&hl=en&vert=chromium&filesuggest=&as_lang=&as_filename=&as_class=&as_function=&as_case=
David Levin
Comment 20 2011-02-15 14:43:20 PST
Comment on attachment 82518 [details] Proposed Patch r- per discussion in bug.
Bill Budge
Comment 21 2011-02-15 15:46:19 PST
I will be adding didReceiveCachedMetadata and didDownloadData methods, and modify the signature of didFinishLoading. I'm unclear about how clients want to handle didReceiveCachedMetadata - for example EventSource has the following code: append(m_receiveBuf, m_decoder->decode(data, length)); parseEventStream(); What should happen in the didReceiveCachedMetadata method?
David Levin
Comment 22 2011-02-15 15:52:43 PST
(In reply to comment #21) > I will be adding didReceiveCachedMetadata and didDownloadData methods, and modify the signature of didFinishLoading. I'm unclear about how clients want to handle didReceiveCachedMetadata - for example EventSource has the following code: > > > append(m_receiveBuf, m_decoder->decode(data, length)); > parseEventStream(); > > What should happen in the didReceiveCachedMetadata method? Why should they implement it at all? (Just modify the appropriate signatures but don't add the new method. They don't care about this information now so let them continue not to care about it.)
Bill Budge
Comment 23 2011-02-15 16:11:11 PST
That makes sense. How about didDownloadData? Couldn't this be implemented at the top level, by AssociatedURLLoader, which could check for this case on didFinishLoading?
David Levin
Comment 24 2011-02-15 16:26:20 PST
(In reply to comment #23) > That makes sense. How about didDownloadData? Couldn't this be implemented at the top level, by AssociatedURLLoader, which could check for this case on didFinishLoading? I see that method here: http://www.google.com/codesearch/p?hl=en#OAMlx_jo-ck/src/third_party/WebKit/Source/WebKit/chromium/public/WebURLLoaderClient.h&q=WebURLLoaderClient&exact_package=chromium but I didn't understand when that method is called. (I suspect that you can get all the information you need from ThreadableLoaderClient to call this at the right time but since I don't know the contract for the method, it is only a guess.)
Bill Budge
Comment 25 2011-02-15 17:30:24 PST
Created attachment 82553 [details] Proposed Patch Changed the name of the bug to reflect the fact that ThreadableLoaderClient is being changed. The patch also adds setDefersLoading(bool value) to DocumentThreadableLoader. That could be a separate patch, but doesn't simplify things much.
David Levin
Comment 26 2011-02-15 17:44:49 PST
Comment on attachment 82553 [details] Proposed Patch View in context: https://bugs.webkit.org/attachment.cgi?id=82553&action=review Just a few things to clean up. > Source/WebCore/loader/DocumentThreadableLoader.cpp:243 > + ASSERT_UNUSED(loader, loader == m_loader); I think this is missing the following: if (!m_actualRequest) m_client->didReceiveCachedMetadata(data, lengthReceived) > Source/WebCore/loader/DocumentThreadableLoader.h:49 > + class DocumentThreadableLoader : public RefCounted<DocumentThreadableLoader>, public ThreadableLoader, protected SubresourceLoaderClient { "protected SubresourceLoaderClient" should be "private SubresourceLoaderClient" again. > Source/WebCore/loader/DocumentThreadableLoader.h:57 > + virtual void setDefersLoading(bool); I suspect that you'll need to make this method public. > Source/WebCore/loader/DocumentThreadableLoader.h:78 > + virtual void didDownloadData(SubresourceLoader*, int dataLength); This isn't implemented in DocumentThreadableLoader.cpp (and I doubt that it should be here). > Source/WebCore/xml/XMLHttpRequest.cpp:990 > +void XMLHttpRequest::didFinishLoading(unsigned long identifier, double finishTime) This will likely result in a compile error since "finishTime" isn't used in this function (just omit the parameter name).
WebKit Review Bot
Comment 27 2011-02-15 17:47:32 PST
Bill Budge
Comment 28 2011-02-15 18:07:48 PST
Comment on attachment 82553 [details] Proposed Patch View in context: https://bugs.webkit.org/attachment.cgi?id=82553&action=review >> Source/WebCore/loader/DocumentThreadableLoader.cpp:243 >> + ASSERT_UNUSED(loader, loader == m_loader); > > I think this is missing the following: > > if (!m_actualRequest) > m_client->didReceiveCachedMetadata(data, lengthReceived) Good catch! >> Source/WebCore/loader/DocumentThreadableLoader.h:49 >> + class DocumentThreadableLoader : public RefCounted<DocumentThreadableLoader>, public ThreadableLoader, protected SubresourceLoaderClient { > > "protected SubresourceLoaderClient" should be "private SubresourceLoaderClient" again. Done. >> Source/WebCore/loader/DocumentThreadableLoader.h:57 >> + virtual void setDefersLoading(bool); > > I suspect that you'll need to make this method public. It is. >> Source/WebCore/loader/DocumentThreadableLoader.h:78 >> + virtual void didDownloadData(SubresourceLoader*, int dataLength); > > This isn't implemented in DocumentThreadableLoader.cpp (and I doubt that it should be here). Right, and it breaks the build on Linux.
Bill Budge
Comment 29 2011-02-15 18:08:43 PST
Created attachment 82567 [details] Proposed Patch
Bill Budge
Comment 30 2011-02-15 18:09:30 PST
Created attachment 82568 [details] Proposed Patch
Build Bot
Comment 31 2011-02-15 18:16:07 PST
Early Warning System Bot
Comment 32 2011-02-15 18:20:50 PST
David Levin
Comment 33 2011-02-15 19:11:57 PST
Comment on attachment 82568 [details] Proposed Patch View in context: https://bugs.webkit.org/attachment.cgi?id=82568&action=review > Source/WebCore/xml/XMLHttpRequest.cpp:990 > +void XMLHttpRequest::didFinishLoading(unsigned long identifier, double finishTime) This will likely result in a compile error since "finishTime" isn't used in this function (just omit the parameter name).
Bill Budge
Comment 34 2011-02-15 20:51:58 PST
Comment on attachment 82568 [details] Proposed Patch View in context: https://bugs.webkit.org/attachment.cgi?id=82568&action=review >> Source/WebCore/xml/XMLHttpRequest.cpp:990 >> +void XMLHttpRequest::didFinishLoading(unsigned long identifier, double finishTime) > > This will likely result in a compile error since "finishTime" isn't used in this function (just omit the parameter name). Done.
Bill Budge
Comment 35 2011-02-15 20:52:27 PST
Created attachment 82584 [details] Proposed Patch
WebKit Commit Bot
Comment 36 2011-02-15 23:50:01 PST
Comment on attachment 82584 [details] Proposed Patch Rejecting attachment 82584 [details] from commit-queue. Failed to run "['./Tools/Scripts/webkit-patch', '--status-host=queues.webkit.org', '--bot-id=cr-jail-8', 'build-..." exit_code: 2 Last 500 characters of output: ................................................. fast/text/whitespace .......................................... fast/tokenizer ........................................ fast/transforms ......................... fast/url .................... fast/workers . fast/workers/dedicated-worker-lifecycle.html -> failed Exiting early after 1 failures. 11091 tests run. 302.89s total testing time 11090 test cases (99%) succeeded 1 test case (<1%) had incorrect layout 7 test cases (<1%) had stderr output Full output: http://queues.webkit.org/results/7917231
David Levin
Comment 37 2011-02-16 07:21:27 PST
Comment on attachment 82584 [details] Proposed Patch Looks like this breaks a layout test. (If you need to run that test in chromium, it is in ui_tests.) Please consider changing the ChangeLog "ThreadableLoaderClient doesn't support WebURLLoader usage" to what I made the bug title. Of course, your formulation is the answer to "Why?" which is nice but I think "What?" would be better for this case.
Bill Budge
Comment 38 2011-02-16 07:31:20 PST
Created attachment 82633 [details] Proposed Patch
David Levin
Comment 39 2011-02-16 07:43:48 PST
Comment on attachment 82633 [details] Proposed Patch The important thing is that it "looks like this breaks a layout test." Since this lastest patch has no difference from the last patch (except the ChangeLog), that issue could not have been addressed. (The ChangeLog comment was just an aside.)
Bill Budge
Comment 40 2011-02-16 08:12:48 PST
I was hoping it was a flaky test. I'll check it out.
David Levin
Comment 41 2011-02-16 08:19:22 PST
(In reply to comment #40) > I was hoping it was a flaky test. I'll check it out. The commit queue is pretty good about noting that a test was flaky. I think it only does this if the test fails twice.
Bill Budge
Comment 42 2011-02-16 17:01:57 PST
Created attachment 82724 [details] Proposed Patch There were 2 pages to your code search. I missed WorkerScriptLoader, which implements ThreadableLoaderClient.
David Levin
Comment 43 2011-02-16 17:13:05 PST
Comment on attachment 82724 [details] Proposed Patch View in context: https://bugs.webkit.org/attachment.cgi?id=82724&action=review > Source/WebCore/workers/WorkerScriptLoader.cpp:137 > +void WorkerScriptLoader::didFinishLoading(unsigned long identifier, double finishTime) omit "finishTime" since it isn't used. (As is, this will fail the compile stage on OSX.)
Bill Budge
Comment 44 2011-02-16 17:22:34 PST
Created attachment 82728 [details] Proposed Patch
WebKit Commit Bot
Comment 45 2011-02-16 20:11:53 PST
Comment on attachment 82728 [details] Proposed Patch Clearing flags on attachment: 82728 Committed r78782: <http://trac.webkit.org/changeset/78782>
WebKit Commit Bot
Comment 46 2011-02-16 20:12:01 PST
All reviewed patches have been landed. Closing bug.
Note You need to log in before you can comment on or make changes to this bug.