WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
92761
Add callbacks to the FrameLoaderClient when a resource is requested
https://bugs.webkit.org/show_bug.cgi?id=92761
Summary
Add callbacks to the FrameLoaderClient when a resource is requested
jochen
Reported
2012-07-31 08:40:01 PDT
Add callbacks to the FrameLoaderClient for when a resource request finished for a script or image element
Attachments
Patch
(25.35 KB, patch)
2012-07-31 08:45 PDT
,
jochen
no flags
Details
Formatted Diff
Diff
Archive of layout-test-results from gce-cr-linux-05
(111.68 KB, application/zip)
2012-07-31 09:12 PDT
,
WebKit Review Bot
no flags
Details
Patch
(25.33 KB, patch)
2012-08-01 00:26 PDT
,
jochen
no flags
Details
Formatted Diff
Diff
Patch
(25.30 KB, patch)
2012-08-01 00:32 PDT
,
jochen
no flags
Details
Formatted Diff
Diff
Patch
(25.62 KB, patch)
2012-08-01 03:40 PDT
,
jochen
no flags
Details
Formatted Diff
Diff
Patch
(19.67 KB, patch)
2012-10-16 19:36 PDT
,
Marja Hölttä
no flags
Details
Formatted Diff
Diff
Patch
(19.57 KB, patch)
2012-10-17 10:13 PDT
,
Marja Hölttä
no flags
Details
Formatted Diff
Diff
Patch
(20.74 KB, patch)
2012-11-22 01:33 PST
,
Marja Hölttä
no flags
Details
Formatted Diff
Diff
Patch
(23.02 KB, patch)
2012-11-22 05:11 PST
,
Marja Hölttä
no flags
Details
Formatted Diff
Diff
Patch
(31.30 KB, patch)
2012-11-23 03:45 PST
,
Marja Hölttä
no flags
Details
Formatted Diff
Diff
Patch
(31.86 KB, patch)
2012-11-23 06:35 PST
,
Marja Hölttä
no flags
Details
Formatted Diff
Diff
Patch
(31.55 KB, patch)
2012-11-23 06:52 PST
,
Marja Hölttä
no flags
Details
Formatted Diff
Diff
Patch
(31.22 KB, patch)
2012-11-27 07:31 PST
,
Marja Hölttä
no flags
Details
Formatted Diff
Diff
Patch
(30.66 KB, patch)
2012-11-27 07:44 PST
,
Marja Hölttä
no flags
Details
Formatted Diff
Diff
Patch
(30.56 KB, patch)
2012-11-27 09:21 PST
,
Marja Hölttä
no flags
Details
Formatted Diff
Diff
Show Obsolete
(13)
View All
Add attachment
proposed patch, testcase, etc.
jochen
Comment 1
2012-07-31 08:45:14 PDT
Created
attachment 155552
[details]
Patch
jochen
Comment 2
2012-07-31 08:45:44 PDT
Adam, can you have a look plz
WebKit Review Bot
Comment 3
2012-07-31 08:58:01 PDT
Please wait for approval from
abarth@webkit.org
,
dglazkov@chromium.org
,
fishd@chromium.org
,
jamesr@chromium.org
or
tkent@chromium.org
before submitting, as this patch contains changes to the Chromium public API. See also
https://trac.webkit.org/wiki/ChromiumWebKitAPI
.
WebKit Review Bot
Comment 4
2012-07-31 09:12:33 PDT
Comment on
attachment 155552
[details]
Patch
Attachment 155552
[details]
did not pass chromium-ews (chromium-xvfb): Output:
http://queues.webkit.org/results/13386888
New failing tests: canvas/philip/tests/2d.composite.image.source-over.html http/tests/cache/stopped-revalidation.html canvas/philip/tests/2d.composite.globalAlpha.canvas.html canvas/philip/tests/2d.composite.globalAlpha.fill.html canvas/philip/tests/2d.composite.clip.source-over.html canvas/philip/tests/2d.composite.globalAlpha.imagepattern.html canvas/philip/tests/2d.clearRect.zero.html canvas/philip/tests/2d.composite.canvas.source-in.html canvas/philip/tests/2d.composite.canvas.destination-out.html accessibility/loading-iframe-sends-notification.html canvas/philip/tests/2d.clearRect.globalcomposite.html canvas/philip/tests/2d.clearRect.clip.html canvas/philip/tests/2d.composite.clip.lighter.html canvas/philip/tests/2d.composite.image.source-in.html canvas/philip/tests/2d.composite.image.lighter.html canvas/philip/tests/2d.composite.clip.destination-atop.html canvas/philip/tests/2d.composite.image.destination-out.html canvas/philip/tests/2d.composite.image.destination-atop.html canvas/philip/tests/2d.clearRect.path.html accessibility/image-link-inline-cont.html canvas/philip/tests/2d.composite.canvas.destination-atop.html canvas/philip/tests/2d.composite.clip.destination-out.html accessibility/content-changed-notification-causes-crash.html canvas/philip/tests/2d.composite.canvas.lighter.html accessibility/img-alt-tag-only-whitespace.html canvas/philip/tests/2d.composite.canvas.source-over.html canvas/philip/tests/2d.composite.clip.source-in.html canvas/philip/tests/2d.clearRect+fillRect.alpha0.html
WebKit Review Bot
Comment 5
2012-07-31 09:12:39 PDT
Created
attachment 155562
[details]
Archive of layout-test-results from gce-cr-linux-05 The attached test failures were seen while running run-webkit-tests on the chromium-ews. Bot: gce-cr-linux-05 Port: <class 'webkitpy.common.config.ports.ChromiumXVFBPort'> Platform: Linux-2.6.39-gcg-201203291735-x86_64-with-Ubuntu-10.04-lucid
Build Bot
Comment 6
2012-07-31 09:38:18 PDT
Comment on
attachment 155552
[details]
Patch
Attachment 155552
[details]
did not pass mac-ews (mac): Output:
http://queues.webkit.org/results/13400486
jochen
Comment 7
2012-08-01 00:26:17 PDT
Created
attachment 155734
[details]
Patch
jochen
Comment 8
2012-08-01 00:32:11 PDT
Created
attachment 155735
[details]
Patch
jochen
Comment 9
2012-08-01 03:40:31 PDT
Created
attachment 155773
[details]
Patch
Adam Barth
Comment 10
2012-08-01 11:30:03 PDT
Comment on
attachment 155773
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=155773&action=review
I'm tempted to r+ this with comments, but I think I'd like to see one more round, if that's ok with you.
> Source/WebCore/loader/FrameLoaderClient.h:167 > + virtual void dispatchImageLoadFinished(Element*, CachedResource*) { } > + virtual void dispatchScriptLoadFinished(Element*, CachedResource*) { }
Why not provide more concerete types? e.g., dispatchImageLoadFinished(Element*, CachedImage*) { }
> Source/WebCore/loader/ImageLoader.cpp:270 > + document()->loader()->frameLoader()->client()->dispatchImageLoadFinished(client()->sourceElement(), resource);
Going through the DocumentLoader for these calls doesn't seem quite right. It makes more sense to me to go through the Frame: document()->frame()->loader()->client()->dispatchImageLoadFinished(client()->sourceElement(), resource); Also, do we need to null-check the frame?
> Source/WebKit/chromium/public/WebFrameClient.h:227 > + // The URL request for the given image element finished loading. > + virtual void imageLoadFinished(WebFrame*, const WebElement&, const WebURLRequest&) { }
imageLoadFinished -> didFinishImageLoad That fits the naming pattern of the functions above.
> Source/WebKit/chromium/public/WebFrameClient.h:230 > + // The URL request for the given script element finished loading. > + virtual void scriptLoadFinished(WebFrame*, const WebElement&, const WebURLRequest&) { }
ditto
> Source/WebKit/chromium/src/FrameLoaderClientImpl.h:111 > + virtual void dispatchImageLoadFinished(WebCore::Element* sourceElement, WebCore::CachedResource*); > + virtual void dispatchScriptLoadFinished(WebCore::Element* sourceElement, WebCore::CachedResource*);
These should also probably be like dispatchDidFinishImageLoad to match the similar callbacks above.
jochen
Comment 11
2012-08-01 11:44:49 PDT
I have another question for you: as is, the callbacks are only invoked when the requested resource was not in the cache but had to be loaded. I guess that's ok for the targetted use case, because we'd return a temporary error for the resource load, and I expect that every element will end up trying to load the resource over the network. Is that correct?
Adam Barth
Comment 12
2012-08-01 11:59:10 PDT
> as is, the callbacks are only invoked when the requested resource was not in the cache but had to be loaded. I guess that's ok for the targetted use case, because we'd return a temporary error for the resource load, and I expect that every element will end up trying to load the resource over the network. Is that correct?
Doesn't didLoadResourceFromMemoryCache cover that case? Maybe we should have a unified didLoadResourceFromNetwork callback rather than per-type notifications.
jochen
Comment 13
2012-08-01 12:21:55 PDT
(In reply to
comment #12
)
> > as is, the callbacks are only invoked when the requested resource was not in the cache but had to be loaded. I guess that's ok for the targetted use case, because we'd return a temporary error for the resource load, and I expect that every element will end up trying to load the resource over the network. Is that correct? > > Doesn't didLoadResourceFromMemoryCache cover that case? Maybe we should have a unified didLoadResourceFromNetwork callback rather than per-type notifications.
that callback doesn't have the element that requested the resource. The main point of the new callbacks is to connect the element with the request for the embedder. Of course, not all requests have an associated element, so I didn't come up with a good name and figured individual callbacks would be clearer
Adam Barth
Comment 14
2012-08-01 13:25:16 PDT
> Of course, not all requests have an associated element, so I didn't come up with a good name and figured individual callbacks would be clearer
I mean, not all image loads have an element either, so we need to solve that problem in any case.
Marja Hölttä
Comment 15
2012-10-16 19:36:38 PDT
Created
attachment 169073
[details]
Patch
Marja Hölttä
Comment 16
2012-10-17 10:13:02 PDT
Created
attachment 169205
[details]
Patch
Adam Barth
Comment 17
2012-10-17 10:43:28 PDT
This is another example of a use-case we have for tracking who initiated a load.
Adam Barth
Comment 18
2012-10-17 10:44:18 PDT
Bug 84883
has another approach for doing something similar.
Adam Barth
Comment 19
2012-10-17 11:56:38 PDT
Comment on
attachment 169205
[details]
Patch We discussed this over VC. We're going to merge this work with the work on the bug mentioned above. The plan is to create a CachedResourceRequest and then to have a frameloaderclient callback similar to willSendRequest but for this CachedResourceRequest.
Marja Hölttä
Comment 20
2012-11-22 01:33:47 PST
Created
attachment 175621
[details]
Patch
Marja Hölttä
Comment 21
2012-11-22 05:11:28 PST
Created
attachment 175651
[details]
Patch
Build Bot
Comment 22
2012-11-22 06:07:50 PST
Comment on
attachment 175651
[details]
Patch
Attachment 175651
[details]
did not pass mac-ews (mac): Output:
http://queues.webkit.org/results/14961377
jochen
Comment 23
2012-11-22 06:58:14 PST
Comment on
attachment 175651
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=175651&action=review
> Source/WebCore/loader/FrameLoaderClient.h:170 > + virtual void dispatchResourceRequested(const AtomicString& initiatorName, const KURL&) { }
you need to omit "initatorName" as it's unused
> Source/WebCore/loader/cache/CachedResourceLoader.cpp:426 > + if (Frame* f = frame()) {
do you know when frame is 0?
> Source/WebCore/loader/cache/CachedResourceLoader.cpp:430 > + f->loader()->client()->dispatchResourceRequested(request.initiatorName(), request.resourceRequest().url());
what should happen if initiatorName is ""?
> LayoutTests/platform/chromium/fast/loader/resource-request-callbacks.html:62 > + This test checks that the correct callbacks for resource requests are
nit. indent 4 spaces
Adam Barth
Comment 24
2012-11-22 08:54:36 PST
Comment on
attachment 175651
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=175651&action=review
> Source/WebCore/loader/FrameLoaderClient.h:169 > + virtual void dispatchResourceRequested(Element*, const KURL&) { }
These are really "WillRequestResource" since the request hasn't happened yet. Also, why not pass the entire CachedResourceRequest? That would seem to give the WebKit layer the most flexibility.
Marja Hölttä
Comment 25
2012-11-23 03:45:15 PST
Created
attachment 175771
[details]
Patch
Marja Hölttä
Comment 26
2012-11-23 03:48:14 PST
Comment on
attachment 175651
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=175651&action=review
>> Source/WebCore/loader/FrameLoaderClient.h:169 >> + virtual void dispatchResourceRequested(Element*, const KURL&) { } > > These are really "WillRequestResource" since the request hasn't happened yet. > > Also, why not pass the entire CachedResourceRequest? That would seem to give the WebKit layer the most flexibility.
Renamed this to dispatchWillRequestResource & renamed other funcs correspondingly. Added WebCachedResourceRequest and passed that to the WebKit layer.
>> Source/WebCore/loader/FrameLoaderClient.h:170 >> + virtual void dispatchResourceRequested(const AtomicString& initiatorName, const KURL&) { } > > you need to omit "initatorName" as it's unused
Done
>> Source/WebCore/loader/cache/CachedResourceLoader.cpp:426 >> + if (Frame* f = frame()) { > > do you know when frame is 0?
In requestImage, there is check for frame() being 0, and it calls this func even in that case -> we need to check here, too.
>> Source/WebCore/loader/cache/CachedResourceLoader.cpp:430 >> + f->loader()->client()->dispatchResourceRequested(request.initiatorName(), request.resourceRequest().url()); > > what should happen if initiatorName is ""?
This is no longer an issue since we're passing a WebCachedResourceRequest.
>> LayoutTests/platform/chromium/fast/loader/resource-request-callbacks.html:62 >> + This test checks that the correct callbacks for resource requests are > > nit. indent 4 spaces
Done
WebKit Review Bot
Comment 27
2012-11-23 04:32:27 PST
Comment on
attachment 175771
[details]
Patch
Attachment 175771
[details]
did not pass chromium-ews (chromium-xvfb): Output:
http://queues.webkit.org/results/14961729
New failing tests: fast/text/atsui-small-caps-punctuation-size.html
jochen
Comment 28
2012-11-23 04:40:24 PST
Comment on
attachment 175771
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=175771&action=review
> Source/WebKit/chromium/public/WebCachedResourceRequest.h:32 > +#define WebCachedResourceRequest_h
I think this should go into Source/Platform/chromium/public
> Source/WebKit/chromium/public/WebCachedResourceRequest.h:53 > + WEBKIT_EXPORT WebURL url() const;
why not return a WebURLRequest?
> Source/WebKit/chromium/public/WebCachedResourceRequest.h:65 > +protected:
why not private?
jochen
Comment 29
2012-11-23 05:04:54 PST
(In reply to
comment #28
)
> (From update of
attachment 175771
[details]
) > View in context:
https://bugs.webkit.org/attachment.cgi?id=175771&action=review
> > > Source/WebKit/chromium/public/WebCachedResourceRequest.h:32 > > +#define WebCachedResourceRequest_h > > I think this should go into Source/Platform/chromium/public
Actually, disregard that comment, the location is already correct
Marja Hölttä
Comment 30
2012-11-23 06:35:17 PST
Created
attachment 175795
[details]
Patch
Marja Hölttä
Comment 31
2012-11-23 06:36:02 PST
Comment on
attachment 175771
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=175771&action=review
>> Source/WebKit/chromium/public/WebCachedResourceRequest.h:53 >> + WEBKIT_EXPORT WebURL url() const; > > why not return a WebURLRequest?
Done
>> Source/WebKit/chromium/public/WebCachedResourceRequest.h:65 >> +protected: > > why not private?
Done
jochen
Comment 32
2012-11-23 06:43:41 PST
looks quite reasonable, I like it. Let's wait for Adam
Marja Hölttä
Comment 33
2012-11-23 06:52:51 PST
Created
attachment 175800
[details]
Patch
Marja Hölttä
Comment 34
2012-11-23 06:56:24 PST
The latest patch also renames the new class to WebCachedURLRequest (as discussed). abarth@, could you have a look?
Adam Barth
Comment 35
2012-11-26 11:22:44 PST
Comment on
attachment 175800
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=175800&action=review
> Source/WebKit/chromium/public/WebCachedURLRequest.h:48 > + ~WebCachedURLRequest();
This isn't quite the right pattern for the dtor. The problem is that you haven't exported the dtor and it's neither virtual nor inline. Take a look at WebURLRequest for the correct pattern. Basically, you want an inline dtor that calls an exported reset() function.
> Source/WebKit/chromium/public/WebCachedURLRequest.h:53 > + void assign(const WebCachedURLRequest&); > + bool equals(const WebCachedURLRequest&) const;
These need to be exported. See WebURLRequest for an example.
> Source/WebKit/chromium/public/WebCachedURLRequest.h:56 > + WEBKIT_EXPORT WebString charset() const;
Don't you need to include WebString.h for these declaration?
> Source/WebKit/chromium/public/WebCachedURLRequest.h:59 > + WEBKIT_EXPORT WebElement initiatorElement() const;
I would expect you'd need to include WebElement as well.
> Source/WebKit/chromium/src/WebCachedURLRequest.cpp:37 > +#include <public/WebElement.h>
There's no public/ prefix for WebElement. We need to improve the header including patterns, but headers in the Client part of the API (the part in WebKit/chromium/public) are just included with their base name. Headers in the Platform part of the API (the part in Platform/chromium/public) need the public/WebFoo.h pattern.
Adam Barth
Comment 36
2012-11-26 11:29:35 PST
Comment on
attachment 175800
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=175800&action=review
> Source/WebKit/chromium/public/WebCachedURLRequest.h:50 > + WebCachedURLRequest(const WebCachedURLRequest& r) { assign(r); }
The problem with this API is that it implies that the embedder can retain a WebCachedURLRequest object. However, because m_private is a raw pointer, the embedder has no control over the lifetime of the object m_private points to and can easily end up with a garbage pointer. The solution to this problem is to move the constructor, destructor, and operator= to the private section of the class declaration. That implies that the embedder can receive a pointer (or a reference) to this type of object but cannot make a copy.
> Source/WebKit/chromium/src/WebCachedURLRequest.cpp:52 > + m_private = other.m_private;
This assign() function doesn't move over m_resourceRequestWrapper. That's likely because m_resourceRequestWrapper is a WebPrivateOwnPtr, which prevents copies. Instead of having a wonky asign() function, we just need to prevent copies of WebCachedURLRequest as well.
Adam Barth
Comment 37
2012-11-26 11:29:55 PST
The general approach in this patch looks good. We just need to clean up the API design a bit.
Marja Hölttä
Comment 38
2012-11-27 07:31:20 PST
Created
attachment 176263
[details]
Patch
Adam Barth
Comment 39
2012-11-27 07:39:52 PST
Comment on
attachment 176263
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=176263&action=review
> Source/WebKit/chromium/public/WebCachedURLRequest.h:38 > +#include <wtf/Noncopyable.h>
We cannot include WTF headers in the API.
> Source/WebKit/chromium/public/WebCachedURLRequest.h:50 > +WTF_MAKE_NONCOPYABLE(WebCachedURLRequest);
You need to do this manually rather than using the macro.
Marja Hölttä
Comment 40
2012-11-27 07:44:09 PST
Created
attachment 176266
[details]
Patch
Marja Hölttä
Comment 41
2012-11-27 07:47:35 PST
Comment on
attachment 175800
[details]
Patch Thanks for comments!
Adam Barth
Comment 42
2012-11-27 09:13:34 PST
Comment on
attachment 176266
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=176266&action=review
Thanks for iterating on the API. This patch looks good with one minor nit below.
> Source/WebKit/chromium/public/WebCachedURLRequest.h:37 > +#include "platform/WebCommon.h" > +#include "platform/WebPrivateOwnPtr.h" > +#include <public/WebString.h>
These includes are inconsistent. I think we use the "platform/" style in the API.
Marja Hölttä
Comment 43
2012-11-27 09:21:27 PST
Created
attachment 176285
[details]
Patch
Adam Barth
Comment 44
2012-11-27 09:25:52 PST
Comment on
attachment 176285
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=176285&action=review
> Source/WebKit/chromium/public/WebCachedURLRequest.h:44 > +class WebElement; > +class WebString;
These aren't needed anymore, but they're also not harmful.
WebKit Review Bot
Comment 45
2012-11-27 10:01:46 PST
Comment on
attachment 176285
[details]
Patch Clearing flags on attachment: 176285 Committed
r135872
: <
http://trac.webkit.org/changeset/135872
>
WebKit Review Bot
Comment 46
2012-11-27 10:01:53 PST
All reviewed patches have been landed. Closing bug.
Tony Chang
Comment 47
2012-11-27 10:34:25 PST
This broke the clang compile. I landed a fix in
http://trac.webkit.org/changeset/135877
.
Marja Hölttä
Comment 48
2012-11-28 00:20:20 PST
tony@: Ahh, I see. Thanks for fixing it!
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug