HTMLImportChild* HTMLImportsController::load(HTMLImport* parent, HTMLImportChildClient* client, FetchRequest request)
{
    ASSERT(!request.url().isEmpty() && request.url().isValid());
    ASSERT(parent == root() || toHTMLImportChild(parent)->loader()->isFirstImport(toHTMLImportChild(parent)));

    if (HTMLImportChild* childToShareWith = root()->find(request.url())) {
        HTMLImportLoader* loader = childToShareWith->loader();
        ASSERT(loader);
        HTMLImportChild* child = createChild(request.url(), loader, parent, client);
        child->didShareLoader();
        return child;
    }

    bool sameOriginRequest = master()->securityOrigin()->canRequest(request.url());
    request.setCrossOriginAccessControl(
        master()->securityOrigin(), sameOriginRequest ? AllowStoredCredentials : DoNotAllowStoredCredentials,
        ClientDidNotRequestCredentials);
    ResourcePtr<RawResource> resource = parent->document()->fetcher()->fetchImport(request);
    if (!resource)
        return 0;

    HTMLImportLoader* loader = createLoader();
    HTMLImportChild* child = createChild(request.url(), loader, parent, client);
    // We set resource after the import tree is built since
    // Resource::addClient() immediately calls back to feed the bytes when the resource is cached.
    loader->startLoading(resource);
    child->didStartLoading();
    return child;
}
HTMLImportChild* HTMLImportsController::load(HTMLImport* parent, HTMLImportChildClient* client, FetchRequest request)
{
    ASSERT(!request.url().isEmpty() && request.url().isValid());
    ASSERT(parent == root() || toHTMLImportChild(parent)->loader()->isFirstImport(toHTMLImportChild(parent)));

    if (HTMLImportChild* childToShareWith = root()->find(request.url())) {
        HTMLImportLoader* loader = childToShareWith->loader();
        ASSERT(loader);
        HTMLImportChild* child = createChild(request.url(), loader, parent, client);
        child->didShareLoader();
        return child;
    }

    HTMLImportLoader* loader = createLoader();
    HTMLImportChild* child = createChild(request.url(), loader, parent, client);
    // We set resource after the import tree is built since
    // Resource::addClient() immediately calls back to feed the bytes when the resource is cached.
    loader->startLoading(request.url());
    child->didStartLoading();
    return child;
}