[Webkit-unassigned] [Bug 29134] [GTK] Add API to access sub resources

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Sat Sep 12 08:00:04 PDT 2009


https://bugs.webkit.org/show_bug.cgi?id=29134





--- Comment #6 from Gustavo Noronha (kov) <gns at gnome.org>  2009-09-12 08:00:03 PDT ---
(In reply to comment #5)
> No need to check the method names unless they have specific comments.

This is news to me, but I am happy to remove that crap from my commits =).

> > +static char* identifierToString(unsigned long identifier)
> 
> Maybe name this toString instead.

Sounds like a plan.

> > +        g_free(webResource->priv->uri);
> > +        webResource->priv->uri = g_strdup(request.url().string().utf8().data());
> 
> I would've preferred to set the property instead of accessing private members
> like this. 

This involves removing the G_PARAM_CONSTRUCT_ONLY from the property. Are you OK
with doing that?

> > +    // If coreResource is NULL here, the resource failed to load,
> > +    // unless it's the main resource.
> > +    if (!coreResource && webResource != webkit_web_view_get_main_resource(webView))
> 
> You could just get the main resource from the data source here.

Yeah, but then I have to first get the DataSource object. Since I already have
the webView here, this seemed sensible =).

> > +    if (!coreResource)
> > +        coreResource = loader->mainResource().releaseRef();
> > +
> > +    webkit_web_resource_init_with_core_resource(webResource, coreResource.get());
> > +
> 
> What's this for?

When the WebResource is first created (in willSendRequest before this patch, in
assignIdentifier in this patch), WebCore still does not have the
ArchiveResource object for the resource. That object is only created when the
resource load is finished. Here we fill the WebResource object we created at
assignIdentifier, and gave to the user during willSendRequest with the actual,
interesting, data.

> > +        // These are hosted here because the DataSource object is
> > +        // created too late in the frame loading process.
> 
> Can you please expound more about when we need the resource and why it's too
> late in the frame loading process? Can we have a resource without a data
> source/document loader?
> Are we doing something different from Mac here?

Sure. Yeah, Mac doesn't use an object to represent the resource itself, it uses
an 'index' object, that you can use to request the object, and it also stores
these objects in its WebView, not in the DataSource, so we are doing exactly
like Mac in this regard.

The problem here is that, when a load starts, the DataSource is still not
created when the main resource starts loading (during, say, assignIdentifier).

> > +        WebKitWebResource* mainResource;
> > +        char* mainResourceIdentifier;
> > +        GHashTable* subResources;
> 
> Same. Can we have a main resource without a data source/document loader?

Yeah.

> >      webkit_web_resource_new_with_core_resource(PassRefPtr<WebCore::ArchiveResource>);
> >  
> > +    void
> > +    webkit_web_resource_init_with_core_resource(WebKitWebResource*, PassRefPtr<WebCore::ArchiveResource>);
> > +
> 
> You could just add a WebResource param to _new_with_core_resource and check for
> NULL in the impl.

Right, but I am not creating a new WebResource object there, so the semantics
are quite different. If you look at init_with_core_resource's implementation
you'll see there's no g_object_new call there. The important thing to keep in
mind here is that we want the same WebResource object to remain throughout the
various signals/delegates , so that the user can keep a reference the object he
got in resource-request-starting, and even compare his pointer to a pointer he
gets later on to know if they are the same. This is important since we don't
give the identifier to the user - the identifier is the pointer.

> > -        g_object_unref(priv->mainresource);
> > +    priv->mainresource = WEBKIT_WEB_RESOURCE(g_object_ref(webkit_web_view_get_main_resource(webView)));
> >  
> > -    priv->mainresource = webkit_web_resource_new_with_core_resource(coreResource.release());
> 
> How is the view mainresource different from the DS main resource?

It's not, they are exactly the same. The view is just holding the stuff,
because it exists before the DS is created. DS is still the API that exposes
them to the user. This is similar to what Mac is doing, like I said:

void WebFrameLoaderClient::dispatchWillSendRequest(DocumentLoader* loader,
unsig
ned long identifier, ResourceRequest& request, const ResourceResponse&
redirectR
esponse)
{
[...]
    if (implementations->willSendRequestFunc)
        request = (NSURLRequest
*)CallResourceLoadDelegate(implementations->willSendRequestFunc, webView,
@selector(webView:resource:willSendRequest:redirectResponse:fromDataSource:),
[webView _objectForIdentifier:identifier], request.nsURLRequest(),
redirectResponse.nsURLResponse(), dataSource(loader));
}

Notice the [webView _objectForIdentifier:identifier] message here =).

> r-. We need to clarify why we can't use DS for these and expound more on
> difference between WebView resources to DS resources.

I hope I have clarified these points in the comments here.

-- 
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.



More information about the webkit-unassigned mailing list