Skip to content

Commit

Permalink
Const correctness for ClientContext and ServerContext getters
Browse files Browse the repository at this point in the history
  • Loading branch information
slash-lib committed Jun 22, 2016
1 parent c9396aa commit 9c578c7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
10 changes: 5 additions & 5 deletions include/grpc++/impl/codegen/client_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ class ClientContext {
///
/// \return A multimap of initial metadata key-value pairs from the server.
const std::multimap<grpc::string_ref, grpc::string_ref>&
GetServerInitialMetadata() {
GetServerInitialMetadata() const {
GPR_CODEGEN_ASSERT(initial_metadata_received_);
return recv_initial_metadata_;
}
Expand All @@ -205,7 +205,7 @@ class ClientContext {
///
/// \return A multimap of metadata trailing key-value pairs from the server.
const std::multimap<grpc::string_ref, grpc::string_ref>&
GetServerTrailingMetadata() {
GetServerTrailingMetadata() const {
// TODO(yangg) check finished
return trailing_metadata_;
}
Expand All @@ -230,13 +230,13 @@ class ClientContext {

#ifndef GRPC_CXX0X_NO_CHRONO
/// Return the deadline for the client call.
std::chrono::system_clock::time_point deadline() {
std::chrono::system_clock::time_point deadline() const {
return Timespec2Timepoint(deadline_);
}
#endif // !GRPC_CXX0X_NO_CHRONO

/// Return a \a gpr_timespec representation of the client call's deadline.
gpr_timespec raw_deadline() { return deadline_; }
gpr_timespec raw_deadline() const { return deadline_; }

/// Set the per call authority header (see
/// https://tools.ietf.org/html/rfc7540#section-8.1.2.3).
Expand Down Expand Up @@ -337,7 +337,7 @@ class ClientContext {
const InputMessage& request,
OutputMessage* result);

grpc_call* call() { return call_; }
grpc_call* call() const { return call_; }
void set_call(grpc_call* call, const std::shared_ptr<Channel>& channel);

uint32_t initial_metadata_flags() const {
Expand Down
7 changes: 4 additions & 3 deletions include/grpc++/impl/codegen/server_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,12 @@ class ServerContext {
~ServerContext();

#ifndef GRPC_CXX0X_NO_CHRONO
std::chrono::system_clock::time_point deadline() {
std::chrono::system_clock::time_point deadline() const {
return Timespec2Timepoint(deadline_);
}
#endif // !GRPC_CXX0X_NO_CHRONO

gpr_timespec raw_deadline() { return deadline_; }
gpr_timespec raw_deadline() const { return deadline_; }

void AddInitialMetadata(const grpc::string& key, const grpc::string& value);
void AddTrailingMetadata(const grpc::string& key, const grpc::string& value);
Expand All @@ -122,7 +122,8 @@ class ServerContext {
// was called.
void TryCancel() const;

const std::multimap<grpc::string_ref, grpc::string_ref>& client_metadata() {
const std::multimap<grpc::string_ref, grpc::string_ref>& client_metadata()
const {
return client_metadata_;
}

Expand Down

0 comments on commit 9c578c7

Please sign in to comment.