Adam Barth d71037bb51 HTMLImportLoader should talk directly to mojo::NetworkService
This CL re-routes the loading pipeline for HTMLImportLoader directly to
mojo::NetworkService rather than through core/fetch, platform/network, and
WebURLLoader.

R=eseidel@chromium.org, esprehn@chromium.org

Review URL: https://codereview.chromium.org/678683004
2014-10-24 15:05:42 -07:00

39 lines
1.1 KiB
C++

// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "config.h"
#include "platform/fetcher/MojoFetcher.h"
#include "base/bind.h"
#include "mojo/services/public/interfaces/network/network_service.mojom.h"
#include "platform/weborigin/KURL.h"
#include "public/platform/Platform.h"
namespace blink {
MojoFetcher::MojoFetcher(Client* client, const KURL& url)
: client_(client),
weak_factory_(this) {
DCHECK(client_);
mojo::NetworkService* net = Platform::current()->networkService();
net->CreateURLLoader(GetProxy(&url_loader_));
mojo::URLRequestPtr url_request = mojo::URLRequest::New();
url_request->url = url.string().toUTF8();
url_request->auto_follow_redirects = true;
url_loader_->Start(url_request.Pass(),
base::Bind(&MojoFetcher::OnReceivedResponse,
weak_factory_.GetWeakPtr()));
}
MojoFetcher::~MojoFetcher() {
}
void MojoFetcher::OnReceivedResponse(mojo::URLResponsePtr response) {
client_->OnReceivedResponse(response.Pass());
}
} // namespace blink