[transport] Make transport types derive from Transport (#36454)

This is a first step to making transports speak various forms of CallDestination, and also solidifying the future world where things talk in terms of `ClientTransport` or `ServerTransport` throughout the rest of the stack.

Closes #36454

COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/36454 from ctiller:transport-refs 4d25347023
PiperOrigin-RevId: 628432909
pull/36462/head
Craig Tiller 7 months ago committed by Copybara-Service
parent 3890766adf
commit 8e6be83a60
  1. 3
      src/core/ext/transport/binder/transport/binder_transport.h
  2. 3
      src/core/ext/transport/chaotic_good/client_transport.h
  3. 3
      src/core/ext/transport/chaotic_good/server_transport.h
  4. 3
      src/core/ext/transport/chttp2/transport/internal.h
  5. 3
      src/core/ext/transport/cronet/transport/cronet_transport.cc
  6. 3
      src/core/ext/transport/inproc/inproc_transport.cc
  7. 3
      src/core/ext/transport/inproc/legacy_inproc_transport.cc
  8. 74
      src/core/lib/transport/transport.h

@ -41,8 +41,7 @@ struct grpc_binder_stream;
// depends on what style we want to follow)
// TODO(mingcl): Decide casing for this class name. Should we use C-style class
// name here or just go with C++ style?
struct grpc_binder_transport final : public grpc_core::Transport,
public grpc_core::FilterStackTransport {
struct grpc_binder_transport final : public grpc_core::FilterStackTransport {
explicit grpc_binder_transport(
std::unique_ptr<grpc_binder::Binder> binder, bool is_client,
std::shared_ptr<grpc::experimental::binder::SecurityPolicy>

@ -65,8 +65,7 @@
namespace grpc_core {
namespace chaotic_good {
class ChaoticGoodClientTransport final : public Transport,
public ClientTransport {
class ChaoticGoodClientTransport final : public ClientTransport {
public:
ChaoticGoodClientTransport(
PromiseEndpoint control_endpoint, PromiseEndpoint data_endpoint,

@ -78,8 +78,7 @@
namespace grpc_core {
namespace chaotic_good {
class ChaoticGoodServerTransport final : public Transport,
public ServerTransport {
class ChaoticGoodServerTransport final : public ServerTransport {
public:
ChaoticGoodServerTransport(
const ChannelArgs& args, PromiseEndpoint control_endpoint,

@ -224,8 +224,7 @@ typedef enum {
} grpc_chttp2_keepalive_state;
struct grpc_chttp2_transport final
: public grpc_core::Transport,
public grpc_core::FilterStackTransport,
: public grpc_core::FilterStackTransport,
public grpc_core::RefCounted<grpc_chttp2_transport,
grpc_core::NonPolymorphicRefCount>,
public grpc_core::KeepsGrpcInitialized {

@ -119,8 +119,7 @@ static bidirectional_stream_callback cronet_callbacks = {
on_canceled};
// Cronet transport object
struct grpc_cronet_transport final : public grpc_core::Transport,
public grpc_core::FilterStackTransport {
struct grpc_cronet_transport final : public grpc_core::FilterStackTransport {
FilterStackTransport* filter_stack_transport() override { return this; }
grpc_core::ClientTransport* client_transport() override { return nullptr; }
grpc_core::ServerTransport* server_transport() override { return nullptr; }

@ -34,7 +34,6 @@ namespace grpc_core {
namespace {
class InprocServerTransport final : public RefCounted<InprocServerTransport>,
public Transport,
public ServerTransport {
public:
void SetAcceptor(Acceptor* acceptor) override {
@ -108,7 +107,7 @@ class InprocServerTransport final : public RefCounted<InprocServerTransport>,
"inproc_server_transport", GRPC_CHANNEL_CONNECTING};
};
class InprocClientTransport final : public Transport, public ClientTransport {
class InprocClientTransport final : public ClientTransport {
public:
void StartCall(CallHandler call_handler) override {
call_handler.SpawnGuarded(

@ -101,8 +101,7 @@ struct shared_mu {
gpr_refcount refs;
};
struct inproc_transport final : public grpc_core::Transport,
public grpc_core::FilterStackTransport {
struct inproc_transport final : public grpc_core::FilterStackTransport {
inproc_transport(shared_mu* mu, bool is_client)
: mu(mu),
is_client(is_client),

@ -498,7 +498,40 @@ std::string grpc_transport_op_string(grpc_transport_op* op);
namespace grpc_core {
class FilterStackTransport {
class FilterStackTransport;
class ClientTransport;
class ServerTransport;
class Transport : public Orphanable {
public:
struct RawPointerChannelArgTag {};
static absl::string_view ChannelArgName() { return GRPC_ARG_TRANSPORT; }
virtual FilterStackTransport* filter_stack_transport() = 0;
virtual ClientTransport* client_transport() = 0;
virtual ServerTransport* server_transport() = 0;
// name of this transport implementation
virtual absl::string_view GetTransportName() const = 0;
// implementation of grpc_transport_set_pollset
virtual void SetPollset(grpc_stream* stream, grpc_pollset* pollset) = 0;
// implementation of grpc_transport_set_pollset
virtual void SetPollsetSet(grpc_stream* stream,
grpc_pollset_set* pollset_set) = 0;
void SetPollingEntity(grpc_stream* stream,
grpc_polling_entity* pollset_or_pollset_set);
// implementation of grpc_transport_perform_op
virtual void PerformOp(grpc_transport_op* op) = 0;
// implementation of grpc_transport_get_endpoint
virtual grpc_endpoint* GetEndpoint() = 0;
};
class FilterStackTransport : public Transport {
public:
// Memory required for a single stream element - this is allocated by upper
// layers and initialized by the transport
@ -536,18 +569,18 @@ class FilterStackTransport {
grpc_closure* then_schedule_closure) = 0;
protected:
~FilterStackTransport() = default;
~FilterStackTransport() override = default;
};
class ClientTransport {
class ClientTransport : public Transport {
public:
virtual void StartCall(CallHandler call_handler) = 0;
protected:
~ClientTransport() = default;
~ClientTransport() override = default;
};
class ServerTransport {
class ServerTransport : public Transport {
public:
// Acceptor helps transports create calls.
class Acceptor {
@ -569,36 +602,7 @@ class ServerTransport {
virtual void SetAcceptor(Acceptor* acceptor) = 0;
protected:
~ServerTransport() = default;
};
class Transport : public Orphanable {
public:
struct RawPointerChannelArgTag {};
static absl::string_view ChannelArgName() { return GRPC_ARG_TRANSPORT; }
virtual FilterStackTransport* filter_stack_transport() = 0;
virtual ClientTransport* client_transport() = 0;
virtual ServerTransport* server_transport() = 0;
// name of this transport implementation
virtual absl::string_view GetTransportName() const = 0;
// implementation of grpc_transport_set_pollset
virtual void SetPollset(grpc_stream* stream, grpc_pollset* pollset) = 0;
// implementation of grpc_transport_set_pollset
virtual void SetPollsetSet(grpc_stream* stream,
grpc_pollset_set* pollset_set) = 0;
void SetPollingEntity(grpc_stream* stream,
grpc_polling_entity* pollset_or_pollset_set);
// implementation of grpc_transport_perform_op
virtual void PerformOp(grpc_transport_op* op) = 0;
// implementation of grpc_transport_get_endpoint
virtual grpc_endpoint* GetEndpoint() = 0;
~ServerTransport() override = default;
};
} // namespace grpc_core

Loading…
Cancel
Save