diff options
author | Vijay Pai <vpai@google.com> | 2016-10-18 12:15:08 -0700 |
---|---|---|
committer | Vijay Pai <vpai@google.com> | 2016-10-18 12:15:08 -0700 |
commit | 9fa9315d62c3163a93eeae2b3d3bb70231567b83 (patch) | |
tree | 49968018548e4a294026a9f95b8ea5363efceb0e /include | |
parent | 23c5b812687d0ebb86ed86d64416b232f8771e56 (diff) | |
parent | 948f95b2ce4204f859c867207bd991d30ca17ee7 (diff) |
Merge remote-tracking branch 'upstream/master' into fc_1dstream
Diffstat (limited to 'include')
-rw-r--r-- | include/grpc++/impl/codegen/server_context.h | 2 | ||||
-rw-r--r-- | include/grpc++/test/server_context_test_spouse.h | 67 | ||||
-rw-r--r-- | include/grpc/support/alloc.h | 6 |
3 files changed, 74 insertions, 1 deletions
diff --git a/include/grpc++/impl/codegen/server_context.h b/include/grpc++/impl/codegen/server_context.h index bce8d2c2f8..975f710f13 100644 --- a/include/grpc++/impl/codegen/server_context.h +++ b/include/grpc++/impl/codegen/server_context.h @@ -86,6 +86,7 @@ class ServerInterface; namespace testing { class InteropServerContextInspector; +class ServerContextTestSpouse; } // namespace testing // Interface of server side rpc context. @@ -173,6 +174,7 @@ class ServerContext { private: friend class ::grpc::testing::InteropServerContextInspector; + friend class ::grpc::testing::ServerContextTestSpouse; friend class ::grpc::ServerInterface; friend class ::grpc::Server; template <class W, class R> diff --git a/include/grpc++/test/server_context_test_spouse.h b/include/grpc++/test/server_context_test_spouse.h new file mode 100644 index 0000000000..b2482854b5 --- /dev/null +++ b/include/grpc++/test/server_context_test_spouse.h @@ -0,0 +1,67 @@ +/* + * + * Copyright 2016, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef GRPCXX_TEST_SERVER_CONTEXT_TEST_SPOUSE_H +#define GRPCXX_TEST_SERVER_CONTEXT_TEST_SPOUSE_H + +#include <map> + +#include <grpc++/server_context.h> + +namespace grpc { +namespace testing { + +// A test-only class to access private members and methods of ServerContext. +class ServerContextTestSpouse { + public: + explicit ServerContextTestSpouse(ServerContext* ctx) : ctx_(ctx) {} + + // Inject client metadata to the ServerContext for the test. The test spouse + // must be alive when ServerContext::client_metadata is called. + void AddClientMetadata(const grpc::string& key, const grpc::string& value); + std::multimap<grpc::string, grpc::string> GetInitialMetadata() const { + return ctx_->initial_metadata_; + } + std::multimap<grpc::string, grpc::string> GetTrailingMetadata() const { + return ctx_->trailing_metadata_; + } + + private: + ServerContext* ctx_; // not owned + std::multimap<grpc::string, grpc::string> client_metadata_storage_; +}; + +} // namespace testing +} // namespace grpc + +#endif // GRPCXX_TEST_SERVER_CONTEXT_TEST_SPOUSE_H diff --git a/include/grpc/support/alloc.h b/include/grpc/support/alloc.h index 327a9ff9f0..7209bec014 100644 --- a/include/grpc/support/alloc.h +++ b/include/grpc/support/alloc.h @@ -48,7 +48,11 @@ typedef struct gpr_allocation_functions { void (*free_fn)(void *ptr); } gpr_allocation_functions; -/* malloc, never returns NULL */ +/* malloc. + * If size==0, always returns NULL. Otherwise this function never returns NULL. + * The pointer returned is suitably aligned for any kind of variable it could + * contain. + */ GPRAPI void *gpr_malloc(size_t size); /* free */ GPRAPI void gpr_free(void *ptr); |