Remove `g_glip` and `class GrpcLibraryInterface` (#30414)
* Remove `g_glip` and `class GrpcLibraryInterface`
* Update
* Update
* Update
* Automated change: Fix sanity tests (#20)
* Update
* Update
* Update
* Test
* Fix
* Revert "Test"
This reverts commit 2f5c77e98d9601b84123377f3e3746be192c4cbf.
* More fix
* More fix
* More fix
* Minor fix
* Revert "Minor fix"
This reverts commit 1ee3ae4da1779fb8c2abc11dace06f09532b17d9.
* Revert "More fix"
This reverts commit 1fc234896b088ec51e02c1dde79cf70db1ef90ae.
* Revert "More fix"
This reverts commit 851393c0e6d668c9c36332b552eefc70be314a4c.
* Revert "More fix"
This reverts commit ed342a51d0dbd47eff20c7c2bbe10a523ea8ca92.
* Revert "Fix"
This reverts commit 286ad8e6394082243c8089c5f8ee904db5f49d7e.
diff --git a/BUILD b/BUILD
index 5fd8b2a..6dc77b7 100644
--- a/BUILD
+++ b/BUILD
@@ -400,7 +400,6 @@
"include/grpc++/impl/codegen/config.h",
"include/grpc++/impl/codegen/core_codegen_interface.h",
"include/grpc++/impl/codegen/create_auth_context.h",
- "include/grpc++/impl/codegen/grpc_library.h",
"include/grpc++/impl/codegen/metadata_map.h",
"include/grpc++/impl/codegen/method_handler_impl.h",
"include/grpc++/impl/codegen/rpc_method.h",
@@ -437,7 +436,6 @@
"include/grpcpp/impl/codegen/core_codegen_interface.h",
"include/grpcpp/impl/codegen/create_auth_context.h",
"include/grpcpp/impl/codegen/delegating_channel.h",
- "include/grpcpp/impl/codegen/grpc_library.h",
"include/grpcpp/impl/codegen/intercepted_channel.h",
"include/grpcpp/impl/codegen/interceptor_common.h",
"include/grpcpp/impl/codegen/interceptor.h",
diff --git a/CMakeLists.txt b/CMakeLists.txt
index d05f180..a00e7ad 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -3327,7 +3327,6 @@
include/grpc++/impl/codegen/core_codegen.h
include/grpc++/impl/codegen/core_codegen_interface.h
include/grpc++/impl/codegen/create_auth_context.h
- include/grpc++/impl/codegen/grpc_library.h
include/grpc++/impl/codegen/metadata_map.h
include/grpc++/impl/codegen/method_handler_impl.h
include/grpc++/impl/codegen/proto_utils.h
@@ -3417,7 +3416,6 @@
include/grpcpp/impl/codegen/core_codegen_interface.h
include/grpcpp/impl/codegen/create_auth_context.h
include/grpcpp/impl/codegen/delegating_channel.h
- include/grpcpp/impl/codegen/grpc_library.h
include/grpcpp/impl/codegen/intercepted_channel.h
include/grpcpp/impl/codegen/interceptor.h
include/grpcpp/impl/codegen/interceptor_common.h
@@ -4015,7 +4013,6 @@
include/grpc++/impl/codegen/core_codegen.h
include/grpc++/impl/codegen/core_codegen_interface.h
include/grpc++/impl/codegen/create_auth_context.h
- include/grpc++/impl/codegen/grpc_library.h
include/grpc++/impl/codegen/metadata_map.h
include/grpc++/impl/codegen/method_handler_impl.h
include/grpc++/impl/codegen/proto_utils.h
@@ -4104,7 +4101,6 @@
include/grpcpp/impl/codegen/core_codegen_interface.h
include/grpcpp/impl/codegen/create_auth_context.h
include/grpcpp/impl/codegen/delegating_channel.h
- include/grpcpp/impl/codegen/grpc_library.h
include/grpcpp/impl/codegen/intercepted_channel.h
include/grpcpp/impl/codegen/interceptor.h
include/grpcpp/impl/codegen/interceptor_common.h
diff --git a/build_autogenerated.yaml b/build_autogenerated.yaml
index b0f745f..48c5e82 100644
--- a/build_autogenerated.yaml
+++ b/build_autogenerated.yaml
@@ -2704,7 +2704,6 @@
- include/grpc++/impl/codegen/core_codegen.h
- include/grpc++/impl/codegen/core_codegen_interface.h
- include/grpc++/impl/codegen/create_auth_context.h
- - include/grpc++/impl/codegen/grpc_library.h
- include/grpc++/impl/codegen/metadata_map.h
- include/grpc++/impl/codegen/method_handler_impl.h
- include/grpc++/impl/codegen/proto_utils.h
@@ -2794,7 +2793,6 @@
- include/grpcpp/impl/codegen/core_codegen_interface.h
- include/grpcpp/impl/codegen/create_auth_context.h
- include/grpcpp/impl/codegen/delegating_channel.h
- - include/grpcpp/impl/codegen/grpc_library.h
- include/grpcpp/impl/codegen/intercepted_channel.h
- include/grpcpp/impl/codegen/interceptor.h
- include/grpcpp/impl/codegen/interceptor_common.h
@@ -3123,7 +3121,6 @@
- include/grpc++/impl/codegen/core_codegen.h
- include/grpc++/impl/codegen/core_codegen_interface.h
- include/grpc++/impl/codegen/create_auth_context.h
- - include/grpc++/impl/codegen/grpc_library.h
- include/grpc++/impl/codegen/metadata_map.h
- include/grpc++/impl/codegen/method_handler_impl.h
- include/grpc++/impl/codegen/proto_utils.h
@@ -3212,7 +3209,6 @@
- include/grpcpp/impl/codegen/core_codegen_interface.h
- include/grpcpp/impl/codegen/create_auth_context.h
- include/grpcpp/impl/codegen/delegating_channel.h
- - include/grpcpp/impl/codegen/grpc_library.h
- include/grpcpp/impl/codegen/intercepted_channel.h
- include/grpcpp/impl/codegen/interceptor.h
- include/grpcpp/impl/codegen/interceptor_common.h
diff --git a/gRPC-C++.podspec b/gRPC-C++.podspec
index c4c400a..c144ca3 100644
--- a/gRPC-C++.podspec
+++ b/gRPC-C++.podspec
@@ -121,7 +121,6 @@
'include/grpcpp/impl/codegen/core_codegen_interface.h',
'include/grpcpp/impl/codegen/create_auth_context.h',
'include/grpcpp/impl/codegen/delegating_channel.h',
- 'include/grpcpp/impl/codegen/grpc_library.h',
'include/grpcpp/impl/codegen/intercepted_channel.h',
'include/grpcpp/impl/codegen/interceptor.h',
'include/grpcpp/impl/codegen/interceptor_common.h',
diff --git a/include/grpc++/impl/codegen/grpc_library.h b/include/grpc++/impl/codegen/grpc_library.h
deleted file mode 100644
index 33c3e25..0000000
--- a/include/grpc++/impl/codegen/grpc_library.h
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- *
- * Copyright 2018 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.
- *
- */
-
-// DEPRECATED: The headers in include/grpc++ are deprecated. Please include the
-// headers in include/grpcpp instead. This header exists only for backwards
-// compatibility.
-
-#ifndef GRPCXX_IMPL_CODEGEN_GRPC_LIBRARY_H
-#define GRPCXX_IMPL_CODEGEN_GRPC_LIBRARY_H
-
-#include <grpcpp/impl/codegen/grpc_library.h>
-
-#endif // GRPCXX_IMPL_CODEGEN_GRPC_LIBRARY_H
diff --git a/include/grpcpp/alarm.h b/include/grpcpp/alarm.h
index 589d884..649e088 100644
--- a/include/grpcpp/alarm.h
+++ b/include/grpcpp/alarm.h
@@ -26,13 +26,12 @@
#include <grpc/grpc.h>
#include <grpcpp/completion_queue.h>
#include <grpcpp/impl/codegen/completion_queue_tag.h>
-#include <grpcpp/impl/codegen/grpc_library.h>
#include <grpcpp/impl/grpc_library.h>
#include <grpcpp/support/time.h>
namespace grpc {
-class Alarm : private grpc::GrpcLibraryCodegen {
+class Alarm : private grpc::internal::GrpcLibrary {
public:
/// Create an unset completion queue alarm
Alarm();
diff --git a/include/grpcpp/channel.h b/include/grpcpp/channel.h
index 3710e5b..29a1643 100644
--- a/include/grpcpp/channel.h
+++ b/include/grpcpp/channel.h
@@ -25,8 +25,8 @@
#include <grpcpp/completion_queue.h>
#include <grpcpp/impl/call.h>
#include <grpcpp/impl/channel_interface.h>
-#include <grpcpp/impl/codegen/grpc_library.h>
#include <grpcpp/impl/codegen/sync.h>
+#include <grpcpp/impl/grpc_library.h>
#include <grpcpp/support/client_interceptor.h>
#include <grpcpp/support/config.h>
@@ -54,7 +54,7 @@
class Channel final : public grpc::ChannelInterface,
public grpc::internal::CallHook,
public std::enable_shared_from_this<Channel>,
- private grpc::GrpcLibraryCodegen {
+ private grpc::internal::GrpcLibrary {
public:
~Channel() override;
diff --git a/include/grpcpp/completion_queue.h b/include/grpcpp/completion_queue.h
index bca5ba4..14657f1 100644
--- a/include/grpcpp/completion_queue.h
+++ b/include/grpcpp/completion_queue.h
@@ -34,14 +34,14 @@
#include <list>
-#include <grpc/support/atm.h>
+#include <grpc/impl/codegen/atm.h>
#include <grpcpp/impl/codegen/completion_queue_tag.h>
#include <grpcpp/impl/codegen/core_codegen_interface.h>
-#include <grpcpp/impl/codegen/grpc_library.h>
+#include <grpcpp/impl/codegen/rpc_service_method.h>
+#include <grpcpp/impl/codegen/status.h>
#include <grpcpp/impl/codegen/sync.h>
-#include <grpcpp/impl/rpc_service_method.h>
-#include <grpcpp/support/status.h>
-#include <grpcpp/support/time.h>
+#include <grpcpp/impl/codegen/time.h>
+#include <grpcpp/impl/grpc_library.h>
struct grpc_completion_queue;
@@ -99,7 +99,7 @@
/// src/core/lib/surface/completion_queue.h).
/// See \ref doc/cpp/perf_notes.md for notes on best practices for high
/// performance servers.
-class CompletionQueue : private grpc::GrpcLibraryCodegen {
+class CompletionQueue : private grpc::internal::GrpcLibrary {
public:
/// Default constructor. Implicitly creates a \a grpc_completion_queue
/// instance.
diff --git a/include/grpcpp/impl/codegen/grpc_library.h b/include/grpcpp/impl/codegen/grpc_library.h
deleted file mode 100644
index 9f83a7f..0000000
--- a/include/grpcpp/impl/codegen/grpc_library.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- *
- * Copyright 2016 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.
- *
- */
-
-#ifndef GRPCPP_IMPL_CODEGEN_GRPC_LIBRARY_H
-#define GRPCPP_IMPL_CODEGEN_GRPC_LIBRARY_H
-
-// IWYU pragma: private, include <grpcpp/impl/grpc_library.h>
-
-#include <grpcpp/impl/codegen/core_codegen_interface.h>
-
-namespace grpc {
-
-class GrpcLibraryInterface {
- public:
- virtual ~GrpcLibraryInterface() = default;
- virtual void init() = 0;
- virtual void shutdown() = 0;
-};
-
-/// Initialized by \a grpc::GrpcLibraryInitializer from
-/// <grpcpp/impl/grpc_library.h>
-extern GrpcLibraryInterface* g_glip;
-
-/// Classes that require gRPC to be initialized should inherit from this class.
-class GrpcLibraryCodegen {
- public:
- explicit GrpcLibraryCodegen(bool call_grpc_init = true)
- : grpc_init_called_(false) {
- if (call_grpc_init) {
- GPR_CODEGEN_ASSERT(g_glip &&
- "gRPC library not initialized. See "
- "grpc::internal::GrpcLibraryInitializer.");
- g_glip->init();
- grpc_init_called_ = true;
- }
- }
- virtual ~GrpcLibraryCodegen() {
- if (grpc_init_called_) {
- GPR_CODEGEN_ASSERT(g_glip &&
- "gRPC library not initialized. See "
- "grpc::internal::GrpcLibraryInitializer.");
- g_glip->shutdown();
- }
- }
-
- private:
- bool grpc_init_called_;
-};
-
-} // namespace grpc
-
-#endif // GRPCPP_IMPL_CODEGEN_GRPC_LIBRARY_H
diff --git a/include/grpcpp/impl/grpc_library.h b/include/grpcpp/impl/grpc_library.h
index 0afca8e..0e0275f 100644
--- a/include/grpcpp/impl/grpc_library.h
+++ b/include/grpcpp/impl/grpc_library.h
@@ -24,25 +24,34 @@
#include <grpc/grpc.h>
#include <grpcpp/impl/codegen/config.h>
#include <grpcpp/impl/codegen/core_codegen.h>
-#include <grpcpp/impl/codegen/grpc_library.h> // IWYU pragma: export
namespace grpc {
namespace internal {
-class GrpcLibrary final : public GrpcLibraryInterface {
+
+/// Classes that require gRPC to be initialized should inherit from this class.
+class GrpcLibrary {
public:
- void init() override { grpc_init(); }
- void shutdown() override { grpc_shutdown(); }
+ explicit GrpcLibrary(bool call_grpc_init = true) : grpc_init_called_(false) {
+ if (call_grpc_init) {
+ grpc_init();
+ grpc_init_called_ = true;
+ }
+ }
+ virtual ~GrpcLibrary() {
+ if (grpc_init_called_) {
+ grpc_shutdown();
+ }
+ }
+
+ private:
+ bool grpc_init_called_;
};
/// Instantiating this class ensures the proper initialization of gRPC.
class GrpcLibraryInitializer final {
public:
GrpcLibraryInitializer() {
- if (grpc::g_glip == nullptr) {
- static auto* const g_gli = new GrpcLibrary();
- grpc::g_glip = g_gli;
- }
if (grpc::g_core_codegen_interface == nullptr) {
static auto* const g_core_codegen = new CoreCodegen();
grpc::g_core_codegen_interface = g_core_codegen;
diff --git a/include/grpcpp/resource_quota.h b/include/grpcpp/resource_quota.h
index 5cec89d..2d2f363 100644
--- a/include/grpcpp/resource_quota.h
+++ b/include/grpcpp/resource_quota.h
@@ -21,7 +21,7 @@
struct grpc_resource_quota;
-#include <grpcpp/impl/codegen/grpc_library.h>
+#include <grpcpp/impl/grpc_library.h>
#include <grpcpp/support/config.h>
namespace grpc {
@@ -31,7 +31,7 @@
/// or a client channel (via \a ChannelArguments).
/// gRPC will attempt to keep memory and threads used by all attached entities
/// below the ResourceQuota bound.
-class ResourceQuota final : private grpc::GrpcLibraryCodegen {
+class ResourceQuota final : private grpc::internal::GrpcLibrary {
public:
/// \param name - a unique name for this ResourceQuota.
explicit ResourceQuota(const std::string& name);
diff --git a/include/grpcpp/security/authorization_policy_provider.h b/include/grpcpp/security/authorization_policy_provider.h
index 1718db4..fe4f2c1 100644
--- a/include/grpcpp/security/authorization_policy_provider.h
+++ b/include/grpcpp/security/authorization_policy_provider.h
@@ -19,7 +19,7 @@
#include <grpc/grpc_security.h>
#include <grpc/status.h>
-#include <grpcpp/impl/codegen/grpc_library.h>
+#include <grpcpp/impl/codegen/status.h>
namespace grpc {
namespace experimental {
diff --git a/include/grpcpp/security/credentials.h b/include/grpcpp/security/credentials.h
index eb0f011..0285bcc 100644
--- a/include/grpcpp/security/credentials.h
+++ b/include/grpcpp/security/credentials.h
@@ -25,7 +25,7 @@
#include <grpc/grpc_security_constants.h>
#include <grpcpp/channel.h>
-#include <grpcpp/impl/codegen/grpc_library.h>
+#include <grpcpp/impl/grpc_library.h>
#include <grpcpp/security/auth_context.h>
#include <grpcpp/security/tls_credentials_options.h>
#include <grpcpp/support/channel_arguments.h>
@@ -66,7 +66,7 @@
/// for all the calls on that channel.
///
/// \see https://grpc.io/docs/guides/auth.html
-class ChannelCredentials : private grpc::GrpcLibraryCodegen {
+class ChannelCredentials : private grpc::internal::GrpcLibrary {
public:
ChannelCredentials();
~ChannelCredentials() override;
@@ -123,7 +123,7 @@
/// authenticate with a server for a given call on a channel.
///
/// \see https://grpc.io/docs/guides/auth.html
-class CallCredentials : private grpc::GrpcLibraryCodegen {
+class CallCredentials : private grpc::internal::GrpcLibrary {
public:
CallCredentials();
~CallCredentials() override;
diff --git a/include/grpcpp/security/server_credentials.h b/include/grpcpp/security/server_credentials.h
index b79816c..19cdaaf 100644
--- a/include/grpcpp/security/server_credentials.h
+++ b/include/grpcpp/security/server_credentials.h
@@ -23,6 +23,7 @@
#include <vector>
#include <grpc/grpc_security_constants.h>
+#include <grpcpp/impl/grpc_library.h>
#include <grpcpp/security/auth_metadata_processor.h>
#include <grpcpp/security/tls_credentials_options.h>
#include <grpcpp/support/config.h>
@@ -65,7 +66,7 @@
const std::shared_ptr<ServerCredentials>& fallback_credentials);
/// Wrapper around \a grpc_server_credentials, a way to authenticate a server.
-class ServerCredentials : private grpc::GrpcLibraryCodegen {
+class ServerCredentials : private grpc::internal::GrpcLibrary {
public:
ServerCredentials();
~ServerCredentials() override;
diff --git a/include/grpcpp/security/tls_certificate_provider.h b/include/grpcpp/security/tls_certificate_provider.h
index bbef455..ce9df5a 100644
--- a/include/grpcpp/security/tls_certificate_provider.h
+++ b/include/grpcpp/security/tls_certificate_provider.h
@@ -24,7 +24,6 @@
#include <grpc/grpc_security_constants.h>
#include <grpc/status.h>
#include <grpc/support/log.h>
-#include <grpcpp/impl/codegen/grpc_library.h>
#include <grpcpp/support/config.h>
namespace grpc {
diff --git a/include/grpcpp/security/tls_certificate_verifier.h b/include/grpcpp/security/tls_certificate_verifier.h
index 881adf2..0c9f35a 100644
--- a/include/grpcpp/security/tls_certificate_verifier.h
+++ b/include/grpcpp/security/tls_certificate_verifier.h
@@ -26,7 +26,6 @@
#include <grpc/grpc_security_constants.h>
#include <grpc/status.h>
#include <grpc/support/log.h>
-#include <grpcpp/impl/codegen/grpc_library.h>
#include <grpcpp/impl/codegen/sync.h>
#include <grpcpp/impl/grpc_library.h>
#include <grpcpp/support/config.h>
diff --git a/include/grpcpp/server.h b/include/grpcpp/server.h
index fe1a458..2bba010 100644
--- a/include/grpcpp/server.h
+++ b/include/grpcpp/server.h
@@ -31,8 +31,8 @@
#include <grpcpp/completion_queue.h>
#include <grpcpp/health_check_service_interface.h>
#include <grpcpp/impl/call.h>
-#include <grpcpp/impl/codegen/grpc_library.h>
#include <grpcpp/impl/codegen/server_interface.h>
+#include <grpcpp/impl/grpc_library.h>
#include <grpcpp/impl/rpc_service_method.h>
#include <grpcpp/security/server_credentials.h>
#include <grpcpp/support/channel_arguments.h>
@@ -55,7 +55,7 @@
///
/// Use a \a grpc::ServerBuilder to create, configure, and start
/// \a Server instances.
-class Server : public ServerInterface, private GrpcLibraryCodegen {
+class Server : public ServerInterface, private internal::GrpcLibrary {
public:
~Server() ABSL_LOCKS_EXCLUDED(mu_) override;
diff --git a/src/core/ext/transport/binder/client/channel_create.cc b/src/core/ext/transport/binder/client/channel_create.cc
index 7eb6041..b08bae6 100644
--- a/src/core/ext/transport/binder/client/channel_create.cc
+++ b/src/core/ext/transport/binder/client/channel_create.cc
@@ -99,8 +99,7 @@
void* jni_env_void, jobject application, absl::string_view uri,
std::shared_ptr<grpc::experimental::binder::SecurityPolicy> security_policy,
const ChannelArguments& args) {
- grpc::internal::GrpcLibrary init_lib;
- init_lib.init();
+ grpc_init();
GPR_ASSERT(jni_env_void != nullptr);
GPR_ASSERT(security_policy != nullptr);
diff --git a/src/cpp/client/create_channel.cc b/src/cpp/client/create_channel.cc
index 34b9227..91e3c0c 100644
--- a/src/cpp/client/create_channel.cc
+++ b/src/cpp/client/create_channel.cc
@@ -44,7 +44,7 @@
const grpc::string& target,
const std::shared_ptr<grpc::ChannelCredentials>& creds,
const grpc::ChannelArguments& args) {
- grpc::GrpcLibraryCodegen
+ grpc::internal::GrpcLibrary
init_lib; // We need to call init in case of bad creds.
return creds ? creds->CreateChannelImpl(target, args)
: grpc::CreateChannelInternal(
@@ -76,7 +76,7 @@
std::vector<
std::unique_ptr<grpc::experimental::ClientInterceptorFactoryInterface>>
interceptor_creators) {
- grpc::GrpcLibraryCodegen
+ grpc::internal::GrpcLibrary
init_lib; // We need to call init in case of bad creds.
return creds ? creds->CreateChannelWithInterceptors(
target, args, std::move(interceptor_creators))
diff --git a/src/cpp/client/create_channel_posix.cc b/src/cpp/client/create_channel_posix.cc
index 94e099d..2252c24 100644
--- a/src/cpp/client/create_channel_posix.cc
+++ b/src/cpp/client/create_channel_posix.cc
@@ -41,22 +41,18 @@
std::shared_ptr<Channel> CreateInsecureChannelFromFd(const std::string& target,
int fd) {
internal::GrpcLibrary init_lib;
- init_lib.init();
grpc_channel_credentials* creds = grpc_insecure_credentials_create();
auto channel = CreateChannelInternal(
"", grpc_channel_create_from_fd(target.c_str(), fd, creds, nullptr),
std::vector<
std::unique_ptr<experimental::ClientInterceptorFactoryInterface>>());
grpc_channel_credentials_release(creds);
- // Channel also initializes gRPC, so we can decrement the init ref count here.
- init_lib.shutdown();
return channel;
}
std::shared_ptr<Channel> CreateCustomInsecureChannelFromFd(
const std::string& target, int fd, const grpc::ChannelArguments& args) {
internal::GrpcLibrary init_lib;
- init_lib.init();
grpc_channel_args channel_args;
args.SetChannelArgs(&channel_args);
grpc_channel_credentials* creds = grpc_insecure_credentials_create();
@@ -66,7 +62,6 @@
std::unique_ptr<experimental::ClientInterceptorFactoryInterface>>());
grpc_channel_credentials_release(creds);
// Channel also initializes gRPC, so we can decrement the init ref count here.
- init_lib.shutdown();
return channel;
}
@@ -78,7 +73,6 @@
std::unique_ptr<grpc::experimental::ClientInterceptorFactoryInterface>>
interceptor_creators) {
internal::GrpcLibrary init_lib;
- init_lib.init();
grpc_channel_args channel_args;
args.SetChannelArgs(&channel_args);
grpc_channel_credentials* creds = grpc_insecure_credentials_create();
@@ -86,8 +80,6 @@
"", grpc_channel_create_from_fd(target.c_str(), fd, creds, &channel_args),
std::move(interceptor_creators));
grpc_channel_credentials_release(creds);
- // Channel also initializes gRPC, so we can decrement the init ref count here.
- init_lib.shutdown();
return channel;
}
diff --git a/src/cpp/client/secure_credentials.cc b/src/cpp/client/secure_credentials.cc
index cef015d..69c33ae 100644
--- a/src/cpp/client/secure_credentials.cc
+++ b/src/cpp/client/secure_credentials.cc
@@ -116,14 +116,14 @@
} // namespace
std::shared_ptr<ChannelCredentials> GoogleDefaultCredentials() {
- grpc::GrpcLibraryCodegen init; // To call grpc_init().
+ grpc::internal::GrpcLibrary init; // To call grpc_init().
return internal::WrapChannelCredentials(
grpc_google_default_credentials_create(nullptr));
}
std::shared_ptr<CallCredentials> ExternalAccountCredentials(
const grpc::string& json_string, const std::vector<grpc::string>& scopes) {
- grpc::GrpcLibraryCodegen init; // To call grpc_init().
+ grpc::internal::GrpcLibrary init; // To call grpc_init().
return WrapCallCredentials(grpc_external_account_credentials_create(
json_string.c_str(), absl::StrJoin(scopes, ",").c_str()));
}
@@ -131,7 +131,7 @@
// Builds SSL Credentials given SSL specific options
std::shared_ptr<ChannelCredentials> SslCredentials(
const SslCredentialsOptions& options) {
- grpc::GrpcLibraryCodegen init; // To call grpc_init().
+ grpc::internal::GrpcLibrary init; // To call grpc_init().
grpc_ssl_pem_key_cert_pair pem_key_cert_pair = {
options.pem_private_key.c_str(), options.pem_cert_chain.c_str()};
@@ -277,7 +277,7 @@
std::shared_ptr<CallCredentials> MetadataCredentialsFromPlugin(
std::unique_ptr<MetadataCredentialsPlugin> plugin,
grpc_security_level min_security_level) {
- grpc::GrpcLibraryCodegen init; // To call grpc_init().
+ grpc::internal::GrpcLibrary init; // To call grpc_init().
const char* type = plugin->GetType();
grpc::MetadataCredentialsPluginWrapper* wrapper =
new grpc::MetadataCredentialsPluginWrapper(std::move(plugin));
@@ -292,7 +292,7 @@
// Builds ALTS Credentials given ALTS specific options
std::shared_ptr<ChannelCredentials> AltsCredentials(
const AltsCredentialsOptions& options) {
- grpc::GrpcLibraryCodegen init; // To call grpc_init().
+ grpc::internal::GrpcLibrary init; // To call grpc_init().
grpc_alts_credentials_options* c_options =
grpc_alts_credentials_client_options_create();
for (const auto& service_account : options.target_service_accounts) {
@@ -307,7 +307,7 @@
// Builds Local Credentials
std::shared_ptr<ChannelCredentials> LocalCredentials(
grpc_local_connect_type type) {
- grpc::GrpcLibraryCodegen init; // To call grpc_init().
+ grpc::internal::GrpcLibrary init; // To call grpc_init().
return internal::WrapChannelCredentials(grpc_local_credentials_create(type));
}
@@ -322,7 +322,7 @@
// Builds credentials for use when running in GCE
std::shared_ptr<CallCredentials> GoogleComputeEngineCredentials() {
- grpc::GrpcLibraryCodegen init; // To call grpc_init().
+ grpc::internal::GrpcLibrary init; // To call grpc_init().
return WrapCallCredentials(
grpc_google_compute_engine_credentials_create(nullptr));
}
@@ -330,7 +330,7 @@
// Builds JWT credentials.
std::shared_ptr<CallCredentials> ServiceAccountJWTAccessCredentials(
const std::string& json_key, long token_lifetime_seconds) {
- grpc::GrpcLibraryCodegen init; // To call grpc_init().
+ grpc::internal::GrpcLibrary init; // To call grpc_init().
if (token_lifetime_seconds <= 0) {
gpr_log(GPR_ERROR,
"Trying to create JWTCredentials with non-positive lifetime");
@@ -345,7 +345,7 @@
// Builds refresh token credentials.
std::shared_ptr<CallCredentials> GoogleRefreshTokenCredentials(
const std::string& json_refresh_token) {
- grpc::GrpcLibraryCodegen init; // To call grpc_init().
+ grpc::internal::GrpcLibrary init; // To call grpc_init().
return WrapCallCredentials(grpc_google_refresh_token_credentials_create(
json_refresh_token.c_str(), nullptr));
}
@@ -353,7 +353,7 @@
// Builds access token credentials.
std::shared_ptr<CallCredentials> AccessTokenCredentials(
const std::string& access_token) {
- grpc::GrpcLibraryCodegen init; // To call grpc_init().
+ grpc::internal::GrpcLibrary init; // To call grpc_init().
return WrapCallCredentials(
grpc_access_token_credentials_create(access_token.c_str(), nullptr));
}
@@ -362,7 +362,7 @@
std::shared_ptr<CallCredentials> GoogleIAMCredentials(
const std::string& authorization_token,
const std::string& authority_selector) {
- grpc::GrpcLibraryCodegen init; // To call grpc_init().
+ grpc::internal::GrpcLibrary init; // To call grpc_init().
return WrapCallCredentials(grpc_google_iam_credentials_create(
authorization_token.c_str(), authority_selector.c_str(), nullptr));
}
@@ -402,7 +402,7 @@
std::shared_ptr<CallCredentials> MetadataCredentialsFromPlugin(
std::unique_ptr<MetadataCredentialsPlugin> plugin) {
- grpc::GrpcLibraryCodegen init; // To call grpc_init().
+ grpc::internal::GrpcLibrary init; // To call grpc_init().
const char* type = plugin->GetType();
grpc::MetadataCredentialsPluginWrapper* wrapper =
new grpc::MetadataCredentialsPluginWrapper(std::move(plugin));
diff --git a/src/cpp/client/secure_credentials.h b/src/cpp/client/secure_credentials.h
index f7f56f9..86a63f8 100644
--- a/src/cpp/client/secure_credentials.h
+++ b/src/cpp/client/secure_credentials.h
@@ -105,7 +105,7 @@
} // namespace experimental
-class MetadataCredentialsPluginWrapper final : private GrpcLibraryCodegen {
+class MetadataCredentialsPluginWrapper final : private internal::GrpcLibrary {
public:
static void Destroy(void* wrapper);
static int GetMetadata(
diff --git a/src/cpp/codegen/codegen_init.cc b/src/cpp/codegen/codegen_init.cc
index 4e1176f..df208ee 100644
--- a/src/cpp/codegen/codegen_init.cc
+++ b/src/cpp/codegen/codegen_init.cc
@@ -17,7 +17,6 @@
*/
#include <grpcpp/impl/codegen/core_codegen_interface.h>
-#include <grpcpp/impl/grpc_library.h>
/// Null-initializes the global gRPC variables for the codegen library. These
/// stay null in the absence of grpc++ library. In this case, no gRPC
@@ -27,4 +26,3 @@
/// as part of the instantiation of a \a grpc::GrpcLibraryInitializer variable.
grpc::CoreCodegenInterface* grpc::g_core_codegen_interface;
-grpc::GrpcLibraryInterface* grpc::g_glip;
diff --git a/src/cpp/common/completion_queue_cc.cc b/src/cpp/common/completion_queue_cc.cc
index 7a22a48..d42743e 100644
--- a/src/cpp/common/completion_queue_cc.cc
+++ b/src/cpp/common/completion_queue_cc.cc
@@ -130,7 +130,7 @@
// a 'grpc_completion_queue' instance (which is being passed as the input to
// this constructor), one must have already called grpc_init().
CompletionQueue::CompletionQueue(grpc_completion_queue* take)
- : GrpcLibraryCodegen(false), cq_(take) {
+ : GrpcLibrary(false), cq_(take) {
InitialAvalanching();
}
diff --git a/test/core/transport/binder/end2end/binder_server_test.cc b/test/core/transport/binder/end2end/binder_server_test.cc
index 9a310f2..8a73138 100644
--- a/test/core/transport/binder/end2end/binder_server_test.cc
+++ b/test/core/transport/binder/end2end/binder_server_test.cc
@@ -23,7 +23,6 @@
#include "absl/memory/memory.h"
#include <grpcpp/grpcpp.h>
-#include <grpcpp/impl/grpc_library.h>
#include <grpcpp/security/binder_credentials.h>
#include <grpcpp/security/binder_security_policy.h>
@@ -68,8 +67,7 @@
std::shared_ptr<grpc::Channel> CreateBinderChannel(
std::unique_ptr<grpc_binder::Binder> endpoint_binder) {
- grpc::internal::GrpcLibrary init_lib;
- init_lib.init();
+ grpc_init();
return grpc::CreateChannelInternal(
"",
diff --git a/test/core/transport/binder/wire_writer_test.cc b/test/core/transport/binder/wire_writer_test.cc
index 8eb3491..168ed57 100644
--- a/test/core/transport/binder/wire_writer_test.cc
+++ b/test/core/transport/binder/wire_writer_test.cc
@@ -37,7 +37,6 @@
TEST(WireWriterTest, RpcCall) {
grpc::internal::GrpcLibrary init_lib;
- init_lib.init();
// Required because wire writer uses combiner internally.
grpc_core::ExecCtx exec_ctx;
auto mock_binder = std::make_unique<MockBinder>();
@@ -257,7 +256,6 @@
grpc_core::ExecCtx::Get()->Flush();
}
grpc_core::ExecCtx::Get()->Flush();
- init_lib.shutdown();
}
} // namespace grpc_binder
diff --git a/test/cpp/codegen/proto_utils_test.cc b/test/cpp/codegen/proto_utils_test.cc
index 4a3706e..c5eab17 100644
--- a/test/cpp/codegen/proto_utils_test.cc
+++ b/test/cpp/codegen/proto_utils_test.cc
@@ -20,7 +20,6 @@
#include <grpc/impl/codegen/byte_buffer.h>
#include <grpc/slice.h>
-#include <grpcpp/impl/codegen/grpc_library.h>
#include <grpcpp/impl/codegen/proto_utils.h>
#include <grpcpp/impl/grpc_library.h>
@@ -58,7 +57,7 @@
// Ensure the ProtoBufferWriter internals are initialized.
grpc::internal::GrpcLibraryInitializer init;
init.summon();
- grpc::GrpcLibraryCodegen lib;
+ grpc::internal::GrpcLibrary lib;
grpc_init();
}
@@ -155,7 +154,7 @@
static void SetUpTestCase() {
grpc::internal::GrpcLibraryInitializer init;
init.summon();
- grpc::GrpcLibraryCodegen lib;
+ grpc::internal::GrpcLibrary lib;
// Ensure the ProtoBufferWriter internals are initialized.
grpc_init();
}
diff --git a/test/cpp/microbenchmarks/helpers.cc b/test/cpp/microbenchmarks/helpers.cc
index 6e4c7f0..67b2001 100644
--- a/test/cpp/microbenchmarks/helpers.cc
+++ b/test/cpp/microbenchmarks/helpers.cc
@@ -28,13 +28,9 @@
g_libraryInitializer = this;
g_gli_initializer.summon();
- init_lib_.init();
}
-LibraryInitializer::~LibraryInitializer() {
- g_libraryInitializer = nullptr;
- init_lib_.shutdown();
-}
+LibraryInitializer::~LibraryInitializer() { g_libraryInitializer = nullptr; }
LibraryInitializer& LibraryInitializer::get() {
GPR_ASSERT(g_libraryInitializer != nullptr);
diff --git a/test/spm_build/test.cc b/test/spm_build/test.cc
index 2eab4ac..80d0934 100644
--- a/test/spm_build/test.cc
+++ b/test/spm_build/test.cc
@@ -22,7 +22,6 @@
#include "grpcpp/create_channel.h"
#include "grpcpp/generic/generic_stub.h"
#include "grpcpp/grpcpp.h"
-#include "grpcpp/impl/codegen/grpc_library.h"
#include "grpcpp/support/byte_buffer.h"
#include "grpcpp/support/status.h"
#include "grpcpp/support/status_code_enum.h"
diff --git a/tools/doxygen/Doxyfile.c++ b/tools/doxygen/Doxyfile.c++
index 054d8b6..2d664cb 100644
--- a/tools/doxygen/Doxyfile.c++
+++ b/tools/doxygen/Doxyfile.c++
@@ -830,7 +830,6 @@
include/grpc++/impl/codegen/core_codegen.h \
include/grpc++/impl/codegen/core_codegen_interface.h \
include/grpc++/impl/codegen/create_auth_context.h \
-include/grpc++/impl/codegen/grpc_library.h \
include/grpc++/impl/codegen/metadata_map.h \
include/grpc++/impl/codegen/method_handler_impl.h \
include/grpc++/impl/codegen/proto_utils.h \
@@ -983,7 +982,6 @@
include/grpcpp/impl/codegen/core_codegen_interface.h \
include/grpcpp/impl/codegen/create_auth_context.h \
include/grpcpp/impl/codegen/delegating_channel.h \
-include/grpcpp/impl/codegen/grpc_library.h \
include/grpcpp/impl/codegen/intercepted_channel.h \
include/grpcpp/impl/codegen/interceptor.h \
include/grpcpp/impl/codegen/interceptor_common.h \
diff --git a/tools/doxygen/Doxyfile.c++.internal b/tools/doxygen/Doxyfile.c++.internal
index bd769d1..6d68057 100644
--- a/tools/doxygen/Doxyfile.c++.internal
+++ b/tools/doxygen/Doxyfile.c++.internal
@@ -830,7 +830,6 @@
include/grpc++/impl/codegen/core_codegen.h \
include/grpc++/impl/codegen/core_codegen_interface.h \
include/grpc++/impl/codegen/create_auth_context.h \
-include/grpc++/impl/codegen/grpc_library.h \
include/grpc++/impl/codegen/metadata_map.h \
include/grpc++/impl/codegen/method_handler_impl.h \
include/grpc++/impl/codegen/proto_utils.h \
@@ -983,7 +982,6 @@
include/grpcpp/impl/codegen/core_codegen_interface.h \
include/grpcpp/impl/codegen/create_auth_context.h \
include/grpcpp/impl/codegen/delegating_channel.h \
-include/grpcpp/impl/codegen/grpc_library.h \
include/grpcpp/impl/codegen/intercepted_channel.h \
include/grpcpp/impl/codegen/interceptor.h \
include/grpcpp/impl/codegen/interceptor_common.h \
diff --git a/tools/run_tests/sanity/check_deprecated_grpc++.py b/tools/run_tests/sanity/check_deprecated_grpc++.py
index 17bffc5..bf4aaf8 100755
--- a/tools/run_tests/sanity/check_deprecated_grpc++.py
+++ b/tools/run_tests/sanity/check_deprecated_grpc++.py
@@ -68,7 +68,6 @@
"include/grpc++/impl/codegen/call.h",
"include/grpc++/impl/codegen/client_context.h",
"include/grpc++/impl/codegen/service_type.h",
- "include/grpc++/impl/codegen/grpc_library.h",
"include/grpc++/impl/codegen/async_stream.h",
"include/grpc++/impl/codegen/slice.h",
"include/grpc++/impl/codegen/client_unary_call.h",