diff options
author | 2015-01-18 14:36:47 -0800 | |
---|---|---|
committer | 2015-01-18 14:36:47 -0800 | |
commit | ecd49345b5c500b9ea1da70b15c90b87da3ff55a (patch) | |
tree | 29afa5d2986d5c85a93e126c1d1f1cd1213d82ab /src/cpp/client | |
parent | cf1d6eb4ae1b48958454259f7e26bee9140cbf65 (diff) |
Use clang-format-3.5
Diffstat (limited to 'src/cpp/client')
-rw-r--r-- | src/cpp/client/channel.cc | 56 | ||||
-rw-r--r-- | src/cpp/client/channel.h | 22 | ||||
-rw-r--r-- | src/cpp/client/channel_arguments.cc | 18 | ||||
-rw-r--r-- | src/cpp/client/client_context.cc | 8 | ||||
-rw-r--r-- | src/cpp/client/create_channel.cc | 8 | ||||
-rw-r--r-- | src/cpp/client/credentials.cc | 40 |
6 files changed, 76 insertions, 76 deletions
diff --git a/src/cpp/client/channel.cc b/src/cpp/client/channel.cc index ddda8c22d6..a8919a10d9 100644 --- a/src/cpp/client/channel.cc +++ b/src/cpp/client/channel.cc @@ -53,7 +53,7 @@ namespace grpc { -Channel::Channel(const grpc::string& target, const ChannelArguments& args) +Channel::Channel(const grpc::string &target, const ChannelArguments &args) : target_(target) { grpc_channel_args channel_args; args.SetChannelArgs(&channel_args); @@ -61,15 +61,15 @@ Channel::Channel(const grpc::string& target, const ChannelArguments& args) target_.c_str(), channel_args.num_args > 0 ? &channel_args : nullptr); } -Channel::Channel(const grpc::string& target, - const std::unique_ptr<Credentials>& creds, - const ChannelArguments& args) +Channel::Channel(const grpc::string &target, + const std::unique_ptr<Credentials> &creds, + const ChannelArguments &args) : target_(args.GetSslTargetNameOverride().empty() ? target : args.GetSslTargetNameOverride()) { grpc_channel_args channel_args; args.SetChannelArgs(&channel_args); - grpc_credentials* c_creds = creds ? creds->GetRawCreds() : nullptr; + grpc_credentials *c_creds = creds ? creds->GetRawCreds() : nullptr; c_channel_ = grpc_secure_channel_create( c_creds, target.c_str(), channel_args.num_args > 0 ? &channel_args : nullptr); @@ -79,9 +79,9 @@ Channel::~Channel() { grpc_channel_destroy(c_channel_); } namespace { // Pluck the finished event and set to status when it is not nullptr. -void GetFinalStatus(grpc_completion_queue* cq, void* finished_tag, - Status* status) { - grpc_event* ev = +void GetFinalStatus(grpc_completion_queue *cq, void *finished_tag, + Status *status) { + grpc_event *ev = grpc_completion_queue_pluck(cq, finished_tag, gpr_inf_future); if (status) { StatusCode error_code = static_cast<StatusCode>(ev->data.finished.status); @@ -94,23 +94,23 @@ void GetFinalStatus(grpc_completion_queue* cq, void* finished_tag, } // namespace // TODO(yangg) more error handling -Status Channel::StartBlockingRpc(const RpcMethod& method, - ClientContext* context, - const google::protobuf::Message& request, - google::protobuf::Message* result) { +Status Channel::StartBlockingRpc(const RpcMethod &method, + ClientContext *context, + const google::protobuf::Message &request, + google::protobuf::Message *result) { Status status; - grpc_call* call = grpc_channel_create_call( + grpc_call *call = grpc_channel_create_call( c_channel_, method.name(), target_.c_str(), context->RawDeadline()); context->set_call(call); - grpc_event* ev; - void* finished_tag = reinterpret_cast<char*>(call); - void* invoke_tag = reinterpret_cast<char*>(call) + 1; - void* metadata_read_tag = reinterpret_cast<char*>(call) + 2; - void* write_tag = reinterpret_cast<char*>(call) + 3; - void* halfclose_tag = reinterpret_cast<char*>(call) + 4; - void* read_tag = reinterpret_cast<char*>(call) + 5; + grpc_event *ev; + void *finished_tag = reinterpret_cast<char *>(call); + void *invoke_tag = reinterpret_cast<char *>(call) + 1; + void *metadata_read_tag = reinterpret_cast<char *>(call) + 2; + void *write_tag = reinterpret_cast<char *>(call) + 3; + void *halfclose_tag = reinterpret_cast<char *>(call) + 4; + void *read_tag = reinterpret_cast<char *>(call) + 5; - grpc_completion_queue* cq = grpc_completion_queue_create(); + grpc_completion_queue *cq = grpc_completion_queue_create(); context->set_cq(cq); // add_metadata from context // @@ -126,7 +126,7 @@ Status Channel::StartBlockingRpc(const RpcMethod& method, return status; } // write request - grpc_byte_buffer* write_buffer = nullptr; + grpc_byte_buffer *write_buffer = nullptr; success = SerializeProto(request, &write_buffer); if (!success) { grpc_call_cancel(call); @@ -172,14 +172,14 @@ Status Channel::StartBlockingRpc(const RpcMethod& method, return status; } -StreamContextInterface* Channel::CreateStream( - const RpcMethod& method, ClientContext* context, - const google::protobuf::Message* request, - google::protobuf::Message* result) { - grpc_call* call = grpc_channel_create_call( +StreamContextInterface *Channel::CreateStream( + const RpcMethod &method, ClientContext *context, + const google::protobuf::Message *request, + google::protobuf::Message *result) { + grpc_call *call = grpc_channel_create_call( c_channel_, method.name(), target_.c_str(), context->RawDeadline()); context->set_call(call); - grpc_completion_queue* cq = grpc_completion_queue_create(); + grpc_completion_queue *cq = grpc_completion_queue_create(); context->set_cq(cq); return new StreamContext(method, context, request, result); } diff --git a/src/cpp/client/channel.h b/src/cpp/client/channel.h index 8de1180ac2..67d18bf4c8 100644 --- a/src/cpp/client/channel.h +++ b/src/cpp/client/channel.h @@ -48,24 +48,24 @@ class StreamContextInterface; class Channel : public ChannelInterface { public: - Channel(const grpc::string& target, const ChannelArguments& args); - Channel(const grpc::string& target, const std::unique_ptr<Credentials>& creds, - const ChannelArguments& args); + Channel(const grpc::string &target, const ChannelArguments &args); + Channel(const grpc::string &target, const std::unique_ptr<Credentials> &creds, + const ChannelArguments &args); ~Channel() override; - Status StartBlockingRpc(const RpcMethod& method, ClientContext* context, - const google::protobuf::Message& request, - google::protobuf::Message* result) override; + Status StartBlockingRpc(const RpcMethod &method, ClientContext *context, + const google::protobuf::Message &request, + google::protobuf::Message *result) override; - StreamContextInterface* CreateStream( - const RpcMethod& method, ClientContext* context, - const google::protobuf::Message* request, - google::protobuf::Message* result) override; + StreamContextInterface *CreateStream( + const RpcMethod &method, ClientContext *context, + const google::protobuf::Message *request, + google::protobuf::Message *result) override; private: const grpc::string target_; - grpc_channel* c_channel_; // owned + grpc_channel *c_channel_; // owned }; } // namespace grpc diff --git a/src/cpp/client/channel_arguments.cc b/src/cpp/client/channel_arguments.cc index eba9c1e76a..70713f015f 100644 --- a/src/cpp/client/channel_arguments.cc +++ b/src/cpp/client/channel_arguments.cc @@ -37,7 +37,7 @@ namespace grpc { -void ChannelArguments::SetSslTargetNameOverride(const grpc::string& name) { +void ChannelArguments::SetSslTargetNameOverride(const grpc::string &name) { SetString(GRPC_SSL_TARGET_NAME_OVERRIDE_ARG, name); } @@ -50,32 +50,32 @@ grpc::string ChannelArguments::GetSslTargetNameOverride() const { return ""; } -void ChannelArguments::SetInt(const grpc::string& key, int value) { +void ChannelArguments::SetInt(const grpc::string &key, int value) { grpc_arg arg; arg.type = GRPC_ARG_INTEGER; strings_.push_back(key); - arg.key = const_cast<char*>(strings_.back().c_str()); + arg.key = const_cast<char *>(strings_.back().c_str()); arg.value.integer = value; args_.push_back(arg); } -void ChannelArguments::SetString(const grpc::string& key, - const grpc::string& value) { +void ChannelArguments::SetString(const grpc::string &key, + const grpc::string &value) { grpc_arg arg; arg.type = GRPC_ARG_STRING; strings_.push_back(key); - arg.key = const_cast<char*>(strings_.back().c_str()); + arg.key = const_cast<char *>(strings_.back().c_str()); strings_.push_back(value); - arg.value.string = const_cast<char*>(strings_.back().c_str()); + arg.value.string = const_cast<char *>(strings_.back().c_str()); args_.push_back(arg); } -void ChannelArguments::SetChannelArgs(grpc_channel_args* channel_args) const { +void ChannelArguments::SetChannelArgs(grpc_channel_args *channel_args) const { channel_args->num_args = args_.size(); if (channel_args->num_args > 0) { - channel_args->args = const_cast<grpc_arg*>(&args_[0]); + channel_args->args = const_cast<grpc_arg *>(&args_[0]); } } diff --git a/src/cpp/client/client_context.cc b/src/cpp/client/client_context.cc index 505b7d89b4..7bda2d07c3 100644 --- a/src/cpp/client/client_context.cc +++ b/src/cpp/client/client_context.cc @@ -50,7 +50,7 @@ ClientContext::~ClientContext() { if (cq_) { grpc_completion_queue_shutdown(cq_); // Drain cq_. - grpc_event* ev; + grpc_event *ev; grpc_completion_type t; do { ev = grpc_completion_queue_next(cq_, gpr_inf_future); @@ -62,7 +62,7 @@ ClientContext::~ClientContext() { } void ClientContext::set_absolute_deadline( - const system_clock::time_point& deadline) { + const system_clock::time_point &deadline) { Timepoint2Timespec(deadline, &absolute_deadline_); } @@ -70,8 +70,8 @@ system_clock::time_point ClientContext::absolute_deadline() { return Timespec2Timepoint(absolute_deadline_); } -void ClientContext::AddMetadata(const grpc::string& meta_key, - const grpc::string& meta_value) { +void ClientContext::AddMetadata(const grpc::string &meta_key, + const grpc::string &meta_value) { return; } diff --git a/src/cpp/client/create_channel.cc b/src/cpp/client/create_channel.cc index 1a88d7f2f1..9cc5cff214 100644 --- a/src/cpp/client/create_channel.cc +++ b/src/cpp/client/create_channel.cc @@ -40,14 +40,14 @@ namespace grpc { class ChannelArguments; -std::shared_ptr<ChannelInterface> CreateChannel(const grpc::string& target, - const ChannelArguments& args) { +std::shared_ptr<ChannelInterface> CreateChannel(const grpc::string &target, + const ChannelArguments &args) { return std::shared_ptr<ChannelInterface>(new Channel(target, args)); } std::shared_ptr<ChannelInterface> CreateChannel( - const grpc::string& target, const std::unique_ptr<Credentials>& creds, - const ChannelArguments& args) { + const grpc::string &target, const std::unique_ptr<Credentials> &creds, + const ChannelArguments &args) { return std::shared_ptr<ChannelInterface>(new Channel(target, creds, args)); } } // namespace grpc diff --git a/src/cpp/client/credentials.cc b/src/cpp/client/credentials.cc index d81cf9f4d0..0955fa28ae 100644 --- a/src/cpp/client/credentials.cc +++ b/src/cpp/client/credentials.cc @@ -40,37 +40,37 @@ namespace grpc { -Credentials::Credentials(grpc_credentials* c_creds) : creds_(c_creds) {} +Credentials::Credentials(grpc_credentials *c_creds) : creds_(c_creds) {} Credentials::~Credentials() { grpc_credentials_release(creds_); } -grpc_credentials* Credentials::GetRawCreds() { return creds_; } +grpc_credentials *Credentials::GetRawCreds() { return creds_; } std::unique_ptr<Credentials> CredentialsFactory::DefaultCredentials() { - grpc_credentials* c_creds = grpc_default_credentials_create(); + grpc_credentials *c_creds = grpc_default_credentials_create(); std::unique_ptr<Credentials> cpp_creds(new Credentials(c_creds)); return cpp_creds; } // Builds SSL Credentials given SSL specific options std::unique_ptr<Credentials> CredentialsFactory::SslCredentials( - const SslCredentialsOptions& options) { - const unsigned char* pem_root_certs = + const SslCredentialsOptions &options) { + const unsigned char *pem_root_certs = options.pem_root_certs.empty() ? nullptr - : reinterpret_cast<const unsigned char*>( + : reinterpret_cast<const unsigned char *>( options.pem_root_certs.c_str()); if (pem_root_certs == nullptr) { return std::unique_ptr<Credentials>(); } - const unsigned char* pem_private_key = + const unsigned char *pem_private_key = options.pem_private_key.empty() ? nullptr - : reinterpret_cast<const unsigned char*>( + : reinterpret_cast<const unsigned char *>( options.pem_private_key.c_str()); - const unsigned char* pem_cert_chain = + const unsigned char *pem_cert_chain = options.pem_cert_chain.empty() ? nullptr - : reinterpret_cast<const unsigned char*>( + : reinterpret_cast<const unsigned char *>( options.pem_cert_chain.c_str()); - grpc_credentials* c_creds = grpc_ssl_credentials_create( + grpc_credentials *c_creds = grpc_ssl_credentials_create( pem_root_certs, options.pem_root_certs.size(), pem_private_key, options.pem_private_key.size(), pem_cert_chain, options.pem_cert_chain.size()); @@ -81,7 +81,7 @@ std::unique_ptr<Credentials> CredentialsFactory::SslCredentials( // Builds credentials for use when running in GCE std::unique_ptr<Credentials> CredentialsFactory::ComputeEngineCredentials() { - grpc_credentials* c_creds = grpc_compute_engine_credentials_create(); + grpc_credentials *c_creds = grpc_compute_engine_credentials_create(); std::unique_ptr<Credentials> cpp_creds( c_creds == nullptr ? nullptr : new Credentials(c_creds)); return cpp_creds; @@ -89,11 +89,11 @@ std::unique_ptr<Credentials> CredentialsFactory::ComputeEngineCredentials() { // Builds service account credentials. std::unique_ptr<Credentials> CredentialsFactory::ServiceAccountCredentials( - const grpc::string& json_key, const grpc::string& scope, + const grpc::string &json_key, const grpc::string &scope, std::chrono::seconds token_lifetime) { gpr_timespec lifetime = gpr_time_from_seconds( token_lifetime.count() > 0 ? token_lifetime.count() : 0); - grpc_credentials* c_creds = grpc_service_account_credentials_create( + grpc_credentials *c_creds = grpc_service_account_credentials_create( json_key.c_str(), scope.c_str(), lifetime); std::unique_ptr<Credentials> cpp_creds( c_creds == nullptr ? nullptr : new Credentials(c_creds)); @@ -102,9 +102,9 @@ std::unique_ptr<Credentials> CredentialsFactory::ServiceAccountCredentials( // Builds IAM credentials. std::unique_ptr<Credentials> CredentialsFactory::IAMCredentials( - const grpc::string& authorization_token, - const grpc::string& authority_selector) { - grpc_credentials* c_creds = grpc_iam_credentials_create( + const grpc::string &authorization_token, + const grpc::string &authority_selector) { + grpc_credentials *c_creds = grpc_iam_credentials_create( authorization_token.c_str(), authority_selector.c_str()); std::unique_ptr<Credentials> cpp_creds( c_creds == nullptr ? nullptr : new Credentials(c_creds)); @@ -113,13 +113,13 @@ std::unique_ptr<Credentials> CredentialsFactory::IAMCredentials( // Combines two credentials objects into a composite credentials. std::unique_ptr<Credentials> CredentialsFactory::ComposeCredentials( - const std::unique_ptr<Credentials>& creds1, - const std::unique_ptr<Credentials>& creds2) { + const std::unique_ptr<Credentials> &creds1, + const std::unique_ptr<Credentials> &creds2) { // Note that we are not saving unique_ptrs to the two credentials // passed in here. This is OK because the underlying C objects (i.e., // creds1 and creds2) into grpc_composite_credentials_create will see their // refcounts incremented. - grpc_credentials* c_creds = grpc_composite_credentials_create( + grpc_credentials *c_creds = grpc_composite_credentials_create( creds1->GetRawCreds(), creds2->GetRawCreds()); std::unique_ptr<Credentials> cpp_creds( c_creds == nullptr ? nullptr : new Credentials(c_creds)); |