[build] Move unnecessary absl includes from metadata_batch.h (#29523)

* Move unnecessary absl includes from metadata_batch.h

metadata_batch.h is a widely used header, and so any includes it takes
that are for its internal use can negatively impact our build times.

* missing file

* build

* review feedback
pull/29575/head
Craig Tiller 3 years ago committed by GitHub
parent 717732c044
commit f7f0dcf2cb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      BUILD
  2. 2
      CMakeLists.txt
  3. 2
      Makefile
  4. 2
      build_autogenerated.yaml
  5. 1
      config.m4
  6. 1
      config.w32
  7. 1
      gRPC-Core.podspec
  8. 1
      grpc.gemspec
  9. 2
      grpc.gyp
  10. 1
      package.xml
  11. 2
      src/core/lib/security/authorization/grpc_server_authz_filter.cc
  12. 29
      src/core/lib/transport/metadata_batch.cc
  13. 30
      src/core/lib/transport/metadata_batch.h
  14. 1
      src/python/grpcio/grpc_core_dependencies.py
  15. 1
      test/core/transport/binder/binder_transport_test.cc
  16. 13
      test/core/transport/metadata_map_test.cc
  17. 1
      tools/doxygen/Doxyfile.c++.internal
  18. 1
      tools/doxygen/Doxyfile.core.internal

@ -2009,6 +2009,7 @@ grpc_cc_library(
"src/core/lib/transport/status_conversion.cc",
"src/core/lib/transport/timeout_encoding.cc",
"src/core/lib/transport/transport.cc",
"src/core/lib/transport/metadata_batch.cc",
"src/core/lib/transport/transport_op_string.cc",
] +
# TODO(hork): delete the iomgr glue code when EventEngine is fully

2
CMakeLists.txt generated

@ -2227,6 +2227,7 @@ add_library(grpc
src/core/lib/transport/byte_stream.cc
src/core/lib/transport/connectivity_state.cc
src/core/lib/transport/error_utils.cc
src/core/lib/transport/metadata_batch.cc
src/core/lib/transport/parsed_metadata.cc
src/core/lib/transport/pid_controller.cc
src/core/lib/transport/status_conversion.cc
@ -2793,6 +2794,7 @@ add_library(grpc_unsecure
src/core/lib/transport/byte_stream.cc
src/core/lib/transport/connectivity_state.cc
src/core/lib/transport/error_utils.cc
src/core/lib/transport/metadata_batch.cc
src/core/lib/transport/parsed_metadata.cc
src/core/lib/transport/pid_controller.cc
src/core/lib/transport/status_conversion.cc

2
Makefile generated

@ -1646,6 +1646,7 @@ LIBGRPC_SRC = \
src/core/lib/transport/byte_stream.cc \
src/core/lib/transport/connectivity_state.cc \
src/core/lib/transport/error_utils.cc \
src/core/lib/transport/metadata_batch.cc \
src/core/lib/transport/parsed_metadata.cc \
src/core/lib/transport/pid_controller.cc \
src/core/lib/transport/status_conversion.cc \
@ -2057,6 +2058,7 @@ LIBGRPC_UNSECURE_SRC = \
src/core/lib/transport/byte_stream.cc \
src/core/lib/transport/connectivity_state.cc \
src/core/lib/transport/error_utils.cc \
src/core/lib/transport/metadata_batch.cc \
src/core/lib/transport/parsed_metadata.cc \
src/core/lib/transport/pid_controller.cc \
src/core/lib/transport/status_conversion.cc \

@ -1602,6 +1602,7 @@ libs:
- src/core/lib/transport/byte_stream.cc
- src/core/lib/transport/connectivity_state.cc
- src/core/lib/transport/error_utils.cc
- src/core/lib/transport/metadata_batch.cc
- src/core/lib/transport/parsed_metadata.cc
- src/core/lib/transport/pid_controller.cc
- src/core/lib/transport/status_conversion.cc
@ -2396,6 +2397,7 @@ libs:
- src/core/lib/transport/byte_stream.cc
- src/core/lib/transport/connectivity_state.cc
- src/core/lib/transport/error_utils.cc
- src/core/lib/transport/metadata_batch.cc
- src/core/lib/transport/parsed_metadata.cc
- src/core/lib/transport/pid_controller.cc
- src/core/lib/transport/status_conversion.cc

1
config.m4 generated

@ -712,6 +712,7 @@ if test "$PHP_GRPC" != "no"; then
src/core/lib/transport/byte_stream.cc \
src/core/lib/transport/connectivity_state.cc \
src/core/lib/transport/error_utils.cc \
src/core/lib/transport/metadata_batch.cc \
src/core/lib/transport/parsed_metadata.cc \
src/core/lib/transport/pid_controller.cc \
src/core/lib/transport/status_conversion.cc \

1
config.w32 generated

@ -678,6 +678,7 @@ if (PHP_GRPC != "no") {
"src\\core\\lib\\transport\\byte_stream.cc " +
"src\\core\\lib\\transport\\connectivity_state.cc " +
"src\\core\\lib\\transport\\error_utils.cc " +
"src\\core\\lib\\transport\\metadata_batch.cc " +
"src\\core\\lib\\transport\\parsed_metadata.cc " +
"src\\core\\lib\\transport\\pid_controller.cc " +
"src\\core\\lib\\transport\\status_conversion.cc " +

1
gRPC-Core.podspec generated

@ -1514,6 +1514,7 @@ Pod::Spec.new do |s|
'src/core/lib/transport/error_utils.cc',
'src/core/lib/transport/error_utils.h',
'src/core/lib/transport/http2_errors.h',
'src/core/lib/transport/metadata_batch.cc',
'src/core/lib/transport/metadata_batch.h',
'src/core/lib/transport/parsed_metadata.cc',
'src/core/lib/transport/parsed_metadata.h',

1
grpc.gemspec generated

@ -1433,6 +1433,7 @@ Gem::Specification.new do |s|
s.files += %w( src/core/lib/transport/error_utils.cc )
s.files += %w( src/core/lib/transport/error_utils.h )
s.files += %w( src/core/lib/transport/http2_errors.h )
s.files += %w( src/core/lib/transport/metadata_batch.cc )
s.files += %w( src/core/lib/transport/metadata_batch.h )
s.files += %w( src/core/lib/transport/parsed_metadata.cc )
s.files += %w( src/core/lib/transport/parsed_metadata.h )

2
grpc.gyp generated

@ -999,6 +999,7 @@
'src/core/lib/transport/byte_stream.cc',
'src/core/lib/transport/connectivity_state.cc',
'src/core/lib/transport/error_utils.cc',
'src/core/lib/transport/metadata_batch.cc',
'src/core/lib/transport/parsed_metadata.cc',
'src/core/lib/transport/pid_controller.cc',
'src/core/lib/transport/status_conversion.cc',
@ -1417,6 +1418,7 @@
'src/core/lib/transport/byte_stream.cc',
'src/core/lib/transport/connectivity_state.cc',
'src/core/lib/transport/error_utils.cc',
'src/core/lib/transport/metadata_batch.cc',
'src/core/lib/transport/parsed_metadata.cc',
'src/core/lib/transport/pid_controller.cc',
'src/core/lib/transport/status_conversion.cc',

1
package.xml generated

@ -1413,6 +1413,7 @@
<file baseinstalldir="/" name="src/core/lib/transport/error_utils.cc" role="src" />
<file baseinstalldir="/" name="src/core/lib/transport/error_utils.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/transport/http2_errors.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/transport/metadata_batch.cc" role="src" />
<file baseinstalldir="/" name="src/core/lib/transport/metadata_batch.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/transport/parsed_metadata.cc" role="src" />
<file baseinstalldir="/" name="src/core/lib/transport/parsed_metadata.h" role="src" />

@ -16,6 +16,8 @@
#include "src/core/lib/security/authorization/grpc_server_authz_filter.h"
#include "absl/strings/str_join.h"
#include "src/core/lib/channel/promise_based_filter.h"
#include "src/core/lib/security/authorization/evaluate_args.h"
#include "src/core/lib/transport/transport.h"

@ -0,0 +1,29 @@
// Copyright 2021 gRPC authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include <grpc/support/port_platform.h>
#include "src/core/lib/transport/metadata_batch.h"
#include "absl/strings/escaping.h"
#include "absl/strings/str_join.h"
namespace grpc_core {
namespace metadata_detail {
void DebugStringBuilder::Add(absl::string_view key, absl::string_view value) {
if (!out_.empty()) out_.append(", ");
absl::StrAppend(&out_, absl::CEscape(key), ": ", absl::CEscape(value));
}
} // namespace metadata_detail
} // namespace grpc_core

@ -26,11 +26,6 @@
#include <cstdint>
#include <limits>
#include "absl/strings/escaping.h"
#include "absl/strings/match.h"
#include "absl/strings/str_join.h"
#include "absl/types/optional.h"
#include <grpc/grpc.h>
#include <grpc/slice.h>
#include <grpc/status.h>
@ -553,6 +548,22 @@ struct GrpcStatusContext {
namespace metadata_detail {
// Build a key/value formatted debug string.
// Output looks like 'key1: value1, key2: value2'
// The string is expected to be readable, but not necessarily parsable.
class DebugStringBuilder {
public:
// Add one key/value pair to the output.
void Add(absl::string_view key, absl::string_view value);
// Finalize the output and return the string.
// Subsequent Add calls are UB.
std::string TakeOutput() { return std::move(out_); }
private:
std::string out_;
};
// IsEncodable: Given a trait, determine if that trait is encodable, or is just
// a value attached to a MetadataMap.
// We use the presence of the key() static method to determine if a trait is
@ -1135,12 +1146,11 @@ class MetadataMap {
}
std::string DebugString() const {
std::string out;
Log([&out](absl::string_view key, absl::string_view value) {
if (!out.empty()) out.append(", ");
absl::StrAppend(&out, absl::CEscape(key), ": ", absl::CEscape(value));
metadata_detail::DebugStringBuilder builder;
Log([&builder](absl::string_view key, absl::string_view value) {
builder.Add(key, value);
});
return out;
return builder.TakeOutput();
}
// Get the pointer to the value of some known metadata.

@ -687,6 +687,7 @@ CORE_SOURCE_FILES = [
'src/core/lib/transport/byte_stream.cc',
'src/core/lib/transport/connectivity_state.cc',
'src/core/lib/transport/error_utils.cc',
'src/core/lib/transport/metadata_batch.cc',
'src/core/lib/transport/parsed_metadata.cc',
'src/core/lib/transport/pid_controller.cc',
'src/core/lib/transport/status_conversion.cc',

@ -26,6 +26,7 @@
#include "absl/memory/memory.h"
#include "absl/strings/match.h"
#include "absl/strings/str_join.h"
#include "absl/synchronization/notification.h"
#include <grpc/grpc.h>

@ -125,6 +125,19 @@ TEST(MetadataMapTest, NonEncodableTrait) {
EXPECT_EQ(map.DebugString(), "GrpcStreamNetworkState: not sent on wire");
}
TEST(DebugStringBuilderTest, AddOne) {
metadata_detail::DebugStringBuilder b;
b.Add("a", "b");
EXPECT_EQ(b.TakeOutput(), "a: b");
}
TEST(DebugStringBuilderTest, AddTwo) {
metadata_detail::DebugStringBuilder b;
b.Add("a", "b");
b.Add("c", "d");
EXPECT_EQ(b.TakeOutput(), "a: b, c: d");
}
} // namespace testing
} // namespace grpc_core

@ -2413,6 +2413,7 @@ src/core/lib/transport/connectivity_state.h \
src/core/lib/transport/error_utils.cc \
src/core/lib/transport/error_utils.h \
src/core/lib/transport/http2_errors.h \
src/core/lib/transport/metadata_batch.cc \
src/core/lib/transport/metadata_batch.h \
src/core/lib/transport/parsed_metadata.cc \
src/core/lib/transport/parsed_metadata.h \

@ -2210,6 +2210,7 @@ src/core/lib/transport/connectivity_state.h \
src/core/lib/transport/error_utils.cc \
src/core/lib/transport/error_utils.h \
src/core/lib/transport/http2_errors.h \
src/core/lib/transport/metadata_batch.cc \
src/core/lib/transport/metadata_batch.h \
src/core/lib/transport/parsed_metadata.cc \
src/core/lib/transport/parsed_metadata.h \

Loading…
Cancel
Save