aboutsummaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
authorGravatar Alistair Veitch <aveitch@google.com>2015-08-28 11:00:02 -0700
committerGravatar Alistair Veitch <aveitch@google.com>2015-08-28 11:00:02 -0700
commitae7bbfcb92a519c5a97aae51b2e668cb2d75fe67 (patch)
treeda337117b631a1eead2b984719476e42a29e7994 /include
parentb8552024179a2910f10d916e69495779271f9344 (diff)
parent9b1f91e7eac88ba477871a60912cc3b6ed3380ed (diff)
merge to head
Diffstat (limited to 'include')
-rw-r--r--include/grpc++/client_context.h11
-rw-r--r--include/grpc++/create_channel.h6
-rw-r--r--include/grpc++/credentials.h2
-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.h11
-rw-r--r--include/grpc/grpc_security.h34
-rw-r--r--include/grpc/support/time.h3
10 files changed, 74 insertions, 55 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++/create_channel.h b/include/grpc++/create_channel.h
index 0e559ac53e..916f3b0b97 100644
--- a/include/grpc++/create_channel.h
+++ b/include/grpc++/create_channel.h
@@ -44,6 +44,12 @@ namespace grpc {
// If creds does not hold an object or is invalid, a lame channel is returned.
std::shared_ptr<Channel> CreateChannel(
+ const grpc::string& target, const std::shared_ptr<Credentials>& creds);
+
+// For advanced use and testing ONLY. Override default channel arguments only
+// if necessary.
+// If creds does not hold an object or is invalid, a lame channel is returned.
+std::shared_ptr<Channel> CreateCustomChannel(
const grpc::string& target, const std::shared_ptr<Credentials>& creds,
const ChannelArguments& args);
diff --git a/include/grpc++/credentials.h b/include/grpc++/credentials.h
index 71e1f00f15..d623bcef60 100644
--- a/include/grpc++/credentials.h
+++ b/include/grpc++/credentials.h
@@ -57,7 +57,7 @@ class Credentials : public GrpcLibrary {
virtual SecureCredentials* AsSecureCredentials() = 0;
private:
- friend std::shared_ptr<Channel> CreateChannel(
+ friend std::shared_ptr<Channel> CreateCustomChannel(
const grpc::string& target, const std::shared_ptr<Credentials>& creds,
const ChannelArguments& args);
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 101fc88d8f..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 {
@@ -206,8 +214,7 @@ typedef struct grpc_metadata {
/** The following fields are reserved for grpc internal use.
There is no need to initialize them, and they will be set to garbage
- during
- calls to grpc. */
+ during calls to grpc. */
struct {
void *obfuscated[4];
} internal_data;
diff --git a/include/grpc/grpc_security.h b/include/grpc/grpc_security.h
index 7f8f4d4a05..6ee6933207 100644
--- a/include/grpc/grpc_security.h
+++ b/include/grpc/grpc_security.h
@@ -89,16 +89,18 @@ typedef struct {
key and certificate chain. This parameter can be NULL if the client does
not have such a key/cert pair. */
grpc_credentials *grpc_ssl_credentials_create(
- const char *pem_root_certs, grpc_ssl_pem_key_cert_pair *pem_key_cert_pair);
+ const char *pem_root_certs, grpc_ssl_pem_key_cert_pair *pem_key_cert_pair,
+ void *reserved);
/* Creates a composite credentials object. */
grpc_credentials *grpc_composite_credentials_create(grpc_credentials *creds1,
- grpc_credentials *creds2);
+ grpc_credentials *creds2,
+ void *reserved);
/* Creates a compute engine credentials object.
WARNING: Do NOT use this credentials to connect to a non-google service as
this could result in an oauth2 token leak. */
-grpc_credentials *grpc_compute_engine_credentials_create(void);
+grpc_credentials *grpc_compute_engine_credentials_create(void *reserved);
extern const gpr_timespec grpc_max_auth_token_lifetime;
@@ -112,7 +114,8 @@ extern const gpr_timespec grpc_max_auth_token_lifetime;
account credentials. It should not exceed grpc_max_auth_token_lifetime
or will be cropped to this value. */
grpc_credentials *grpc_service_account_credentials_create(
- const char *json_key, const char *scope, gpr_timespec token_lifetime);
+ const char *json_key, const char *scope, gpr_timespec token_lifetime,
+ void *reserved);
/* Creates a JWT credentials object. May return NULL if the input is invalid.
- json_key is the JSON key string containing the client's private key.
@@ -120,7 +123,7 @@ grpc_credentials *grpc_service_account_credentials_create(
this credentials. It should not exceed grpc_max_auth_token_lifetime or
will be cropped to this value. */
grpc_credentials *grpc_service_account_jwt_access_credentials_create(
- const char *json_key, gpr_timespec token_lifetime);
+ const char *json_key, gpr_timespec token_lifetime, void *reserved);
/* Creates an Oauth2 Refresh Token credentials object. May return NULL if the
input is invalid.
@@ -129,32 +132,25 @@ grpc_credentials *grpc_service_account_jwt_access_credentials_create(
- json_refresh_token is the JSON string containing the refresh token itself
along with a client_id and client_secret. */
grpc_credentials *grpc_refresh_token_credentials_create(
- const char *json_refresh_token);
+ const char *json_refresh_token, void *reserved);
/* Creates an Oauth2 Access Token credentials with an access token that was
aquired by an out of band mechanism. */
grpc_credentials *grpc_access_token_credentials_create(
- const char *access_token);
+ const char *access_token, void *reserved);
/* Creates an IAM credentials object. */
grpc_credentials *grpc_iam_credentials_create(const char *authorization_token,
- const char *authority_selector);
+ const char *authority_selector,
+ void *reserved);
/* --- 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,
- const grpc_channel_args *args);
+ const grpc_channel_args *args,
+ void *reserved);
/* --- grpc_server_credentials object. ---
@@ -180,7 +176,7 @@ void grpc_server_credentials_release(grpc_server_credentials *creds);
NULL. */
grpc_server_credentials *grpc_ssl_server_credentials_create(
const char *pem_root_certs, grpc_ssl_pem_key_cert_pair *pem_key_cert_pairs,
- size_t num_key_cert_pairs, int force_client_auth);
+ size_t num_key_cert_pairs, int force_client_auth, void *reserved);
/* --- Server-side secure ports. --- */
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