Commit 1139efa9 authored by Takashi Toyoshima's avatar Takashi Toyoshima Committed by Commit Bot

OOR-CORS: move network::CORSURLLoader{Factory} outside of public/cpp

Since these files are not used by Blink, we can put them in
services/network/cors.

This will make it easier for CORSURLLoader to depend on
cors::PreflightController.

Bug: 803766
Cq-Include-Trybots: master.tryserver.chromium.linux:linux_mojo
Change-Id: Ibebe686a54e70872b33db06bf7ed72d653d4d1f6
Reviewed-on: https://chromium-review.googlesource.com/999692
Commit-Queue: Takashi Toyoshima <toyoshim@chromium.org>
Reviewed-by: default avatarYutaka Hirano <yhirano@chromium.org>
Cr-Commit-Position: refs/heads/master@{#549444}
parent 1c0bb49a
......@@ -18,7 +18,7 @@
#include "content/public/browser/resource_context.h"
#include "content/public/common/content_features.h"
#include "content/public/common/weak_wrapper_shared_url_loader_factory.h"
#include "services/network/public/cpp/cors/cors_url_loader_factory.h"
#include "services/network/cors/cors_url_loader_factory.h"
#include "services/network/public/cpp/features.h"
#include "storage/browser/fileapi/file_system_context.h"
......@@ -166,7 +166,7 @@ void ResourceMessageFilter::InitializeOnIOThread() {
url_loader_factory_ = std::make_unique<URLLoaderFactoryImpl>(requester_info_);
if (base::FeatureList::IsEnabled(network::features::kOutOfBlinkCORS)) {
url_loader_factory_ = std::make_unique<network::CORSURLLoaderFactory>(
url_loader_factory_ = std::make_unique<network::cors::CORSURLLoaderFactory>(
std::move(url_loader_factory_));
}
}
......
......@@ -16,6 +16,10 @@ component("network_service") {
"conditional_cache_deletion_helper.h",
"cookie_manager.cc",
"cookie_manager.h",
"cors/cors_url_loader.cc",
"cors/cors_url_loader.h",
"cors/cors_url_loader_factory.cc",
"cors/cors_url_loader_factory.h",
"cors/preflight_controller.cc",
"cors/preflight_controller.h",
"cross_origin_read_blocking.cc",
......
......@@ -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 "services/network/public/cpp/cors/cors_url_loader.h"
#include "services/network/cors/cors_url_loader.h"
#include "base/stl_util.h"
#include "services/network/public/cpp/cors/cors.h"
......@@ -11,6 +11,8 @@
namespace network {
namespace cors {
namespace {
bool IsOriginWhiteListedTrustworthy(const url::Origin& origin) {
......@@ -233,4 +235,6 @@ void CORSURLLoader::HandleComplete(const URLLoaderCompletionStatus& status) {
network_loader_.reset();
}
} // namespace cors
} // namespace network
......@@ -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 SERVICES_NETWORK_PUBLIC_CPP_CORS_CORS_URL_LOADER_H_
#define SERVICES_NETWORK_PUBLIC_CPP_CORS_CORS_URL_LOADER_H_
#ifndef SERVICES_NETWORK_CORS_CORS_URL_LOADER_H_
#define SERVICES_NETWORK_CORS_CORS_URL_LOADER_H_
#include "mojo/public/cpp/bindings/binding.h"
#include "net/traffic_annotation/network_traffic_annotation.h"
......@@ -14,12 +14,14 @@
namespace network {
namespace cors {
// Wrapper class that adds cross-origin resource sharing capabilities
// (https://fetch.spec.whatwg.org/#http-cors-protocol), delegating requests as
// well as potential preflight requests to the supplied
// |network_loader_factory|. It is owned by the CORSURLLoaderFactory that
// created it.
class COMPONENT_EXPORT(NETWORK_CPP) CORSURLLoader
class COMPONENT_EXPORT(NETWORK_SERVICE) CORSURLLoader
: public mojom::URLLoader,
public mojom::URLLoaderClient {
public:
......@@ -96,6 +98,8 @@ class COMPONENT_EXPORT(NETWORK_CPP) CORSURLLoader
DISALLOW_COPY_AND_ASSIGN(CORSURLLoader);
};
} // namespace cors
} // namespace network
#endif // SERVICES_NETWORK_PUBLIC_CPP_CORS_CORS_URL_LOADER_H_
#endif // SERVICES_NETWORK_CORS_CORS_URL_LOADER_H_
......@@ -2,13 +2,15 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "services/network/public/cpp/cors/cors_url_loader_factory.h"
#include "services/network/cors/cors_url_loader_factory.h"
#include "services/network/public/cpp/cors/cors_url_loader.h"
#include "services/network/cors/cors_url_loader.h"
#include "services/network/public/cpp/features.h"
namespace network {
namespace cors {
CORSURLLoaderFactory::CORSURLLoaderFactory(
std::unique_ptr<mojom::URLLoaderFactory> network_loader_factory)
: network_loader_factory_(std::move(network_loader_factory)) {}
......@@ -42,4 +44,6 @@ void CORSURLLoaderFactory::Clone(mojom::URLLoaderFactoryRequest request) {
bindings_.AddBinding(this, std::move(request));
}
} // namespace cors
} // namespace network
......@@ -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 SERVICES_NETWORK_PUBLIC_CPP_CORS_CORS_URL_LOADER_FACTORY_H_
#define SERVICES_NETWORK_PUBLIC_CPP_CORS_CORS_URL_LOADER_FACTORY_H_
#ifndef SERVICES_NETWORK_CORS_CORS_URL_LOADER_FACTORY_H_
#define SERVICES_NETWORK_CORS_CORS_URL_LOADER_FACTORY_H_
#include <memory>
......@@ -16,11 +16,13 @@ namespace network {
struct ResourceRequest;
namespace cors {
// A factory class to create a URLLoader that supports CORS.
// This class takes a network::mojom::URLLoaderFactory instance in the
// constructor and owns it to make network requests for CORS preflight, and
// actual network request.
class COMPONENT_EXPORT(NETWORK_CPP) CORSURLLoaderFactory final
class COMPONENT_EXPORT(NETWORK_SERVICE) CORSURLLoaderFactory final
: public mojom::URLLoaderFactory {
public:
explicit CORSURLLoaderFactory(
......@@ -49,6 +51,8 @@ class COMPONENT_EXPORT(NETWORK_CPP) CORSURLLoaderFactory final
DISALLOW_COPY_AND_ASSIGN(CORSURLLoaderFactory);
};
} // namespace cors
} // namespace network
#endif // SERVICES_NETWORK_PUBLIC_CPP_CORS_CORS_URL_LOADER_FACTORY_H_
#endif // SERVICES_NETWORK_CORS_CORS_URL_LOADER_FACTORY_H_
......@@ -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 "services/network/public/cpp/cors/cors_url_loader.h"
#include "services/network/cors/cors_url_loader.h"
#include "base/logging.h"
#include "base/macros.h"
......@@ -12,7 +12,7 @@
#include "base/test/scoped_feature_list.h"
#include "net/http/http_request_headers.h"
#include "net/traffic_annotation/network_traffic_annotation_test_helper.h"
#include "services/network/public/cpp/cors/cors_url_loader_factory.h"
#include "services/network/cors/cors_url_loader_factory.h"
#include "services/network/public/cpp/features.h"
#include "services/network/public/mojom/url_loader.mojom.h"
#include "services/network/public/mojom/url_loader_factory.mojom.h"
......@@ -20,6 +20,9 @@
#include "testing/gtest/include/gtest/gtest.h"
namespace network {
namespace cors {
namespace {
class TestURLLoaderFactory : public mojom::URLLoaderFactory {
......@@ -258,4 +261,7 @@ TEST_F(CORSURLLoaderTest,
}
} // namespace
} // namespace cors
} // namespace network
......@@ -12,10 +12,6 @@ component("cpp") {
"cors/cors.h",
"cors/cors_legacy.cc",
"cors/cors_legacy.h",
"cors/cors_url_loader.cc",
"cors/cors_url_loader.h",
"cors/cors_url_loader_factory.cc",
"cors/cors_url_loader_factory.h",
"cors/preflight_cache.cc",
"cors/preflight_cache.h",
"cors/preflight_result.cc",
......
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