aboutsummaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
authorGravatar murgatroid99 <mlumish@google.com>2016-10-19 13:53:21 -0700
committerGravatar murgatroid99 <mlumish@google.com>2016-10-19 13:53:21 -0700
commit59f347e125182a273f32907f28fa09a264763ffc (patch)
treee8f6098abdcf2f741e4833c875d71f4ff6257360 /include
parent583eb9b96f83f8e443ee530d0cc8df9c233a2de9 (diff)
parentee167049f5834950b857d4d24aafd7f0738361fb (diff)
Merge branch 'master' into uv_core_transport
Diffstat (limited to 'include')
-rw-r--r--include/grpc++/impl/codegen/server_context.h2
-rw-r--r--include/grpc++/test/server_context_test_spouse.h67
-rw-r--r--include/grpc/support/alloc.h6
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);