Bug 39204 - schedule/unscheduleAll API in ResourceHandleMac
Summary: schedule/unscheduleAll API in ResourceHandleMac
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore Misc. (show other bugs)
Version: 528+ (Nightly build)
Hardware: Macintosh OS X 10.5
: P2 Normal
Assignee: Nobody
Depends on:
Blocks: 39202
  Show dependency treegraph
Reported: 2010-05-17 01:07 PDT by Philippe Normand
Modified: 2011-02-15 03:14 PST (History)
5 users (show)

See Also:

proposed patch (4.64 KB, patch)
2010-05-17 01:14 PDT, Philippe Normand
zimmermann: review-
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Philippe Normand 2010-05-17 01:07:04 PDT
For the GStreamer support in mac os, the WebKitWebSource element needs to pause/unpause the HTTP download depending on the status of buffered/consumed data in the pipeline. So we'd need 2 new methods in ResourceHandleMac to schedule or unschedule all the current scheduledPairs at once.
Comment 1 Philippe Normand 2010-05-17 01:14:29 PDT
Created attachment 56220 [details]
proposed patch
Comment 2 Darin Adler 2010-05-17 10:53:40 PDT
Comment on attachment 56220 [details]
proposed patch

It's a very bad idea to add a Page pointer to the ResourceHandle class. This goes against the layering, where the resource handle is the low level mechanism in the platform layer that is not tied to the page loading mechanism. We should look for another way to do this. I need to know more about the big picture here.
Comment 3 Philippe Normand 2010-05-17 23:16:32 PDT
Thanks Darin for looking at the patch.

Would it be ok to pass the Page pointer in parameter of the new methods then? This would work for my use-case as well.

About the big picture, I tried to explain it in the bug description but it wasn't probably clear enough :)

The gstreamer framework is based on the concept of pipelines where data flow between elements (source elements, demuxers, decoders, sink elements,...). Our pipeline uses a custom source element that does the HTTP data downloading with the ResourceHandle "low level" API. It has a custom ResourceHandleClient. The element is using appsrc [1]. Appsrc has an internal queue that manages the data buffering. When it's full appsrc will ask the application (ResourceHandle) to 
pause the download because it has enough data for now to feed the pipeline. When the queue reaches a low level appsrc will ask ResourceHandle to resume the download so the queue can fill again.

The source code of this element is in WebCore/platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp

[1] http://gstreamer.freedesktop.org/data/doc/gstreamer/head/gst-plugins-base-libs/html/gst-plugins-base-libs-appsrc.html
Comment 4 Philippe Normand 2010-05-27 00:59:41 PDT
Darin can you please reply to comment 3? Thanks!
Comment 5 Darin Adler 2010-05-27 20:13:21 PDT
(In reply to comment #3)
> Would it be ok to pass the Page pointer in parameter of the new methods then? This would work for my use-case as well.

Not really OK. The layering issue is that things in the platform directory can't know about things at a higher level at all. So they can’t even mention Page in their definitions.

We have to think about how to structure this so the higher level loader can set up these resource handles appropriately, but the whole point of the ResourceHandle abstraction is a low level one that does not involve things like Frame and Page.

I don’t immediately know what the right solution is. Maciej Stachoiwak might have some ideas. He’s currently on vacation. Since the platform directory was originally conceived in its current form by Hyatt, he might have ideas too.
Comment 6 Philippe Normand 2010-06-11 00:45:37 PDT
Is Maciej back? Hyatt? ;)

Another thing I can do without touching the ResourceHandleMac code is to get the SchedulePairs and internal connection instance from my side and do the scheduling/unscheduling there. This feels nasty but could maybe be acceptable in the short term. Thoughts?
Comment 7 Nikolas Zimmermann 2010-07-30 23:01:30 PDT
Comment on attachment 56220 [details]
proposed patch

r-, because of the layering violation.

I have no clue about this particular part of the code, but you could avoid passing Page, by just querying Page* from the call site, and pass in a SchedulePairHashSet* pointer to your scheduleAll/unscheduleAll functions.
Not sure if this design is good at all, other reviewers could comment better than me.
Comment 8 Philippe Normand 2010-08-18 02:25:29 PDT
It seems using  ResourceHandle::setDefersLoading in the WebKitWebSource gstreamer element is a better approach. See bug 44157