aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/cpp/ext
diff options
context:
space:
mode:
authorGravatar Yuchen Zeng <zyc@google.com>2016-06-06 14:21:11 -0700
committerGravatar Yuchen Zeng <zyc@google.com>2016-06-06 14:35:51 -0700
commit7ae31a88980cba5e7e0173cad91e62dbfe1b0374 (patch)
tree8156bd4c5a58c2ae55382ef4fdcfd8fac8d13d9d /src/cpp/ext
parent0601df3a04a91e5e731e829989fd93290e301d97 (diff)
Add more comments, fix format issues
Diffstat (limited to 'src/cpp/ext')
-rw-r--r--src/cpp/ext/proto_server_reflection.cc14
-rw-r--r--src/cpp/ext/proto_server_reflection.h22
-rw-r--r--src/cpp/ext/proto_server_reflection_plugin.cc6
3 files changed, 24 insertions, 18 deletions
diff --git a/src/cpp/ext/proto_server_reflection.cc b/src/cpp/ext/proto_server_reflection.cc
index 6e54bc2720..348a035f0f 100644
--- a/src/cpp/ext/proto_server_reflection.cc
+++ b/src/cpp/ext/proto_server_reflection.cc
@@ -131,7 +131,8 @@ Status ProtoServerReflection::GetFileByName(
return Status::CANCELLED;
}
- const protobuf::FileDescriptor* file_desc = descriptor_pool_->FindFileByName(filename);
+ const protobuf::FileDescriptor* file_desc =
+ descriptor_pool_->FindFileByName(filename);
if (file_desc == nullptr) {
return Status(StatusCode::NOT_FOUND, "File not found.");
}
@@ -170,8 +171,9 @@ Status ProtoServerReflection::GetFileContainingExtension(
return Status(StatusCode::NOT_FOUND, "Type not found.");
}
- const protobuf::FieldDescriptor* field_desc = descriptor_pool_->FindExtensionByNumber(
- desc, request->extension_number());
+ const protobuf::FieldDescriptor* field_desc =
+ descriptor_pool_->FindExtensionByNumber(desc,
+ request->extension_number());
if (field_desc == nullptr) {
return Status(StatusCode::NOT_FOUND, "Extension not found.");
}
@@ -187,7 +189,8 @@ Status ProtoServerReflection::GetAllExtensionNumbers(
return Status::CANCELLED;
}
- const protobuf::Descriptor* desc = descriptor_pool_->FindMessageTypeByName(type);
+ const protobuf::Descriptor* desc =
+ descriptor_pool_->FindMessageTypeByName(type);
if (desc == nullptr) {
return Status(StatusCode::NOT_FOUND, "Type not found.");
}
@@ -202,7 +205,8 @@ Status ProtoServerReflection::GetAllExtensionNumbers(
}
void ProtoServerReflection::FillFileDescriptorResponse(
- const protobuf::FileDescriptor* file_desc, ServerReflectionResponse* response,
+ const protobuf::FileDescriptor* file_desc,
+ ServerReflectionResponse* response,
std::unordered_set<grpc::string>* seen_files) {
if (seen_files->find(file_desc->name()) != seen_files->end()) {
return;
diff --git a/src/cpp/ext/proto_server_reflection.h b/src/cpp/ext/proto_server_reflection.h
index e7ab1fdf34..23c130513d 100644
--- a/src/cpp/ext/proto_server_reflection.h
+++ b/src/cpp/ext/proto_server_reflection.h
@@ -30,16 +30,14 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
-
-#ifndef GRPC_EXTENSIONS_REFLECTION_PROTO_SERVER_REFLECTION_H
-#define GRPC_EXTENSIONS_REFLECTION_PROTO_SERVER_REFLECTION_H
+#ifndef GRPC_INTERNAL_CPP_EXT_PROTO_SERVER_REFLECTION_H
+#define GRPC_INTERNAL_CPP_EXT_PROTO_SERVER_REFLECTION_H
#include <unordered_set>
#include <vector>
-#include <grpc++/grpc++.h>
-
#include <grpc++/ext/reflection.grpc.pb.h>
+#include <grpc++/grpc++.h>
namespace grpc {
@@ -48,21 +46,23 @@ class ProtoServerReflection GRPC_FINAL
public:
ProtoServerReflection();
+ // Add the full names of registered services
void SetServiceList(const std::vector<grpc::string>* services);
+ // implementation of ServerReflectionInfo(stream ServerReflectionRequest) rpc
+ // in ServerReflection service
Status ServerReflectionInfo(
ServerContext* context,
ServerReaderWriter<reflection::v1alpha::ServerReflectionResponse,
- reflection::v1alpha::ServerReflectionRequest>*
- stream) GRPC_OVERRIDE;
+ reflection::v1alpha::ServerReflectionRequest>* stream)
+ GRPC_OVERRIDE;
private:
Status ListService(ServerContext* context,
reflection::v1alpha::ListServiceResponse* response);
- Status GetFileByName(
- ServerContext* context, const grpc::string& file_name,
- reflection::v1alpha::ServerReflectionResponse* response);
+ Status GetFileByName(ServerContext* context, const grpc::string& file_name,
+ reflection::v1alpha::ServerReflectionResponse* response);
Status GetFileContainingSymbol(
ServerContext* context, const grpc::string& symbol,
@@ -91,4 +91,4 @@ class ProtoServerReflection GRPC_FINAL
} // namespace grpc
-#endif // GRPC_EXTENSIONS_REFLECTION_PROTO_SERVER_REFLECTION_H
+#endif // GRPC_INTERNAL_CPP_EXT_PROTO_SERVER_REFLECTION_H
diff --git a/src/cpp/ext/proto_server_reflection_plugin.cc b/src/cpp/ext/proto_server_reflection_plugin.cc
index becc949359..f31d102a9e 100644
--- a/src/cpp/ext/proto_server_reflection_plugin.cc
+++ b/src/cpp/ext/proto_server_reflection_plugin.cc
@@ -78,16 +78,18 @@ static std::unique_ptr<::grpc::ServerBuilderPlugin> CreateProtoReflection() {
new ProtoServerReflectionPlugin());
}
-static void AddProtoReflectionServerBuilderPlugin() {
+void InitProtoReflectionServerBuilderPlugin() {
static bool already_here = false;
if (already_here) return;
already_here = true;
::grpc::ServerBuilder::InternalAddPluginFactory(&CreateProtoReflection);
}
+// Force InitProtoReflectionServerBuilderPlugin() to be called at static
+// initialization time.
struct StaticProtoReflectionPluginInitializer {
StaticProtoReflectionPluginInitializer() {
- AddProtoReflectionServerBuilderPlugin();
+ InitProtoReflectionServerBuilderPlugin();
}
} static_proto_reflection_plugin_initializer;