Commit fa9bdfac authored by Kunihiko Sakamoto's avatar Kunihiko Sakamoto Committed by Commit Bot

Rename WebPackageLoader to SignedExchangeLoader

To clarify that it is for single Signed Exchange.

Bug: 803774
Change-Id: I9a7acc5b3c7b1074828c0560fba819ae351d6ff7
Reviewed-on: https://chromium-review.googlesource.com/1100658Reviewed-by: default avatarKouhei Ueno <kouhei@chromium.org>
Reviewed-by: default avatarKinuko Yasuda <kinuko@chromium.org>
Commit-Queue: Kunihiko Sakamoto <ksakamoto@chromium.org>
Cr-Commit-Position: refs/heads/master@{#567535}
parent 7b4dab1e
......@@ -1737,6 +1737,8 @@ jumbo_source_set("browser") {
"web_package/signed_exchange_error.h",
"web_package/signed_exchange_handler.cc",
"web_package/signed_exchange_handler.h",
"web_package/signed_exchange_loader.cc",
"web_package/signed_exchange_loader.h",
"web_package/signed_exchange_prologue.cc",
"web_package/signed_exchange_prologue.h",
"web_package/signed_exchange_signature_header_field.cc",
......@@ -1749,8 +1751,6 @@ jumbo_source_set("browser") {
"web_package/signed_exchange_utils.h",
"web_package/web_package_context_impl.cc",
"web_package/web_package_context_impl.h",
"web_package/web_package_loader.cc",
"web_package/web_package_loader.h",
"web_package/web_package_prefetch_handler.cc",
"web_package/web_package_prefetch_handler.h",
"web_package/web_package_request_handler.cc",
......
......@@ -14,7 +14,7 @@
#include "content/browser/loader/prefetch_url_loader_service.h"
#include "content/browser/storage_partition_impl.h"
#include "content/browser/web_package/mock_signed_exchange_handler.h"
#include "content/browser/web_package/web_package_loader.h"
#include "content/browser/web_package/signed_exchange_loader.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/web_contents.h"
#include "content/public/common/content_features.h"
......@@ -40,10 +40,10 @@ struct PrefetchBrowserTestParam {
struct ScopedSignedExchangeHandlerFactory {
explicit ScopedSignedExchangeHandlerFactory(
SignedExchangeHandlerFactory* factory) {
WebPackageLoader::SetSignedExchangeHandlerFactoryForTest(factory);
SignedExchangeLoader::SetSignedExchangeHandlerFactoryForTest(factory);
}
~ScopedSignedExchangeHandlerFactory() {
WebPackageLoader::SetSignedExchangeHandlerFactoryForTest(nullptr);
SignedExchangeLoader::SetSignedExchangeHandlerFactoryForTest(nullptr);
}
};
......
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "content/browser/web_package/web_package_loader.h"
#include "content/browser/web_package/signed_exchange_loader.h"
#include <memory>
......@@ -45,7 +45,7 @@ SignedExchangeHandlerFactory* g_signed_exchange_factory_for_testing_ = nullptr;
} // namespace
class WebPackageLoader::ResponseTimingInfo {
class SignedExchangeLoader::ResponseTimingInfo {
public:
explicit ResponseTimingInfo(const network::ResourceResponseHead& response)
: request_start_(response.request_start),
......@@ -79,7 +79,7 @@ class WebPackageLoader::ResponseTimingInfo {
DISALLOW_COPY_AND_ASSIGN(ResponseTimingInfo);
};
WebPackageLoader::WebPackageLoader(
SignedExchangeLoader::SignedExchangeLoader(
const GURL& outer_request_url,
const network::ResourceResponseHead& outer_response,
network::mojom::URLLoaderClientPtr forwarding_client,
......@@ -170,43 +170,44 @@ WebPackageLoader::WebPackageLoader(
pending_client_request_ = mojo::MakeRequest(&client_);
}
WebPackageLoader::~WebPackageLoader() = default;
SignedExchangeLoader::~SignedExchangeLoader() = default;
void WebPackageLoader::OnReceiveResponse(
void SignedExchangeLoader::OnReceiveResponse(
const network::ResourceResponseHead& response_head) {
// Must not be called because this WebPackageLoader and the client endpoints
// were bound after OnReceiveResponse() is called.
// Must not be called because this SignedExchangeLoader and the client
// endpoints were bound after OnReceiveResponse() is called.
NOTREACHED();
}
void WebPackageLoader::OnReceiveRedirect(
void SignedExchangeLoader::OnReceiveRedirect(
const net::RedirectInfo& redirect_info,
const network::ResourceResponseHead& response_head) {
// Must not be called because this WebPackageLoader and the client endpoints
// were bound after OnReceiveResponse() is called.
// Must not be called because this SignedExchangeLoader and the client
// endpoints were bound after OnReceiveResponse() is called.
NOTREACHED();
}
void WebPackageLoader::OnUploadProgress(int64_t current_position,
int64_t total_size,
OnUploadProgressCallback ack_callback) {
// Must not be called because this WebPackageLoader and the client endpoints
// were bound after OnReceiveResponse() is called.
void SignedExchangeLoader::OnUploadProgress(
int64_t current_position,
int64_t total_size,
OnUploadProgressCallback ack_callback) {
// Must not be called because this SignedExchangeLoader and the client
// endpoints were bound after OnReceiveResponse() is called.
NOTREACHED();
}
void WebPackageLoader::OnReceiveCachedMetadata(
void SignedExchangeLoader::OnReceiveCachedMetadata(
const std::vector<uint8_t>& data) {
// Curerntly CachedMetadata for WebPackage is not supported.
// Curerntly CachedMetadata for Signed Exchange is not supported.
NOTREACHED();
}
void WebPackageLoader::OnTransferSizeUpdated(int32_t transfer_size_diff) {
void SignedExchangeLoader::OnTransferSizeUpdated(int32_t transfer_size_diff) {
// TODO(https://crbug.com/803774): Implement this to progressively update the
// encoded data length in DevTools.
}
void WebPackageLoader::OnStartLoadingResponseBody(
void SignedExchangeLoader::OnStartLoadingResponseBody(
mojo::ScopedDataPipeConsumerHandle body) {
auto cert_fetcher_factory = SignedExchangeCertFetcherFactory::Create(
std::move(request_initiator_), std::move(url_loader_factory_),
......@@ -215,7 +216,7 @@ void WebPackageLoader::OnStartLoadingResponseBody(
if (g_signed_exchange_factory_for_testing_) {
signed_exchange_handler_ = g_signed_exchange_factory_for_testing_->Create(
std::make_unique<DataPipeToSourceStream>(std::move(body)),
base::BindOnce(&WebPackageLoader::OnHTTPExchangeFound,
base::BindOnce(&SignedExchangeLoader::OnHTTPExchangeFound,
weak_factory_.GetWeakPtr()),
std::move(cert_fetcher_factory));
return;
......@@ -223,23 +224,23 @@ void WebPackageLoader::OnStartLoadingResponseBody(
signed_exchange_handler_ = std::make_unique<SignedExchangeHandler>(
content_type_, std::make_unique<DataPipeToSourceStream>(std::move(body)),
base::BindOnce(&WebPackageLoader::OnHTTPExchangeFound,
base::BindOnce(&SignedExchangeLoader::OnHTTPExchangeFound,
weak_factory_.GetWeakPtr()),
std::move(cert_fetcher_factory), load_flags_,
std::move(request_context_getter_), std::move(devtools_proxy_));
}
void WebPackageLoader::OnComplete(
void SignedExchangeLoader::OnComplete(
const network::URLLoaderCompletionStatus& status) {}
void WebPackageLoader::FollowRedirect(
void SignedExchangeLoader::FollowRedirect(
const base::Optional<std::vector<std::string>>&
to_be_removed_request_headers,
const base::Optional<net::HttpRequestHeaders>& modified_request_headers) {
NOTREACHED();
}
void WebPackageLoader::ProceedWithResponse() {
void SignedExchangeLoader::ProceedWithResponse() {
// TODO(https://crbug.com/791049): Remove this when NetworkService is
// enabled by default.
DCHECK(!base::FeatureList::IsEnabled(network::features::kNetworkService));
......@@ -250,27 +251,27 @@ void WebPackageLoader::ProceedWithResponse() {
client_->OnStartLoadingResponseBody(std::move(pending_body_consumer_));
}
void WebPackageLoader::SetPriority(net::RequestPriority priority,
int intra_priority_value) {
void SignedExchangeLoader::SetPriority(net::RequestPriority priority,
int intra_priority_value) {
// TODO(https://crbug.com/803774): Implement this.
}
void WebPackageLoader::PauseReadingBodyFromNet() {
void SignedExchangeLoader::PauseReadingBodyFromNet() {
// TODO(https://crbug.com/803774): Implement this.
}
void WebPackageLoader::ResumeReadingBodyFromNet() {
void SignedExchangeLoader::ResumeReadingBodyFromNet() {
// TODO(https://crbug.com/803774): Implement this.
}
void WebPackageLoader::ConnectToClient(
void SignedExchangeLoader::ConnectToClient(
network::mojom::URLLoaderClientPtr client) {
DCHECK(pending_client_request_.is_pending());
mojo::FuseInterface(std::move(pending_client_request_),
client.PassInterface());
}
void WebPackageLoader::OnHTTPExchangeFound(
void SignedExchangeLoader::OnHTTPExchangeFound(
net::Error error,
const GURL& request_url,
const std::string& request_method,
......@@ -316,7 +317,7 @@ void WebPackageLoader::OnHTTPExchangeFound(
body_data_pipe_adapter_ = std::make_unique<SourceStreamToDataPipe>(
std::move(payload_stream), std::move(data_pipe.producer_handle),
base::BindOnce(&WebPackageLoader::FinishReadingBody,
base::BindOnce(&SignedExchangeLoader::FinishReadingBody,
base::Unretained(this)));
if (url_loader_options_ &
......@@ -330,7 +331,7 @@ void WebPackageLoader::OnHTTPExchangeFound(
client_->OnStartLoadingResponseBody(std::move(pending_body_consumer_));
}
void WebPackageLoader::FinishReadingBody(int result) {
void SignedExchangeLoader::FinishReadingBody(int result) {
// TODO(https://crbug.com/803774): Fill the data length information too.
network::URLLoaderCompletionStatus status;
status.error_code = result;
......@@ -347,7 +348,7 @@ void WebPackageLoader::FinishReadingBody(int result) {
client_->OnComplete(status);
}
void WebPackageLoader::SetSignedExchangeHandlerFactoryForTest(
void SignedExchangeLoader::SetSignedExchangeHandlerFactoryForTest(
SignedExchangeHandlerFactory* factory) {
g_signed_exchange_factory_for_testing_ = factory;
}
......
......@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CONTENT_BROWSER_WEB_PACKAGE_WEB_PACKAGE_LOADER_H_
#define CONTENT_BROWSER_WEB_PACKAGE_WEB_PACKAGE_LOADER_H_
#ifndef CONTENT_BROWSER_WEB_PACKAGE_SIGNED_EXCHANGE_LOADER_H_
#define CONTENT_BROWSER_WEB_PACKAGE_SIGNED_EXCHANGE_LOADER_H_
#include "base/callback.h"
#include "base/optional.h"
......@@ -34,18 +34,18 @@ class SignedExchangeHandlerFactory;
class URLLoaderThrottle;
class SourceStreamToDataPipe;
// WebPackageLoader handles an origin-signed HTTP exchange response. It is
// SignedExchangeLoader handles an origin-signed HTTP exchange response. It is
// created when a WebPackageRequestHandler recieves an origin-signed HTTP
// exchange response, and is owned by the handler until the StartLoaderCallback
// of WebPackageRequestHandler::StartResponse is called. After that, it is
// owned by the URLLoader mojo endpoint.
class WebPackageLoader final : public network::mojom::URLLoaderClient,
public network::mojom::URLLoader {
class SignedExchangeLoader final : public network::mojom::URLLoaderClient,
public network::mojom::URLLoader {
public:
using URLLoaderThrottlesGetter = base::RepeatingCallback<
std::vector<std::unique_ptr<content::URLLoaderThrottle>>()>;
WebPackageLoader(
SignedExchangeLoader(
const GURL& outer_request_url,
const network::ResourceResponseHead& outer_response,
network::mojom::URLLoaderClientPtr forwarding_client,
......@@ -57,7 +57,7 @@ class WebPackageLoader final : public network::mojom::URLLoaderClient,
scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory,
URLLoaderThrottlesGetter url_loader_throttles_getter,
scoped_refptr<net::URLRequestContextGetter> request_context_getter);
~WebPackageLoader() override;
~SignedExchangeLoader() override;
// network::mojom::URLLoaderClient implementation
// Only OnStartLoadingResponseBody() and OnComplete() are called.
......@@ -145,11 +145,11 @@ class WebPackageLoader final : public network::mojom::URLLoaderClient,
std::string content_type_;
base::WeakPtrFactory<WebPackageLoader> weak_factory_;
base::WeakPtrFactory<SignedExchangeLoader> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(WebPackageLoader);
DISALLOW_COPY_AND_ASSIGN(SignedExchangeLoader);
};
} // namespace content
#endif // CONTENT_BROWSER_WEB_PACKAGE_WEB_PACKAGE_LOADER_H_
#endif // CONTENT_BROWSER_WEB_PACKAGE_SIGNED_EXCHANGE_LOADER_H_
......@@ -7,8 +7,8 @@
#include "base/callback.h"
#include "base/feature_list.h"
#include "content/browser/web_package/signed_exchange_devtools_proxy.h"
#include "content/browser/web_package/signed_exchange_loader.h"
#include "content/browser/web_package/signed_exchange_url_loader_factory_for_non_network_service.h"
#include "content/browser/web_package/web_package_loader.h"
#include "content/public/common/content_features.h"
#include "mojo/public/cpp/bindings/strong_binding.h"
#include "net/url_request/url_request_context_getter.h"
......@@ -47,7 +47,7 @@ WebPackagePrefetchHandler::WebPackagePrefetchHandler(
} else {
url_loader_factory = std::move(network_loader_factory);
}
web_package_loader_ = std::make_unique<WebPackageLoader>(
signed_exchange_loader_ = std::make_unique<SignedExchangeLoader>(
outer_request_url, response, std::move(client), std::move(endpoints),
std::move(request_initiator), network::mojom::kURLLoadOptionNone,
load_flags,
......@@ -63,11 +63,11 @@ WebPackagePrefetchHandler::~WebPackagePrefetchHandler() = default;
network::mojom::URLLoaderClientRequest
WebPackagePrefetchHandler::FollowRedirect(
network::mojom::URLLoaderRequest loader_request) {
DCHECK(web_package_loader_);
DCHECK(signed_exchange_loader_);
network::mojom::URLLoaderClientPtr client;
auto pending_request = mojo::MakeRequest(&client);
web_package_loader_->ConnectToClient(std::move(client));
mojo::MakeStrongBinding(std::move(web_package_loader_),
signed_exchange_loader_->ConnectToClient(std::move(client));
mojo::MakeStrongBinding(std::move(signed_exchange_loader_),
std::move(loader_request));
return pending_request;
}
......
......@@ -22,7 +22,7 @@ namespace content {
class ResourceContext;
class URLLoaderThrottle;
class WebPackageLoader;
class SignedExchangeLoader;
// Attached to each PrefetchURLLoader if the prefetch is for a signed exchange.
class WebPackagePrefetchHandler final : public network::mojom::URLLoaderClient {
......@@ -31,7 +31,7 @@ class WebPackagePrefetchHandler final : public network::mojom::URLLoaderClient {
std::vector<std::unique_ptr<content::URLLoaderThrottle>>()>;
// This takes |network_loader| and |network_client| to set up the
// WebPackageLoader (so that the loader can load data from the network).
// SignedExchangeLoader (so that the loader can load data from the network).
// |forwarding_client| is a pointer to the downstream client (typically who
// creates this handler).
WebPackagePrefetchHandler(
......@@ -51,10 +51,10 @@ class WebPackagePrefetchHandler final : public network::mojom::URLLoaderClient {
~WebPackagePrefetchHandler() override;
// This connects |loader_request| to the WebPackageLoader, and returns the
// This connects |loader_request| to the SignedExchangeLoader, and returns the
// pending client request to the loader.
// The returned client request can be bound to the downstream client so that
// they can start directly receiving upcalls from the WebPackageLoader.
// they can start directly receiving upcalls from the SignedExchangeLoader.
// After this point |this| can be destructed.
network::mojom::URLLoaderClientRequest FollowRedirect(
network::mojom::URLLoaderRequest loader_request);
......@@ -75,7 +75,7 @@ class WebPackagePrefetchHandler final : public network::mojom::URLLoaderClient {
mojo::Binding<network::mojom::URLLoaderClient> loader_client_binding_;
std::unique_ptr<WebPackageLoader> web_package_loader_;
std::unique_ptr<SignedExchangeLoader> signed_exchange_loader_;
network::mojom::URLLoaderClient* forwarding_client_;
......
......@@ -9,8 +9,8 @@
#include "base/bind.h"
#include "base/feature_list.h"
#include "content/browser/web_package/signed_exchange_devtools_proxy.h"
#include "content/browser/web_package/signed_exchange_loader.h"
#include "content/browser/web_package/signed_exchange_utils.h"
#include "content/browser/web_package/web_package_loader.h"
#include "content/common/throttling_url_loader.h"
#include "content/public/common/content_features.h"
#include "mojo/public/cpp/bindings/strong_binding.h"
......@@ -64,7 +64,7 @@ void WebPackageRequestHandler::MaybeCreateLoader(
// ongoing matching SignedExchangeHandler which was created by a
// WebPackagePrefetcher.
if (!web_package_loader_) {
if (!signed_exchange_loader_) {
std::move(callback).Run({});
return;
}
......@@ -89,7 +89,7 @@ bool WebPackageRequestHandler::MaybeCreateLoaderForResponse(
// TODO(https://crbug.com/803774): Consider creating a new ThrottlingURLLoader
// or reusing the existing ThrottlingURLLoader by reattaching URLLoaderClient,
// to support SafeBrowsing checking of the content of the WebPackage.
web_package_loader_ = std::make_unique<WebPackageLoader>(
signed_exchange_loader_ = std::make_unique<SignedExchangeLoader>(
url_, response, std::move(client), url_loader->Unbind(),
std::move(request_initiator_), url_loader_options_, load_flags_,
std::make_unique<SignedExchangeDevToolsProxy>(
......@@ -104,8 +104,9 @@ bool WebPackageRequestHandler::MaybeCreateLoaderForResponse(
void WebPackageRequestHandler::StartResponse(
network::mojom::URLLoaderRequest request,
network::mojom::URLLoaderClientPtr client) {
web_package_loader_->ConnectToClient(std::move(client));
mojo::MakeStrongBinding(std::move(web_package_loader_), std::move(request));
signed_exchange_loader_->ConnectToClient(std::move(client));
mojo::MakeStrongBinding(std::move(signed_exchange_loader_),
std::move(request));
}
} // namespace content
......@@ -22,7 +22,7 @@ class SharedURLLoaderFactory;
namespace content {
class URLLoaderThrottle;
class WebPackageLoader;
class SignedExchangeLoader;
class WebPackageRequestHandler final : public NavigationLoaderInterceptor {
public:
......@@ -61,7 +61,7 @@ class WebPackageRequestHandler final : public NavigationLoaderInterceptor {
// Valid after MaybeCreateLoaderForResponse intercepts the request and until
// the loader is re-bound to the new client for the redirected request in
// StartResponse.
std::unique_ptr<WebPackageLoader> web_package_loader_;
std::unique_ptr<SignedExchangeLoader> signed_exchange_loader_;
url::Origin request_initiator_;
GURL url_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment