From 1ea195b6f327136a86d80dd84c4bd85273894357 Mon Sep 17 00:00:00 2001 From: Yash Tibrewal Date: Fri, 26 Oct 2018 16:11:48 -0700 Subject: Reviewer comments except for void * fixed --- include/grpcpp/impl/codegen/channel_interface.h | 5 +++++ include/grpcpp/impl/codegen/client_context.h | 4 ++-- include/grpcpp/impl/codegen/client_interceptor.h | 9 ++++----- include/grpcpp/impl/codegen/intercepted_channel.h | 10 ++++------ include/grpcpp/impl/codegen/interceptor_common.h | 2 -- include/grpcpp/impl/codegen/server_interceptor.h | 16 +++++++--------- include/grpcpp/impl/codegen/server_interface.h | 1 - test/cpp/end2end/interceptors_util.h | 2 +- 8 files changed, 23 insertions(+), 26 deletions(-) diff --git a/include/grpcpp/impl/codegen/channel_interface.h b/include/grpcpp/impl/codegen/channel_interface.h index 57026a235e..6fd1dd1d9b 100644 --- a/include/grpcpp/impl/codegen/channel_interface.h +++ b/include/grpcpp/impl/codegen/channel_interface.h @@ -122,9 +122,14 @@ class ChannelInterface { CompletionQueue* cq, void* tag) = 0; virtual bool WaitForStateChangeImpl(grpc_connectivity_state last_observed, gpr_timespec deadline) = 0; + + // EXPERIMENTAL // This is needed to keep codegen_test_minimal happy. InterceptedChannel needs // to make use of this but can't directly call Channel's implementation // because of the test. + // Returns an empty Call object (rather than being pure) since this is a new + // method and adding a new pure method to an interface would be a breaking + // change (even though this is private and non-API) virtual internal::Call CreateCallInternal(const internal::RpcMethod& method, ClientContext* context, CompletionQueue* cq, diff --git a/include/grpcpp/impl/codegen/client_context.h b/include/grpcpp/impl/codegen/client_context.h index 59c61c4f0e..f53b744dcf 100644 --- a/include/grpcpp/impl/codegen/client_context.h +++ b/include/grpcpp/impl/codegen/client_context.h @@ -404,11 +404,11 @@ class ClientContext { void set_call(grpc_call* call, const std::shared_ptr& channel); experimental::ClientRpcInfo* set_client_rpc_info( - const char* method, grpc::Channel* channel, + const char* method, grpc::ChannelInterface* channel, const std::vector< std::unique_ptr>& creators, - int interceptor_pos) { + size_t interceptor_pos) { rpc_info_ = experimental::ClientRpcInfo(this, method, channel); rpc_info_.RegisterInterceptors(creators, interceptor_pos); return &rpc_info_; diff --git a/include/grpcpp/impl/codegen/client_interceptor.h b/include/grpcpp/impl/codegen/client_interceptor.h index 8f32814838..9922206815 100644 --- a/include/grpcpp/impl/codegen/client_interceptor.h +++ b/include/grpcpp/impl/codegen/client_interceptor.h @@ -55,17 +55,16 @@ class ClientRpcInfo { // Getter methods const char* method() { return method_; } - Channel* channel() { return channel_; } + ChannelInterface* channel() { return channel_; } grpc::ClientContext* client_context() { return ctx_; } private: ClientRpcInfo(grpc::ClientContext* ctx, const char* method, - grpc::Channel* channel) + grpc::ChannelInterface* channel) : ctx_(ctx), method_(method), channel_(channel) {} // Runs interceptor at pos \a pos. void RunInterceptor( - experimental::InterceptorBatchMethods* interceptor_methods, - unsigned int pos) { + experimental::InterceptorBatchMethods* interceptor_methods, size_t pos) { GPR_CODEGEN_ASSERT(pos < interceptors_.size()); interceptors_[pos]->Intercept(interceptor_methods); } @@ -83,7 +82,7 @@ class ClientRpcInfo { grpc::ClientContext* ctx_ = nullptr; const char* method_ = nullptr; - grpc::Channel* channel_ = nullptr; + grpc::ChannelInterface* channel_ = nullptr; std::vector> interceptors_; bool hijacked_ = false; int hijacked_interceptor_ = false; diff --git a/include/grpcpp/impl/codegen/intercepted_channel.h b/include/grpcpp/impl/codegen/intercepted_channel.h index dd4b2d8712..612e56d862 100644 --- a/include/grpcpp/impl/codegen/intercepted_channel.h +++ b/include/grpcpp/impl/codegen/intercepted_channel.h @@ -45,14 +45,12 @@ class InterceptedChannel : public ChannelInterface { InterceptedChannel(ChannelInterface* channel, int pos) : channel_(channel), interceptor_pos_(pos) {} - internal::Call CreateCall(const internal::RpcMethod& method, - ClientContext* context, - CompletionQueue* cq) override { + Call CreateCall(const RpcMethod& method, ClientContext* context, + CompletionQueue* cq) override { return channel_->CreateCallInternal(method, context, cq, interceptor_pos_); } - void PerformOpsOnCall(internal::CallOpSetInterface* ops, - internal::Call* call) override { + void PerformOpsOnCall(CallOpSetInterface* ops, Call* call) override { return channel_->PerformOpsOnCall(ops, call); } void* RegisterMethod(const char* method) override { @@ -79,4 +77,4 @@ class InterceptedChannel : public ChannelInterface { } // namespace internal } // namespace grpc -#endif // GRPCPP_IMPL_CODEGEN_INTERCEPTED_CHANNEL_H \ No newline at end of file +#endif // GRPCPP_IMPL_CODEGEN_INTERCEPTED_CHANNEL_H diff --git a/include/grpcpp/impl/codegen/interceptor_common.h b/include/grpcpp/impl/codegen/interceptor_common.h index 21b27f3672..4d744b94f9 100644 --- a/include/grpcpp/impl/codegen/interceptor_common.h +++ b/include/grpcpp/impl/codegen/interceptor_common.h @@ -55,8 +55,6 @@ class InternalInterceptorBatchMethods virtual void SetRecvStatus(Status* status) = 0; virtual void SetRecvTrailingMetadata(internal::MetadataMap* map) = 0; - - virtual std::unique_ptr GetInterceptedChannel() = 0; }; class InterceptorBatchMethodsImpl : public InternalInterceptorBatchMethods { diff --git a/include/grpcpp/impl/codegen/server_interceptor.h b/include/grpcpp/impl/codegen/server_interceptor.h index 6a8b908747..c39e9a988d 100644 --- a/include/grpcpp/impl/codegen/server_interceptor.h +++ b/include/grpcpp/impl/codegen/server_interceptor.h @@ -55,21 +55,19 @@ class ServerRpcInfo { const char* method() { return method_; } grpc::ServerContext* server_context() { return ctx_; } - public: - // Runs interceptor at pos \a pos. - void RunInterceptor( - experimental::InterceptorBatchMethods* interceptor_methods, - unsigned int pos) { - GPR_CODEGEN_ASSERT(pos < interceptors_.size()); - interceptors_[pos]->Intercept(interceptor_methods); - } - private: ServerRpcInfo(grpc::ServerContext* ctx, const char* method) : ctx_(ctx), method_(method) { ref_.store(1); } + // Runs interceptor at pos \a pos. + void RunInterceptor( + experimental::InterceptorBatchMethods* interceptor_methods, size_t pos) { + GPR_CODEGEN_ASSERT(pos < interceptors_.size()); + interceptors_[pos]->Intercept(interceptor_methods); + } + void RegisterInterceptors( const std::vector< std::unique_ptr>& diff --git a/include/grpcpp/impl/codegen/server_interface.h b/include/grpcpp/impl/codegen/server_interface.h index dab08057cd..92c87a5f7e 100644 --- a/include/grpcpp/impl/codegen/server_interface.h +++ b/include/grpcpp/impl/codegen/server_interface.h @@ -20,7 +20,6 @@ #define GRPCPP_IMPL_CODEGEN_SERVER_INTERFACE_H #include -//#include #include #include #include diff --git a/test/cpp/end2end/interceptors_util.h b/test/cpp/end2end/interceptors_util.h index c44a025f82..a481ccc517 100644 --- a/test/cpp/end2end/interceptors_util.h +++ b/test/cpp/end2end/interceptors_util.h @@ -306,4 +306,4 @@ class Verifier { }; } // namespace testing -} // namespace grpc \ No newline at end of file +} // namespace grpc -- cgit v1.2.3