Bug 62308 - CachedResourceLoader doesn't need to know about CachedResourceRequest
Summary: CachedResourceLoader doesn't need to know about CachedResourceRequest
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore Misc. (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nate Chapin
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-06-08 12:42 PDT by Nate Chapin
Modified: 2011-06-08 15:50 PDT (History)
3 users (show)

See Also:


Attachments
patch (14.16 KB, patch)
2011-06-08 12:46 PDT, Nate Chapin
abarth: review+
abarth: commit-queue-
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Nate Chapin 2011-06-08 12:42:45 PDT
Currently, CachedResourceLoader only uses CachedResourceRequests to keep them alive (it holds the primary RefPtr) and to cancel them (CachedResourceLoader::cancelRequests()).  It appears cancelRequests() isn't strictly necessary (DocumentLoader cancels all its subresources, which accomplishes the same thing), and I can't think of a good reason not to let CachedResource own the CachedResourceRequest (especially since the same CachedResourceRequest may be used in multiple Document).

Patch shortly.
Comment 1 Nate Chapin 2011-06-08 12:46:07 PDT
Created attachment 96462 [details]
patch
Comment 2 Adam Barth 2011-06-08 12:50:34 PDT
Comment on attachment 96462 [details]
patch

At first glance, this patch looks very cool.  I need to study it in more detail.
Comment 3 Nate Chapin 2011-06-08 12:53:53 PDT
(In reply to comment #2)
> (From update of attachment 96462 [details])
> At first glance, this patch looks very cool.  I need to study it in more detail.

The main thing I'm concerned about is that I'm removing CachedResourceLoader::m_loadDoneActionTimer.  It appears it's not doing anything on trunk (since loadDone() shouldn't be getting called with a null CachedResourceRequest anymore), but it's not 100% clear to me whether or not it should be used.
Comment 4 Adam Barth 2011-06-08 12:58:14 PDT
Comment on attachment 96462 [details]
patch

View in context: https://bugs.webkit.org/attachment.cgi?id=96462&action=review

> Source/WebCore/loader/cache/CachedResourceLoader.cpp:-604
> -    for (unsigned i = 0; i < requestsToCancel.size(); ++i)
> -        requestsToCancel[i]->didFail(true);

Where did this didFail call go?  It looks like we're supposed to call didFail on requests when the Document dies.

> Source/WebCore/loader/cache/CachedResourceRequest.cpp:131
> -        return 0;
> +        return PassOwnPtr<CachedResourceRequest>();

return nullptr;
Comment 5 Nate Chapin 2011-06-08 13:15:04 PDT
(In reply to comment #4)
> (From update of attachment 96462 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=96462&action=review
> 
> > Source/WebCore/loader/cache/CachedResourceLoader.cpp:-604
> > -    for (unsigned i = 0; i < requestsToCancel.size(); ++i)
> > -        requestsToCancel[i]->didFail(true);
> 
> Where did this didFail call go?  It looks like we're supposed to call didFail on requests when the Document dies.

Currently, we cancel CachedResourceRequests and sever their connection from their SubresourceLoader, but don't actually cancel the SubresourceLoader until later.  This merges the two cancellation paths.

My attempt at a trac stacktrace (tractrace?):

http://trac.webkit.org/browser/trunk/Source/WebCore/loader/SubresourceLoader.cpp#L230
http://trac.webkit.org/browser/trunk/Source/WebCore/loader/ResourceLoader.cpp#L363
http://trac.webkit.org/browser/trunk/Source/WebCore/loader/DocumentLoader.cpp#L78
http://trac.webkit.org/browser/trunk/Source/WebCore/loader/DocumentLoader.cpp#L756
http://trac.webkit.org/browser/trunk/Source/WebCore/loader/DocumentLoader.cpp#L262


> 
> > Source/WebCore/loader/cache/CachedResourceRequest.cpp:131
> > -        return 0;
> > +        return PassOwnPtr<CachedResourceRequest>();
> 
> return nullptr;
Comment 6 Adam Barth 2011-06-08 13:41:58 PDT
Comment on attachment 96462 [details]
patch

Ok.  I'm sold.
Comment 7 Nate Chapin 2011-06-08 14:46:10 PDT
http://trac.webkit.org/changeset/88391
Comment 8 Alexey Proskuryakov 2011-06-08 15:45:31 PDT
I feel that these classes may be getting progressively misnamed. When looking at names alone, of course a loader _should_ know about its request! I'm not commenting on this particular patch here.
Comment 9 Adam Barth 2011-06-08 15:46:53 PDT
(In reply to comment #8)
> I feel that these classes may be getting progressively misnamed. When looking at names alone, of course a loader _should_ know about its request! I'm not commenting on this particular patch here.

Do you think the problem is that CachedResourceLoader shouldn't be called a "loader" or that CachedResourceRequest shouldn't be called a "request" ?
Comment 10 Nate Chapin 2011-06-08 15:50:10 PDT
(In reply to comment #9)
> (In reply to comment #8)
> > I feel that these classes may be getting progressively misnamed. When looking at names alone, of course a loader _should_ know about its request! I'm not commenting on this particular patch here.
> 
> Do you think the problem is that CachedResourceLoader shouldn't be called a "loader" or that CachedResourceRequest shouldn't be called a "request" ?

I've actually been wondering about that too (CachedResourceLoader specifically).