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 2f5c77e98d.

* More fix

* More fix

* More fix

* Minor fix

* Revert "Minor fix"

This reverts commit 1ee3ae4da1.

* Revert "More fix"

This reverts commit 1fc234896b.

* Revert "More fix"

This reverts commit 851393c0e6.

* Revert "More fix"

This reverts commit ed342a51d0.

* Revert "Fix"

This reverts commit 286ad8e639.
pull/31643/head^2
Cheng-Yu Chung 2 years ago committed by GitHub
parent cf63689276
commit 47b9a57de9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      BUILD
  2. 4
      CMakeLists.txt
  3. 4
      build_autogenerated.yaml
  4. 1
      gRPC-C++.podspec
  5. 28
      include/grpc++/impl/codegen/grpc_library.h
  6. 3
      include/grpcpp/alarm.h
  7. 4
      include/grpcpp/channel.h
  8. 12
      include/grpcpp/completion_queue.h
  9. 67
      include/grpcpp/impl/codegen/grpc_library.h
  10. 25
      include/grpcpp/impl/grpc_library.h
  11. 4
      include/grpcpp/resource_quota.h
  12. 2
      include/grpcpp/security/authorization_policy_provider.h
  13. 6
      include/grpcpp/security/credentials.h
  14. 3
      include/grpcpp/security/server_credentials.h
  15. 1
      include/grpcpp/security/tls_certificate_provider.h
  16. 1
      include/grpcpp/security/tls_certificate_verifier.h
  17. 4
      include/grpcpp/server.h
  18. 3
      src/core/ext/transport/binder/client/channel_create.cc
  19. 4
      src/cpp/client/create_channel.cc
  20. 8
      src/cpp/client/create_channel_posix.cc
  21. 24
      src/cpp/client/secure_credentials.cc
  22. 2
      src/cpp/client/secure_credentials.h
  23. 2
      src/cpp/codegen/codegen_init.cc
  24. 2
      src/cpp/common/completion_queue_cc.cc
  25. 4
      test/core/transport/binder/end2end/binder_server_test.cc
  26. 2
      test/core/transport/binder/wire_writer_test.cc
  27. 5
      test/cpp/codegen/proto_utils_test.cc
  28. 6
      test/cpp/microbenchmarks/helpers.cc
  29. 1
      test/spm_build/test.cc
  30. 2
      tools/doxygen/Doxyfile.c++
  31. 2
      tools/doxygen/Doxyfile.c++.internal
  32. 1
      tools/run_tests/sanity/check_deprecated_grpc++.py

@ -400,7 +400,6 @@ GRPCXX_PUBLIC_HDRS = [
"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 @@ GRPCXX_PUBLIC_HDRS = [
"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",

4
CMakeLists.txt generated

@ -3327,7 +3327,6 @@ foreach(_hdr
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 @@ foreach(_hdr
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 @@ foreach(_hdr
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 @@ foreach(_hdr
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

@ -2704,7 +2704,6 @@ libs:
- 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 @@ libs:
- 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 @@ libs:
- 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 @@ libs:
- 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

1
gRPC-C++.podspec generated

@ -121,7 +121,6 @@ Pod::Spec.new do |s|
'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',

@ -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

@ -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();

@ -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 @@ void ChannelResetConnectionBackoff(Channel* channel);
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;

@ -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 @@ extern CoreCodegenInterface* g_core_codegen_interface;
/// 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.

@ -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

@ -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;

@ -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 @@ namespace grpc {
/// 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);

@ -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 {

@ -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 @@ std::shared_ptr<ChannelCredentials> XdsCredentials(
/// 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 @@ class ChannelCredentials : private grpc::GrpcLibraryCodegen {
/// 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;

@ -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 @@ std::shared_ptr<ServerCredentials> XdsServerCredentials(
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;

@ -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 {

@ -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>

@ -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 @@ class ExternalConnectionAcceptorImpl;
///
/// 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;

@ -99,8 +99,7 @@ std::shared_ptr<grpc::Channel> CreateCustomBinderChannel(
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);

@ -44,7 +44,7 @@ std::shared_ptr<grpc::Channel> CreateCustomChannel(
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::shared_ptr<grpc::Channel> CreateCustomChannelWithInterceptors(
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))

@ -41,22 +41,18 @@ class ChannelArguments;
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::shared_ptr<Channel> CreateCustomInsecureChannelFromFd(
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::shared_ptr<Channel> CreateCustomInsecureChannelWithInterceptorsFromFd(
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 @@ std::shared_ptr<Channel> CreateCustomInsecureChannelWithInterceptorsFromFd(
"", 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;
}

@ -116,14 +116,14 @@ std::shared_ptr<CallCredentials> WrapCallCredentials(
} // 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 @@ std::shared_ptr<CallCredentials> ExternalAccountCredentials(
// 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> StsCredentials(
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 @@ std::shared_ptr<CallCredentials> MetadataCredentialsFromPlugin(
// 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 @@ std::shared_ptr<ChannelCredentials> AltsCredentials(
// 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 @@ std::shared_ptr<ChannelCredentials> TlsCredentials(
// 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 @@ std::shared_ptr<CallCredentials> GoogleComputeEngineCredentials() {
// 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 @@ std::shared_ptr<CallCredentials> ServiceAccountJWTAccessCredentials(
// 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 @@ std::shared_ptr<CallCredentials> GoogleRefreshTokenCredentials(
// 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> AccessTokenCredentials(
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> CompositeCallCredentials(
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));

@ -105,7 +105,7 @@ grpc_sts_credentials_options StsCredentialsCppToCoreOptions(
} // namespace experimental
class MetadataCredentialsPluginWrapper final : private GrpcLibraryCodegen {
class MetadataCredentialsPluginWrapper final : private internal::GrpcLibrary {
public:
static void Destroy(void* wrapper);
static int GetMetadata(

@ -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;

@ -130,7 +130,7 @@ CallbackAlternativeCQ g_callback_alternative_cq;
// 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();
}

@ -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<ServerCredentials> BinderServerCredentials() {
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(
"",

@ -37,7 +37,6 @@ MATCHER_P(StrEqInt8Ptr, target, "") {
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 @@ TEST(WireWriterTest, RpcCall) {
grpc_core::ExecCtx::Get()->Flush();
}
grpc_core::ExecCtx::Get()->Flush();
init_lib.shutdown();
}
} // namespace grpc_binder

@ -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 @@ class ProtoUtilsTest : public ::testing::Test {
// 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 @@ class WriterTest : public ::testing::Test {
static void SetUpTestCase() {
grpc::internal::GrpcLibraryInitializer init;
init.summon();
grpc::GrpcLibraryCodegen lib;
grpc::internal::GrpcLibrary lib;
// Ensure the ProtoBufferWriter internals are initialized.
grpc_init();
}

@ -28,13 +28,9 @@ LibraryInitializer::LibraryInitializer() {
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);

@ -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"

@ -830,7 +830,6 @@ include/grpc++/impl/codegen/config_protobuf.h \
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.h \
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 \

@ -830,7 +830,6 @@ include/grpc++/impl/codegen/config_protobuf.h \
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.h \
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 \

@ -68,7 +68,6 @@ expected_files = [
"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",

Loading…
Cancel
Save