Remove smart pointers from global registry

reviewable/pr18586/r2
Yash Tibrewal 6 years ago
parent 9bfd2354ec
commit 0c8ef41a5e
  1. 6
      src/core/ext/filters/client_channel/service_config.cc
  2. 13
      src/core/ext/filters/client_channel/service_config.h

@ -34,7 +34,7 @@
namespace grpc_core {
int ServiceConfig::registered_parsers_count = 0;
UniquePtr<ServiceConfigParser>
ServiceConfigParser
ServiceConfig::registered_parsers[ServiceConfigParser::kMaxParsers];
RefCountedPtr<ServiceConfig> ServiceConfig::Create(const char* json) {
@ -85,7 +85,7 @@ void ServiceConfig::ParseGlobalParams(const grpc_json* json_tree,
GPR_DEBUG_ASSERT(json_tree_->key == nullptr);
for (auto i = 0; i < registered_parsers_count; i++) {
auto parsed_obj =
registered_parsers[i]->ParseGlobalParams(json_tree, success);
registered_parsers[i].ParseGlobalParams(json_tree, success);
if (!*success) {
return;
}
@ -102,7 +102,7 @@ bool ServiceConfig::ParseJsonMethodConfigToServiceConfigObjectsTable(
for (auto i = 0; i < registered_parsers_count; i++) {
bool success;
auto parsed_obj =
registered_parsers[i]->ParsePerMethodParams(json, &success);
registered_parsers[i].ParsePerMethodParams(json, &success);
if (!success) {
return false;
}

@ -176,17 +176,12 @@ class ServiceConfig : public RefCounted<ServiceConfig> {
/// registered parser. Each parser is responsible for reading the service
/// config json and returning a parsed object. This parsed object can later be
/// retrieved using the same index that was returned at registration time.
static int RegisterParser(UniquePtr<ServiceConfigParser> func) {
registered_parsers[registered_parsers_count] = std::move(func);
static int RegisterParser(const ServiceConfigParser& parser) {
registered_parsers[registered_parsers_count] = parser;
return registered_parsers_count++;
}
static void ResetServiceConfigParsers() {
for (auto i = 0; i < ServiceConfigParser::kMaxParsers; i++) {
registered_parsers[i].reset(nullptr);
}
registered_parsers_count = 0;
}
static void ResetServiceConfigParsers() { registered_parsers_count = 0; }
private:
// So New() can call our private ctor.
@ -222,7 +217,7 @@ class ServiceConfig : public RefCounted<ServiceConfig> {
size_t* idx);
static int registered_parsers_count;
static UniquePtr<ServiceConfigParser>
static ServiceConfigParser
registered_parsers[ServiceConfigParser::kMaxParsers];
UniquePtr<char> service_config_json_;

Loading…
Cancel
Save