Fix naming and comment problems

pull/6373/head
Yuchen Zeng 9 years ago
parent 3b8f3354de
commit 7d099a5c90
  1. 2
      include/grpc++/impl/server_builder_plugin.h
  2. 1
      include/grpc++/server_builder.h
  3. 10
      src/cpp/server/server_builder.cc
  4. 18
      test/cpp/end2end/server_builder_plugin_test.cc

@ -64,6 +64,4 @@ class ServerBuilderPlugin {
} // namespace grpc
#endif // GRPCXX_IMPL_SERVER_BUILDER_PLUGIN_H

@ -113,6 +113,7 @@ class ServerBuilder {
/// Return a running server which is ready for processing calls.
std::unique_ptr<Server> BuildAndStart();
/// For internal use only: Register a ServerBuilderPlugin factory function.
static void InternalAddPluginFactory(
std::unique_ptr<ServerBuilderPlugin> (*CreatePlugin)());

@ -41,18 +41,20 @@
namespace grpc {
static std::vector<std::unique_ptr<ServerBuilderPlugin> (*)()>* plugin_list;
static std::vector<std::unique_ptr<ServerBuilderPlugin> (*)()>*
g_plugin_factory_list;
static gpr_once once_init_plugin_list = GPR_ONCE_INIT;
static void do_plugin_list_init(void) {
plugin_list = new std::vector<std::unique_ptr<ServerBuilderPlugin> (*)()>();
g_plugin_factory_list =
new std::vector<std::unique_ptr<ServerBuilderPlugin> (*)()>();
}
ServerBuilder::ServerBuilder()
: max_message_size_(-1), generic_service_(nullptr) {
grpc_compression_options_init(&compression_options_);
gpr_once_init(&once_init_plugin_list, do_plugin_list_init);
for (auto factory : (*plugin_list)) {
for (auto factory : (*g_plugin_factory_list)) {
std::unique_ptr<ServerBuilderPlugin> plugin = factory();
plugins_[plugin->name()] = std::move(plugin);
}
@ -171,7 +173,7 @@ std::unique_ptr<Server> ServerBuilder::BuildAndStart() {
void ServerBuilder::InternalAddPluginFactory(
std::unique_ptr<ServerBuilderPlugin> (*CreatePlugin)()) {
gpr_once_init(&once_init_plugin_list, do_plugin_list_init);
(*plugin_list).push_back(CreatePlugin);
(*g_plugin_factory_list).push_back(CreatePlugin);
}
} // namespace grpc

@ -115,10 +115,7 @@ class InsertPluginServerBuilderOption : public ServerBuilderOption {
void UpdatePlugins(
std::map<grpc::string, std::unique_ptr<ServerBuilderPlugin>>* plugins)
GRPC_OVERRIDE {
auto it = plugins->begin();
while (it != plugins->end()) {
plugins->erase(it++);
}
plugins->clear();
std::unique_ptr<TestServerBuilderPlugin> plugin(
new TestServerBuilderPlugin());
@ -136,7 +133,7 @@ std::unique_ptr<ServerBuilderPlugin> CreateTestServerBuilderPlugin() {
return std::unique_ptr<ServerBuilderPlugin>(new TestServerBuilderPlugin());
}
void grpc_AddServerBuilderPlugin_reflection() {
void AddTestServerBuilderPlugin() {
static bool already_here = false;
if (already_here) return;
already_here = true;
@ -145,12 +142,13 @@ void grpc_AddServerBuilderPlugin_reflection() {
}
// Force AddServerBuilderPlugin() to be called at static initialization time.
struct StaticPluginInitializer_reflection {
StaticPluginInitializer_reflection() {
grpc_AddServerBuilderPlugin_reflection();
}
} static_plugin_initializer_reflection_;
struct StaticTestPluginInitializer {
StaticTestPluginInitializer() { AddTestServerBuilderPlugin(); }
} static_plugin_initializer_test_;
// When the param boolean is true, the ServerBuilder plugin will be added at the
// time of static initialization. When it's false, the ServerBuilder plugin will
// be added using ServerBuilder::SetOption().
class ServerBuilderPluginTest : public ::testing::TestWithParam<bool> {
public:
ServerBuilderPluginTest() {}

Loading…
Cancel
Save