Commit 0d1660e8 authored by Daniel Bratell's avatar Daniel Bratell Committed by Commit Bot

Add support for jumbo in services/network (-7 CPU minutes)

This adds support for jumbo compilation of services/network. Jumbo
is a unity build implementation where many files are compiled
together in the same translation unit. That is usually much faster,
and more efficient, than compiling one file at a time, but it requires
the code to be compatible with such treatment.

In services/network there were two problems, one duplicated function
which this patch unduplicates, and the IPC/ParamTraits system which
is sensitive to include header ordering.

In total, on the build time reference test, this saves 7 CPU minutes
(from 12 to 4), or roughly 1 minute on an 8 core machine.

Cq-Include-Trybots: luci.chromium.try:linux_mojo
Change-Id: I997cc61159ccf9f23eb22f3b954b888b498e3862
Reviewed-on: https://chromium-review.googlesource.com/1221946Reviewed-by: default avatarYutaka Hirano <yhirano@chromium.org>
Commit-Queue: Daniel Bratell <bratell@opera.com>
Cr-Commit-Position: refs/heads/master@{#591300}
parent e3e236b0
...@@ -2,13 +2,14 @@ ...@@ -2,13 +2,14 @@
# Use of this source code is governed by a BSD-style license that can be # Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file. # found in the LICENSE file.
import("//build/config/jumbo.gni")
import("//mojo/public/tools/bindings/mojom.gni") import("//mojo/public/tools/bindings/mojom.gni")
import("//services/catalog/public/tools/catalog.gni") import("//services/catalog/public/tools/catalog.gni")
import("//services/service_manager/public/cpp/service.gni") import("//services/service_manager/public/cpp/service.gni")
import("//services/service_manager/public/service_manifest.gni") import("//services/service_manager/public/service_manifest.gni")
import("//services/service_manager/public/tools/test/service_test.gni") import("//services/service_manager/public/tools/test/service_test.gni")
component("network_service") { jumbo_component("network_service") {
sources = [ sources = [
"cert_verifier_config_type_converter.cc", "cert_verifier_config_type_converter.cc",
"cert_verifier_config_type_converter.h", "cert_verifier_config_type_converter.h",
...@@ -311,7 +312,7 @@ source_set("tests") { ...@@ -311,7 +312,7 @@ source_set("tests") {
] ]
} }
source_set("test_support") { jumbo_source_set("test_support") {
testonly = true testonly = true
sources = [ sources = [
......
...@@ -17,15 +17,6 @@ namespace cors { ...@@ -17,15 +17,6 @@ namespace cors {
namespace { namespace {
base::Optional<std::string> GetHeaderString(
const scoped_refptr<net::HttpResponseHeaders>& headers,
const std::string& header_name) {
std::string header_value;
if (!headers->GetNormalizedHeader(header_name, &header_value))
return base::nullopt;
return header_value;
}
bool NeedsPreflight(const ResourceRequest& request) { bool NeedsPreflight(const ResourceRequest& request) {
if (!IsCORSEnabledRequestMode(request.fetch_request_mode)) if (!IsCORSEnabledRequestMode(request.fetch_request_mode))
return false; return false;
...@@ -197,9 +188,8 @@ void CORSURLLoader::OnReceiveResponse( ...@@ -197,9 +188,8 @@ void CORSURLLoader::OnReceiveResponse(
// TODO(toyoshim): Reflect --allow-file-access-from-files flag. // TODO(toyoshim): Reflect --allow-file-access-from-files flag.
const auto error_status = CheckAccess( const auto error_status = CheckAccess(
request_.url, response_head.headers->response_code(), request_.url, response_head.headers->response_code(),
GetHeaderString(response_head.headers, GetHeaderString(response_head, header_names::kAccessControlAllowOrigin),
header_names::kAccessControlAllowOrigin), GetHeaderString(response_head,
GetHeaderString(response_head.headers,
header_names::kAccessControlAllowCredentials), header_names::kAccessControlAllowCredentials),
request_.fetch_credentials_mode, request_.fetch_credentials_mode,
tainted_ ? url::Origin() : *request_.request_initiator); tainted_ ? url::Origin() : *request_.request_initiator);
...@@ -234,9 +224,8 @@ void CORSURLLoader::OnReceiveRedirect( ...@@ -234,9 +224,8 @@ void CORSURLLoader::OnReceiveRedirect(
// TODO(toyoshim): Reflect --allow-file-access-from-files flag. // TODO(toyoshim): Reflect --allow-file-access-from-files flag.
const auto error_status = CheckAccess( const auto error_status = CheckAccess(
request_.url, response_head.headers->response_code(), request_.url, response_head.headers->response_code(),
GetHeaderString(response_head.headers, GetHeaderString(response_head, header_names::kAccessControlAllowOrigin),
header_names::kAccessControlAllowOrigin), GetHeaderString(response_head,
GetHeaderString(response_head.headers,
header_names::kAccessControlAllowCredentials), header_names::kAccessControlAllowCredentials),
request_.fetch_credentials_mode, request_.fetch_credentials_mode,
tainted_ ? url::Origin() : *request_.request_initiator); tainted_ ? url::Origin() : *request_.request_initiator);
...@@ -475,6 +464,15 @@ void CORSURLLoader::SetCORSFlagIfNeeded() { ...@@ -475,6 +464,15 @@ void CORSURLLoader::SetCORSFlagIfNeeded() {
fetch_cors_flag_ = true; fetch_cors_flag_ = true;
} }
base::Optional<std::string> CORSURLLoader::GetHeaderString(
const ResourceResponseHead& response,
const std::string& header_name) {
std::string header_value;
if (!response.headers->GetNormalizedHeader(header_name, &header_value))
return base::nullopt;
return header_value;
}
} // namespace cors } // namespace cors
} // namespace network } // namespace network
...@@ -94,6 +94,10 @@ class COMPONENT_EXPORT(NETWORK_SERVICE) CORSURLLoader ...@@ -94,6 +94,10 @@ class COMPONENT_EXPORT(NETWORK_SERVICE) CORSURLLoader
void SetCORSFlagIfNeeded(); void SetCORSFlagIfNeeded();
static base::Optional<std::string> GetHeaderString(
const ResourceResponseHead& response,
const std::string& header_name);
mojo::Binding<mojom::URLLoader> binding_; mojo::Binding<mojom::URLLoader> binding_;
// We need to save these for redirect. // We need to save these for redirect.
......
...@@ -2,9 +2,10 @@ ...@@ -2,9 +2,10 @@
# Use of this source code is governed by a BSD-style license that can be # Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file. # found in the LICENSE file.
import("//build/config/jumbo.gni")
import("//mojo/public/tools/bindings/mojom.gni") import("//mojo/public/tools/bindings/mojom.gni")
component("cpp") { jumbo_component("cpp") {
output_name = "network_cpp" output_name = "network_cpp"
sources = [ sources = [
...@@ -75,7 +76,7 @@ component("cpp") { ...@@ -75,7 +76,7 @@ component("cpp") {
defines = [ "IS_NETWORK_CPP_IMPL" ] defines = [ "IS_NETWORK_CPP_IMPL" ]
} }
component("cpp_base") { jumbo_component("cpp_base") {
output_name = "network_cpp_base" output_name = "network_cpp_base"
sources = [ sources = [
...@@ -111,6 +112,15 @@ component("cpp_base") { ...@@ -111,6 +112,15 @@ component("cpp_base") {
"url_request_mojom_traits.cc", "url_request_mojom_traits.cc",
"url_request_mojom_traits.h", "url_request_mojom_traits.h",
] ]
jumbo_excluded_sources = [
# IPC/Params code generators are based on macros and multiple
# inclusion of headers using those macros. That is not
# compatible with jumbo compiling all source, generators and
# users, together, so exclude those files from jumbo compilation.
"network_ipc_param_traits.cc",
"p2p_param_traits.cc",
]
public_deps = [ public_deps = [
"//services/network/public/mojom:data_pipe_interfaces", "//services/network/public/mojom:data_pipe_interfaces",
"//services/network/public/mojom:mutable_network_traffic_annotation_interface", "//services/network/public/mojom:mutable_network_traffic_annotation_interface",
......
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