Fix the naming conflict issue that cause the tests to fail.

pull/4441/head
Bogdan Drutu 9 years ago
parent 4a4a20b6f4
commit 6af31bd04f
  1. 22
      src/cpp/client/client_context.cc

@ -45,14 +45,16 @@
namespace grpc {
class DefaultGlobalCallbacks GRPC_FINAL : public ClientContext::GlobalCallbacks {
class DefaultGlobalClientCallbacks GRPC_FINAL
: public ClientContext::GlobalCallbacks {
public:
void DefaultConstructor(ClientContext* context) GRPC_OVERRIDE {}
void Destructor(ClientContext* context) GRPC_OVERRIDE {}
};
static DefaultGlobalCallbacks g_default_callbacks;
static ClientContext::GlobalCallbacks* g_callbacks = &g_default_callbacks;
static DefaultGlobalClientCallbacks g_default_client_callbacks;
static ClientContext::GlobalCallbacks* g_client_callbacks =
&g_default_client_callbacks;
ClientContext::ClientContext()
: initial_metadata_received_(false),
@ -60,14 +62,14 @@ ClientContext::ClientContext()
call_canceled_(false),
deadline_(gpr_inf_future(GPR_CLOCK_REALTIME)),
propagate_from_call_(nullptr) {
g_callbacks->DefaultConstructor(this);
g_client_callbacks->DefaultConstructor(this);
}
ClientContext::~ClientContext() {
if (call_) {
grpc_call_destroy(call_);
}
g_callbacks->Destructor(this);
g_client_callbacks->Destructor(this);
}
std::unique_ptr<ClientContext> ClientContext::FromServerContext(
@ -136,11 +138,11 @@ grpc::string ClientContext::peer() const {
return peer;
}
void ClientContext::SetGlobalCallbacks(GlobalCallbacks* callbacks) {
GPR_ASSERT(g_callbacks == &g_default_callbacks);
GPR_ASSERT(callbacks != NULL);
GPR_ASSERT(callbacks != &g_default_callbacks);
g_callbacks = callbacks;
void ClientContext::SetGlobalCallbacks(GlobalCallbacks* client_callbacks) {
GPR_ASSERT(g_client_callbacks == &g_default_client_callbacks);
GPR_ASSERT(client_callbacks != NULL);
GPR_ASSERT(client_callbacks != &g_default_client_callbacks);
g_client_callbacks = client_callbacks;
}
} // namespace grpc

Loading…
Cancel
Save