Changes to byte_buffer based on comments.
diff --git a/include/grpc/byte_buffer.h b/include/grpc/byte_buffer.h
index eb9608a..6d08474 100644
--- a/include/grpc/byte_buffer.h
+++ b/include/grpc/byte_buffer.h
@@ -34,45 +34,44 @@
#ifndef GRPC_BYTE_BUFFER_H
#define GRPC_BYTE_BUFFER_H
+#include <grpc/compression.h>
#include <grpc/support/slice_buffer.h>
-typedef enum {
- GRPC_BB_SLICE_BUFFER,
+#ifdef __cplusplus
+extern "C" {
+#endif
- /* Keep the GRPC_BB_COMPRESSED_* entries in the same order as the
- * grpc_compression_algorithm enum entries. */
- GRPC_BB_COMPRESSED_NONE, /* for overriding otherwise compressed channels */
- GRPC_BB_COMPRESSED_DEFLATE,
- GRPC_BB_COMPRESSED_GZIP
+typedef enum {
+ GRPC_BB_RAW
+ /* Future types may include GRPC_BB_PROTOBUF, etc. */
} grpc_byte_buffer_type;
-/* byte buffers are containers for messages passed in from the public api's */
struct grpc_byte_buffer {
grpc_byte_buffer_type type;
union {
- gpr_slice_buffer slice_buffer;
+ struct {
+ grpc_compression_algorithm compression;
+ gpr_slice_buffer slice_buffer;
+ } raw;
} data;
};
typedef struct grpc_byte_buffer grpc_byte_buffer;
-/** Returns the grpc_compression_algorithm enum value for a
- * grpc_byte_buffer_type GRPC_BB_COMPRESSED_* value. */
-#define GRPC_COMPRESS_ALGORITHM_FROM_BB_TYPE(bb_type) \
- (bb_type - GRPC_BB_COMPRESSED_NONE)
+/** Returns a RAW byte buffer instance over the given slices (up to \a nslices).
+ *
+ * Increases the reference count for all \a slices processed. The user is
+ * responsible for invoking grpc_byte_buffer_destroy on the returned instance.*/
+grpc_byte_buffer *grpc_raw_byte_buffer_create(gpr_slice *slices,
+ size_t nslices);
-/** Returns a byte buffer instance over the given slices (up to \a nslices) of
- * \a type type.
+/** Returns a *compressed* RAW byte buffer instance over the given slices (up to
+ * \a nslices). The \a compression argument defines the compression algorithm
+ * used to generate the data in \a slices.
*
- * Increases the reference count for all \a slices processed.
- *
- * The user is responsible for invoking grpc_byte_buffer_destroy on
- * the returned instance. */
-grpc_byte_buffer *grpc_byte_buffer_typed_create(gpr_slice *slices,
- size_t nslices,
- grpc_byte_buffer_type type);
-/** Convenience method for creating GRPC_BB_SLICE_BUFFER byte buffers. \sa
- * grpc_byte_buffer_typed_create */
-grpc_byte_buffer *grpc_byte_buffer_create(gpr_slice *slices, size_t nslices);
+ * Increases the reference count for all \a slices processed. The user is
+ * responsible for invoking grpc_byte_buffer_destroy on the returned instance.*/
+grpc_byte_buffer *grpc_raw_compressed_byte_buffer_create(
+ gpr_slice *slices, size_t nslices, grpc_compression_algorithm compression);
/** Copies input byte buffer \a bb.
*
@@ -104,4 +103,8 @@
int grpc_byte_buffer_reader_next(grpc_byte_buffer_reader *reader,
gpr_slice *slice);
+#ifdef __cplusplus
+}
+#endif
+
#endif /* GRPC_BYTE_BUFFER_H */
diff --git a/include/grpc/byte_buffer_reader.h b/include/grpc/byte_buffer_reader.h
index 3f186da..1ef817c 100644
--- a/include/grpc/byte_buffer_reader.h
+++ b/include/grpc/byte_buffer_reader.h
@@ -37,6 +37,10 @@
#include <grpc/grpc.h>
#include <grpc/byte_buffer.h>
+#ifdef __cplusplus
+extern "C" {
+#endif
+
struct grpc_byte_buffer_reader {
grpc_byte_buffer *buffer_in;
grpc_byte_buffer *buffer_out;
@@ -47,4 +51,8 @@
} current;
};
+#ifdef __cplusplus
+}
+#endif
+
#endif /* GRPC_BYTE_BUFFER_READER_H */
diff --git a/include/grpc/census.h b/include/grpc/census.h
index 5f08c10..b2049b3 100644
--- a/include/grpc/census.h
+++ b/include/grpc/census.h
@@ -40,6 +40,10 @@
#include <grpc/grpc.h>
+#ifdef __cplusplus
+extern "C" {
+#endif
+
/* Identify census functionality that can be enabled via census_initialize(). */
enum census_functions {
CENSUS_NONE = 0, /* Do not enable census. */
@@ -92,4 +96,8 @@
* future census calls will result in undefined behavior. */
void census_context_destroy(census_context *context);
+#ifdef __cplusplus
+}
+#endif
+
#endif /* CENSUS_CENSUS_H */
diff --git a/include/grpc/grpc_security.h b/include/grpc/grpc_security.h
index d7ed2d8..82f8f44 100644
--- a/include/grpc/grpc_security.h
+++ b/include/grpc/grpc_security.h
@@ -34,8 +34,8 @@
#ifndef GRPC_GRPC_SECURITY_H
#define GRPC_GRPC_SECURITY_H
-#include "grpc.h"
-#include "status.h"
+#include <grpc/grpc.h>
+#include <grpc/status.h>
#ifdef __cplusplus
extern "C" {
diff --git a/include/grpc/support/tls_pthread.h b/include/grpc/support/tls_pthread.h
index 67f169d..7c42d08 100644
--- a/include/grpc/support/tls_pthread.h
+++ b/include/grpc/support/tls_pthread.h
@@ -49,6 +49,9 @@
#define gpr_tls_init(tls) GPR_ASSERT(0 == pthread_key_create(&(tls)->key, NULL))
#define gpr_tls_destroy(tls) pthread_key_delete((tls)->key)
+#ifdef __cplusplus
+extern "C"
+#endif
gpr_intptr gpr_tls_set(struct gpr_pthread_thread_local *tls, gpr_intptr value);
#define gpr_tls_get(tls) ((gpr_intptr)pthread_getspecific((tls)->key))