|
|
|
@ -19,21 +19,30 @@ |
|
|
|
|
#include <grpc/support/alloc.h> |
|
|
|
|
#include <grpc/support/log.h> |
|
|
|
|
|
|
|
|
|
#include "src/core/lib/compression/stream_compression.h" |
|
|
|
|
#include "src/core/lib/compression/stream_compression_identity.h" |
|
|
|
|
#include "src/core/lib/iomgr/exec_ctx.h" |
|
|
|
|
#include "src/core/lib/slice/slice_internal.h" |
|
|
|
|
|
|
|
|
|
#define OUTPUT_BLOCK_SIZE (1024) |
|
|
|
|
|
|
|
|
|
/* Singleton context used for all identity streams. */ |
|
|
|
|
static grpc_stream_compression_context identity_ctx = { |
|
|
|
|
.vtable = &grpc_stream_compression_identity_vtable |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
static void grpc_stream_compression_pass_through(grpc_slice_buffer *in, |
|
|
|
|
grpc_slice_buffer *out, |
|
|
|
|
size_t *output_size, |
|
|
|
|
size_t max_output_size) { |
|
|
|
|
if (max_output_size >= in->length) { |
|
|
|
|
*output_size = in->length; |
|
|
|
|
if (output_size) { |
|
|
|
|
*output_size = in->length; |
|
|
|
|
} |
|
|
|
|
grpc_slice_buffer_move_into(in, out); |
|
|
|
|
} else { |
|
|
|
|
*output_size = max_output_size; |
|
|
|
|
if (output_size) { |
|
|
|
|
*output_size = max_output_size; |
|
|
|
|
} |
|
|
|
|
grpc_slice_buffer_move_first(in, max_output_size, out); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -59,7 +68,9 @@ static bool grpc_stream_decompress_identity( |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
grpc_stream_compression_pass_through(in, out, output_size, max_output_size); |
|
|
|
|
*end_of_context = false; |
|
|
|
|
if (end_of_context) { |
|
|
|
|
*end_of_context = false; |
|
|
|
|
} |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -69,7 +80,7 @@ grpc_stream_compression_context_create_identity( |
|
|
|
|
GPR_ASSERT(method == GRPC_STREAM_COMPRESSION_IDENTITY_COMPRESS || |
|
|
|
|
method == GRPC_STREAM_COMPRESSION_IDENTITY_DECOMPRESS); |
|
|
|
|
/* No context needed in this case. Use fake context instead. */ |
|
|
|
|
return (grpc_stream_compression_context *)1; |
|
|
|
|
return (grpc_stream_compression_context *)&identity_ctx; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static void grpc_stream_compression_context_destroy_identity( |
|
|
|
|