aboutsummaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/grpc++/client_context.h11
-rw-r--r--include/grpc++/impl/call.h9
-rw-r--r--include/grpc++/server_context.h5
-rw-r--r--include/grpc++/support/auth_context.h7
-rw-r--r--include/grpc++/support/string_ref.h41
-rw-r--r--include/grpc/grpc.h8
-rw-r--r--include/grpc/grpc_security.h9
-rw-r--r--include/grpc/support/time.h3
8 files changed, 51 insertions, 42 deletions
diff --git a/include/grpc++/client_context.h b/include/grpc++/client_context.h
index ee28f360cb..62e5260a18 100644
--- a/include/grpc++/client_context.h
+++ b/include/grpc++/client_context.h
@@ -45,6 +45,7 @@
#include <grpc++/support/auth_context.h>
#include <grpc++/support/config.h>
#include <grpc++/support/status.h>
+#include <grpc++/support/string_ref.h>
#include <grpc++/support/time.h>
struct census_context;
@@ -138,12 +139,14 @@ class ClientContext {
void AddMetadata(const grpc::string& meta_key,
const grpc::string& meta_value);
- const std::multimap<grpc::string, grpc::string>& GetServerInitialMetadata() {
+ const std::multimap<grpc::string_ref, grpc::string_ref>&
+ GetServerInitialMetadata() {
GPR_ASSERT(initial_metadata_received_);
return recv_initial_metadata_;
}
- const std::multimap<grpc::string, grpc::string>& GetServerTrailingMetadata() {
+ const std::multimap<grpc::string_ref, grpc::string_ref>&
+ GetServerTrailingMetadata() {
// TODO(yangg) check finished
return trailing_metadata_;
}
@@ -234,8 +237,8 @@ class ClientContext {
mutable std::shared_ptr<const AuthContext> auth_context_;
struct census_context* census_context_;
std::multimap<grpc::string, grpc::string> send_initial_metadata_;
- std::multimap<grpc::string, grpc::string> recv_initial_metadata_;
- std::multimap<grpc::string, grpc::string> trailing_metadata_;
+ std::multimap<grpc::string_ref, grpc::string_ref> recv_initial_metadata_;
+ std::multimap<grpc::string_ref, grpc::string_ref> trailing_metadata_;
grpc_call* propagate_from_call_;
PropagationOptions propagation_options_;
diff --git a/include/grpc++/impl/call.h b/include/grpc++/impl/call.h
index e5da6c9e2a..fca5603047 100644
--- a/include/grpc++/impl/call.h
+++ b/include/grpc++/impl/call.h
@@ -54,8 +54,9 @@ namespace grpc {
class ByteBuffer;
class Call;
-void FillMetadataMap(grpc_metadata_array* arr,
- std::multimap<grpc::string, grpc::string>* metadata);
+void FillMetadataMap(
+ grpc_metadata_array* arr,
+ std::multimap<grpc::string_ref, grpc::string_ref>* metadata);
grpc_metadata* FillMetadataArray(
const std::multimap<grpc::string, grpc::string>& metadata);
@@ -418,7 +419,7 @@ class CallOpRecvInitialMetadata {
}
private:
- std::multimap<grpc::string, grpc::string>* recv_initial_metadata_;
+ std::multimap<grpc::string_ref, grpc::string_ref>* recv_initial_metadata_;
grpc_metadata_array recv_initial_metadata_arr_;
};
@@ -461,7 +462,7 @@ class CallOpClientRecvStatus {
}
private:
- std::multimap<grpc::string, grpc::string>* recv_trailing_metadata_;
+ std::multimap<grpc::string_ref, grpc::string_ref>* recv_trailing_metadata_;
Status* recv_status_;
grpc_metadata_array recv_trailing_metadata_arr_;
grpc_status_code status_code_;
diff --git a/include/grpc++/server_context.h b/include/grpc++/server_context.h
index ce3cb47a23..4b17a28047 100644
--- a/include/grpc++/server_context.h
+++ b/include/grpc++/server_context.h
@@ -41,6 +41,7 @@
#include <grpc/support/time.h>
#include <grpc++/support/auth_context.h>
#include <grpc++/support/config.h>
+#include <grpc++/support/string_ref.h>
#include <grpc++/support/time.h>
struct gpr_timespec;
@@ -103,7 +104,7 @@ class ServerContext {
bool IsCancelled() const;
- const std::multimap<grpc::string, grpc::string>& client_metadata() {
+ const std::multimap<grpc::string_ref, grpc::string_ref>& client_metadata() {
return client_metadata_;
}
@@ -185,7 +186,7 @@ class ServerContext {
CompletionQueue* cq_;
bool sent_initial_metadata_;
mutable std::shared_ptr<const AuthContext> auth_context_;
- std::multimap<grpc::string, grpc::string> client_metadata_;
+ std::multimap<grpc::string_ref, grpc::string_ref> client_metadata_;
std::multimap<grpc::string, grpc::string> initial_metadata_;
std::multimap<grpc::string, grpc::string> trailing_metadata_;
diff --git a/include/grpc++/support/auth_context.h b/include/grpc++/support/auth_context.h
index f4f2dcf5bb..67e3e66c05 100644
--- a/include/grpc++/support/auth_context.h
+++ b/include/grpc++/support/auth_context.h
@@ -38,6 +38,7 @@
#include <vector>
#include <grpc++/support/config.h>
+#include <grpc++/support/string_ref.h>
struct grpc_auth_context;
struct grpc_auth_property;
@@ -46,7 +47,7 @@ struct grpc_auth_property_iterator;
namespace grpc {
class SecureAuthContext;
-typedef std::pair<grpc::string, grpc::string> AuthProperty;
+typedef std::pair<grpc::string_ref, grpc::string_ref> AuthProperty;
class AuthPropertyIterator
: public std::iterator<std::input_iterator_tag, const AuthProperty> {
@@ -78,11 +79,11 @@ class AuthContext {
// A peer identity, in general is one or more properties (in which case they
// have the same name).
- virtual std::vector<grpc::string> GetPeerIdentity() const = 0;
+ virtual std::vector<grpc::string_ref> GetPeerIdentity() const = 0;
virtual grpc::string GetPeerIdentityPropertyName() const = 0;
// Returns all the property values with the given name.
- virtual std::vector<grpc::string> FindPropertyValues(
+ virtual std::vector<grpc::string_ref> FindPropertyValues(
const grpc::string& name) const = 0;
// Iteration over all the properties.
diff --git a/include/grpc++/support/string_ref.h b/include/grpc++/support/string_ref.h
index 0ec39a9b0a..2bc1fecefe 100644
--- a/include/grpc++/support/string_ref.h
+++ b/include/grpc++/support/string_ref.h
@@ -31,10 +31,11 @@
*
*/
-#ifndef GRPCXX_STRING_REF_H
-#define GRPCXX_STRING_REF_H
+#ifndef GRPCXX_SUPPORT_STRING_REF_H
+#define GRPCXX_SUPPORT_STRING_REF_H
#include <iterator>
+#include <iosfwd>
#include <grpc++/support/config.h>
@@ -43,6 +44,8 @@ namespace grpc {
// This class is a non owning reference to a string.
// It should be a strict subset of the upcoming std::string_ref. See:
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2012/n3442.html
+// The constexpr is dropped or replaced with const for legacy compiler
+// compatibility.
class string_ref {
public:
// types
@@ -50,22 +53,22 @@ class string_ref {
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
// constants
- static constexpr size_t npos = size_t(-1);
+ const static size_t npos = size_t(-1);
// construct/copy.
- constexpr string_ref() : data_(nullptr), length_(0) {}
- constexpr string_ref(const string_ref& other)
+ string_ref() : data_(nullptr), length_(0) {}
+ string_ref(const string_ref& other)
: data_(other.data_), length_(other.length_) {}
string_ref& operator=(const string_ref& rhs);
string_ref(const char* s);
- constexpr string_ref(const char* s, size_t l) : data_(s), length_(l) {}
+ string_ref(const char* s, size_t l) : data_(s), length_(l) {}
string_ref(const grpc::string& s) : data_(s.data()), length_(s.length()) {}
// iterators
- constexpr const_iterator begin() const { return data_; }
- constexpr const_iterator end() const { return data_ + length_; }
- constexpr const_iterator cbegin() const { return data_; }
- constexpr const_iterator cend() const { return data_ + length_; }
+ const_iterator begin() const { return data_; }
+ const_iterator end() const { return data_ + length_; }
+ const_iterator cbegin() const { return data_; }
+ const_iterator cend() const { return data_ + length_; }
const_reverse_iterator rbegin() const {
return const_reverse_iterator(end());
}
@@ -80,10 +83,10 @@ class string_ref {
}
// capacity
- constexpr size_t size() const { return length_; }
- constexpr size_t length() const { return length_; }
- constexpr size_t max_size() const { return length_; }
- constexpr bool empty() const { return length_ == 0; }
+ size_t size() const { return length_; }
+ size_t length() const { return length_; }
+ size_t max_size() const { return length_; }
+ bool empty() const { return length_ == 0; }
// element access
const char* data() const { return data_; }
@@ -95,9 +98,7 @@ class string_ref {
size_t find(string_ref s) const;
size_t find(char c) const;
- // Defined as constexpr in n3442 but C++11 constexpr semantics do not allow
- // the implementation of this function to comply.
- /* constrexpr */ string_ref substr(size_t pos, size_t n = npos) const;
+ string_ref substr(size_t pos, size_t n = npos) const;
private:
const char* data_;
@@ -112,8 +113,8 @@ bool operator>(string_ref x, string_ref y);
bool operator<=(string_ref x, string_ref y);
bool operator>=(string_ref x, string_ref y);
-} // namespace grpc
-
-#endif // GRPCXX_STRING_REF_H
+std::ostream& operator<<(std::ostream& stream, const string_ref& string);
+} // namespace grpc
+#endif // GRPCXX_SUPPORT_STRING_REF_H
diff --git a/include/grpc/grpc.h b/include/grpc/grpc.h
index 92085a2895..a75f356312 100644
--- a/include/grpc/grpc.h
+++ b/include/grpc/grpc.h
@@ -134,6 +134,14 @@ typedef struct {
/** Secondary user agent: goes at the end of the user-agent metadata
sent on each request */
#define GRPC_ARG_SECONDARY_USER_AGENT_STRING "grpc.secondary_user_agent"
+/* The caller of the secure_channel_create functions may override the target
+ name used for SSL host name checking using this channel argument which is of
+ type GRPC_ARG_STRING. This *should* be used for testing only.
+ If this argument is not specified, the name used for SSL host name checking
+ will be the target parameter (assuming that the secure channel is an SSL
+ channel). If this parameter is specified and the underlying is not an SSL
+ channel, it will just be ignored. */
+#define GRPC_SSL_TARGET_NAME_OVERRIDE_ARG "grpc.ssl_target_name_override"
/** Connectivity state of a channel. */
typedef enum {
diff --git a/include/grpc/grpc_security.h b/include/grpc/grpc_security.h
index 8647078233..049ab3c4be 100644
--- a/include/grpc/grpc_security.h
+++ b/include/grpc/grpc_security.h
@@ -133,15 +133,6 @@ grpc_credentials *grpc_google_iam_credentials_create(
/* --- Secure channel creation. --- */
-/* The caller of the secure_channel_create functions may override the target
- name used for SSL host name checking using this channel argument which is of
- type GRPC_ARG_STRING. This *should* be used for testing only.
- If this argument is not specified, the name used for SSL host name checking
- will be the target parameter (assuming that the secure channel is an SSL
- channel). If this parameter is specified and the underlying is not an SSL
- channel, it will just be ignored. */
-#define GRPC_SSL_TARGET_NAME_OVERRIDE_ARG "grpc.ssl_target_name_override"
-
/* Creates a secure channel using the passed-in credentials. */
grpc_channel *grpc_secure_channel_create(grpc_credentials *creds,
const char *target,
diff --git a/include/grpc/support/time.h b/include/grpc/support/time.h
index 4ef9c76459..f8ed893bc0 100644
--- a/include/grpc/support/time.h
+++ b/include/grpc/support/time.h
@@ -52,6 +52,9 @@ typedef enum {
/* Realtime clock. May jump forwards or backwards. Settable by
the system administrator. Has its epoch at 0:00:00 UTC 1 Jan 1970. */
GPR_CLOCK_REALTIME,
+ /* CPU cycle time obtained by rdtsc instruction on x86 platforms. Epoch
+ undefined. Degrades to GPR_CLOCK_REALTIME on other platforms. */
+ GPR_CLOCK_PRECISE,
/* Unmeasurable clock type: no base, created by taking the difference
between two times */
GPR_TIMESPAN