Classes | Macros | Typedefs | Enumerations | Functions | Variables
cronet_transport.cc File Reference
#include <grpc/support/port_platform.h>
#include "src/core/ext/transport/cronet/transport/cronet_transport.h"
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <new>
#include <string>
#include <utility>
#include "absl/strings/match.h"
#include "absl/strings/str_cat.h"
#include "absl/strings/str_format.h"
#include "absl/strings/string_view.h"
#include "absl/types/optional.h"
#include "third_party/objective_c/Cronet/bidirectional_stream_c.h"
#include <grpc/slice.h>
#include <grpc/status.h>
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/sync.h>
#include "src/core/ext/transport/chttp2/transport/bin_decoder.h"
#include "src/core/ext/transport/chttp2/transport/bin_encoder.h"
#include "src/core/ext/transport/cronet/transport/cronet_status.h"
#include "src/core/lib/debug/trace.h"
#include "src/core/lib/gprpp/debug_location.h"
#include "src/core/lib/iomgr/closure.h"
#include "src/core/lib/iomgr/endpoint.h"
#include "src/core/lib/iomgr/error.h"
#include "src/core/lib/iomgr/exec_ctx.h"
#include "src/core/lib/iomgr/iomgr_fwd.h"
#include "src/core/lib/iomgr/pollset.h"
#include "src/core/lib/resource_quota/arena.h"
#include "src/core/lib/slice/slice.h"
#include "src/core/lib/slice/slice_buffer.h"
#include "src/core/lib/slice/slice_refcount.h"
#include "src/core/lib/surface/validate_metadata.h"
#include "src/core/lib/transport/metadata_batch.h"
#include "src/core/lib/transport/transport.h"
#include "src/core/lib/transport/transport_impl.h"
Include dependency graph for cronet_transport.cc:

Go to the source code of this file.

Classes

struct  grpc_cronet_transport
 
struct  op_and_state
 
struct  op_state
 
struct  op_storage
 
struct  read_state
 
struct  stream_obj
 
struct  write_state
 

Macros

#define CRONET_LOG(...)
 
#define GRPC_CRONET_STREAM_REF(stream, reason)   grpc_cronet_stream_ref((stream), (reason))
 
#define GRPC_CRONET_STREAM_UNREF(stream, reason)   grpc_cronet_stream_unref((stream), (reason))
 
#define GRPC_FLUSH_READ_SIZE   4096
 
#define GRPC_HEADER_SIZE_IN_BYTES   5
 

Typedefs

typedef struct grpc_cronet_transport grpc_cronet_transport
 

Enumerations

enum  e_op_id {
  OP_SEND_INITIAL_METADATA = 0, OP_SEND_MESSAGE, OP_SEND_TRAILING_METADATA, OP_RECV_MESSAGE,
  OP_RECV_INITIAL_METADATA, OP_RECV_TRAILING_METADATA, OP_CANCEL_ERROR, OP_ON_COMPLETE,
  OP_FAILED, OP_SUCCEEDED, OP_CANCELED, OP_RECV_MESSAGE_AND_ON_COMPLETE,
  OP_READ_REQ_MADE, OP_NUM_OPS
}
 
enum  e_op_result { ACTION_TAKEN_WITH_CALLBACK, ACTION_TAKEN_NO_CALLBACK, NO_ACTION_POSSIBLE }
 

Functions

static void add_to_storage (struct stream_obj *s, grpc_transport_stream_op_batch *op)
 
static void convert_cronet_array_to_metadata (const bidirectional_stream_header_array *header_array, grpc_metadata_batch *mds)
 
static void convert_metadata_to_cronet_headers (grpc_metadata_batch *metadata, const char *host, std::string *pp_url, bidirectional_stream_header **pp_headers, size_t *p_num_headers, const char **method)
 
static void create_grpc_frame (grpc_slice_buffer *write_slice_buffer, char **pp_write_buffer, size_t *p_write_buffer_size, uint32_t flags)
 
static void destroy_stream (grpc_transport *, grpc_stream *gs, grpc_closure *then_schedule_closure)
 
static void destroy_transport (grpc_transport *)
 
static void execute_from_storage (stream_obj *s)
 
static enum e_op_result execute_stream_op (struct op_and_state *oas)
 
static grpc_endpointget_endpoint (grpc_transport *)
 
grpc_transportgrpc_create_cronet_transport (void *engine, const char *target, const grpc_channel_args *args, void *)
 
void grpc_cronet_stream_ref (stream_obj *s, const char *reason)
 
void grpc_cronet_stream_unref (stream_obj *s, const char *reason)
 
static bool header_has_authority (const grpc_metadata_batch *b)
 
static int init_stream (grpc_transport *gt, grpc_stream *gs, grpc_stream_refcount *refcount, const void *, grpc_core::Arena *arena)
 
static grpc_error_handle make_error_with_desc (int error_code, int cronet_internal_error_code, const char *desc)
 
static void null_and_maybe_free_read_buffer (stream_obj *s)
 
static void on_canceled (bidirectional_stream *)
 
static void on_failed (bidirectional_stream *, int)
 
static void on_read_completed (bidirectional_stream *, char *, int)
 
static void on_response_headers_received (bidirectional_stream *, const bidirectional_stream_header_array *, const char *)
 
static void on_response_trailers_received (bidirectional_stream *, const bidirectional_stream_header_array *)
 
static void on_stream_ready (bidirectional_stream *)
 
static void on_succeeded (bidirectional_stream *)
 
static void on_write_completed (bidirectional_stream *, const char *)
 
static bool op_can_be_run (grpc_transport_stream_op_batch *curr_op, struct stream_obj *s, struct op_state *op_state, enum e_op_id op_id)
 
static const char * op_id_string (enum e_op_id i)
 
static const char * op_result_string (enum e_op_result i)
 
static void parse_grpc_header (const uint8_t *data, int *length, bool *compressed)
 
static void perform_op (grpc_transport *, grpc_transport_op *)
 
static void perform_stream_op (grpc_transport *, grpc_stream *gs, grpc_transport_stream_op_batch *op)
 
static void read_grpc_header (stream_obj *s)
 
static void remove_from_storage (struct stream_obj *s, struct op_and_state *oas)
 
static void set_pollset_do_nothing (grpc_transport *, grpc_stream *, grpc_pollset *)
 
static void set_pollset_set_do_nothing (grpc_transport *, grpc_stream *, grpc_pollset_set *)
 

Variables

static bidirectional_stream_callback cronet_callbacks
 
grpc_core::TraceFlag grpc_cronet_trace (false, "cronet")
 
static const grpc_transport_vtable grpc_cronet_vtable
 

Macro Definition Documentation

◆ CRONET_LOG

#define CRONET_LOG (   ...)
Value:
do { \
if (grpc_cronet_trace.enabled()) gpr_log(__VA_ARGS__); \
} while (0)

Definition at line 70 of file cronet_transport.cc.

◆ GRPC_CRONET_STREAM_REF

#define GRPC_CRONET_STREAM_REF (   stream,
  reason 
)    grpc_cronet_stream_ref((stream), (reason))

Definition at line 232 of file cronet_transport.cc.

◆ GRPC_CRONET_STREAM_UNREF

#define GRPC_CRONET_STREAM_UNREF (   stream,
  reason 
)    grpc_cronet_stream_unref((stream), (reason))

Definition at line 234 of file cronet_transport.cc.

◆ GRPC_FLUSH_READ_SIZE

#define GRPC_FLUSH_READ_SIZE   4096

Definition at line 67 of file cronet_transport.cc.

◆ GRPC_HEADER_SIZE_IN_BYTES

#define GRPC_HEADER_SIZE_IN_BYTES   5

Definition at line 66 of file cronet_transport.cc.

Typedef Documentation

◆ grpc_cronet_transport

Definition at line 128 of file cronet_transport.cc.

Enumeration Type Documentation

◆ e_op_id

enum e_op_id
Enumerator
OP_SEND_INITIAL_METADATA 
OP_SEND_MESSAGE 
OP_SEND_TRAILING_METADATA 
OP_RECV_MESSAGE 
OP_RECV_INITIAL_METADATA 
OP_RECV_TRAILING_METADATA 
OP_CANCEL_ERROR 
OP_ON_COMPLETE 
OP_FAILED 
OP_SUCCEEDED 
OP_CANCELED 
OP_RECV_MESSAGE_AND_ON_COMPLETE 
OP_READ_REQ_MADE 
OP_NUM_OPS 

Definition at line 81 of file cronet_transport.cc.

◆ e_op_result

Enumerator
ACTION_TAKEN_WITH_CALLBACK 
ACTION_TAKEN_NO_CALLBACK 
NO_ACTION_POSSIBLE 

Definition at line 75 of file cronet_transport.cc.

Function Documentation

◆ add_to_storage()

static void add_to_storage ( struct stream_obj s,
grpc_transport_stream_op_batch op 
)
static

Definition at line 335 of file cronet_transport.cc.

◆ convert_cronet_array_to_metadata()

static void convert_cronet_array_to_metadata ( const bidirectional_stream_header_array header_array,
grpc_metadata_batch mds 
)
static

Definition at line 416 of file cronet_transport.cc.

◆ convert_metadata_to_cronet_headers()

static void convert_metadata_to_cronet_headers ( grpc_metadata_batch metadata,
const char *  host,
std::string *  pp_url,
bidirectional_stream_header **  pp_headers,
size_t *  p_num_headers,
const char **  method 
)
static

Definition at line 798 of file cronet_transport.cc.

◆ create_grpc_frame()

static void create_grpc_frame ( grpc_slice_buffer write_slice_buffer,
char **  pp_write_buffer,
size_t *  p_write_buffer_size,
uint32_t  flags 
)
static

Definition at line 685 of file cronet_transport.cc.

◆ destroy_stream()

static void destroy_stream ( grpc_transport ,
grpc_stream gs,
grpc_closure then_schedule_closure 
)
static

Definition at line 1449 of file cronet_transport.cc.

◆ destroy_transport()

static void destroy_transport ( grpc_transport )
static

Definition at line 1457 of file cronet_transport.cc.

◆ execute_from_storage()

static void execute_from_storage ( stream_obj s)
static

Definition at line 393 of file cronet_transport.cc.

◆ execute_stream_op()

static enum e_op_result execute_stream_op ( struct op_and_state oas)
static

Definition at line 1031 of file cronet_transport.cc.

◆ get_endpoint()

static grpc_endpoint* get_endpoint ( grpc_transport )
static

Definition at line 1459 of file cronet_transport.cc.

◆ grpc_create_cronet_transport()

grpc_transport* grpc_create_cronet_transport ( void *  engine,
const char *  target,
const grpc_channel_args args,
void *   
)

Definition at line 1476 of file cronet_transport.cc.

◆ grpc_cronet_stream_ref()

void grpc_cronet_stream_ref ( stream_obj s,
const char *  reason 
)

Definition at line 236 of file cronet_transport.cc.

◆ grpc_cronet_stream_unref()

void grpc_cronet_stream_unref ( stream_obj s,
const char *  reason 
)

Definition at line 239 of file cronet_transport.cc.

◆ header_has_authority()

static bool header_has_authority ( const grpc_metadata_batch b)
static

Definition at line 819 of file cronet_transport.cc.

◆ init_stream()

static int init_stream ( grpc_transport gt,
grpc_stream gs,
grpc_stream_refcount refcount,
const void *  ,
grpc_core::Arena arena 
)
static

Definition at line 1401 of file cronet_transport.cc.

◆ make_error_with_desc()

static grpc_error_handle make_error_with_desc ( int  error_code,
int  cronet_internal_error_code,
const char *  desc 
)
static

Definition at line 319 of file cronet_transport.cc.

◆ null_and_maybe_free_read_buffer()

static void null_and_maybe_free_read_buffer ( stream_obj s)
static

Definition at line 301 of file cronet_transport.cc.

◆ on_canceled()

static void on_canceled ( bidirectional_stream stream)
static

Definition at line 472 of file cronet_transport.cc.

◆ on_failed()

static void on_failed ( bidirectional_stream stream,
int  net_error 
)
static

Definition at line 444 of file cronet_transport.cc.

◆ on_read_completed()

static void on_read_completed ( bidirectional_stream stream,
char *  data,
int  count 
)
static

Definition at line 605 of file cronet_transport.cc.

◆ on_response_headers_received()

static void on_response_headers_received ( bidirectional_stream stream,
const bidirectional_stream_header_array headers,
const char *  negotiated_protocol 
)
static

Definition at line 547 of file cronet_transport.cc.

◆ on_response_trailers_received()

static void on_response_trailers_received ( bidirectional_stream stream,
const bidirectional_stream_header_array trailers 
)
static

Definition at line 644 of file cronet_transport.cc.

◆ on_stream_ready()

static void on_stream_ready ( bidirectional_stream stream)
static

Definition at line 518 of file cronet_transport.cc.

◆ on_succeeded()

static void on_succeeded ( bidirectional_stream stream)
static

Definition at line 499 of file cronet_transport.cc.

◆ on_write_completed()

static void on_write_completed ( bidirectional_stream stream,
const char *  data 
)
static

Definition at line 587 of file cronet_transport.cc.

◆ op_can_be_run()

static bool op_can_be_run ( grpc_transport_stream_op_batch curr_op,
struct stream_obj s,
struct op_state op_state,
enum e_op_id  op_id 
)
static

Definition at line 827 of file cronet_transport.cc.

◆ op_id_string()

static const char* op_id_string ( enum e_op_id  i)
static

Definition at line 267 of file cronet_transport.cc.

◆ op_result_string()

static const char* op_result_string ( enum e_op_result  i)
static

Definition at line 255 of file cronet_transport.cc.

◆ parse_grpc_header()

static void parse_grpc_header ( const uint8_t data,
int length,
bool compressed 
)
static

Definition at line 807 of file cronet_transport.cc.

◆ perform_op()

static void perform_op ( grpc_transport ,
grpc_transport_op  
)
static

Definition at line 1461 of file cronet_transport.cc.

◆ perform_stream_op()

static void perform_stream_op ( grpc_transport ,
grpc_stream gs,
grpc_transport_stream_op_batch op 
)
static

Definition at line 1415 of file cronet_transport.cc.

◆ read_grpc_header()

static void read_grpc_header ( stream_obj s)
static

Definition at line 309 of file cronet_transport.cc.

◆ remove_from_storage()

static void remove_from_storage ( struct stream_obj s,
struct op_and_state oas 
)
static

Definition at line 359 of file cronet_transport.cc.

◆ set_pollset_do_nothing()

static void set_pollset_do_nothing ( grpc_transport ,
grpc_stream ,
grpc_pollset  
)
static

Definition at line 1408 of file cronet_transport.cc.

◆ set_pollset_set_do_nothing()

static void set_pollset_set_do_nothing ( grpc_transport ,
grpc_stream ,
grpc_pollset_set  
)
static

Definition at line 1411 of file cronet_transport.cc.

Variable Documentation

◆ cronet_callbacks

bidirectional_stream_callback cronet_callbacks
static

◆ grpc_cronet_trace

grpc_core::TraceFlag grpc_cronet_trace(false, "cronet")

◆ grpc_cronet_vtable

const grpc_transport_vtable grpc_cronet_vtable
static
on_failed
static void on_failed(bidirectional_stream *, int)
Definition: cronet_transport.cc:444
set_pollset_set_do_nothing
static void set_pollset_set_do_nothing(grpc_transport *, grpc_stream *, grpc_pollset_set *)
Definition: cronet_transport.cc:1411
get_endpoint
static grpc_endpoint * get_endpoint(grpc_transport *)
Definition: cronet_transport.cc:1459
destroy_stream
static void destroy_stream(grpc_transport *, grpc_stream *gs, grpc_closure *then_schedule_closure)
Definition: cronet_transport.cc:1449
init_stream
static int init_stream(grpc_transport *gt, grpc_stream *gs, grpc_stream_refcount *refcount, const void *, grpc_core::Arena *arena)
Definition: cronet_transport.cc:1401
grpc_cronet_trace
grpc_core::TraceFlag grpc_cronet_trace(false, "cronet")
on_write_completed
static void on_write_completed(bidirectional_stream *, const char *)
Definition: cronet_transport.cc:587
on_succeeded
static void on_succeeded(bidirectional_stream *)
Definition: cronet_transport.cc:499
on_stream_ready
static void on_stream_ready(bidirectional_stream *)
Definition: cronet_transport.cc:518
perform_op
static void perform_op(grpc_transport *, grpc_transport_op *)
Definition: cronet_transport.cc:1461
gpr_log
GPRAPI void gpr_log(const char *file, int line, gpr_log_severity severity, const char *format,...) GPR_PRINT_FORMAT_CHECK(4
destroy_transport
static void destroy_transport(grpc_transport *)
Definition: cronet_transport.cc:1457
on_response_headers_received
static void on_response_headers_received(bidirectional_stream *, const bidirectional_stream_header_array *, const char *)
Definition: cronet_transport.cc:547
on_canceled
static void on_canceled(bidirectional_stream *)
Definition: cronet_transport.cc:472
on_read_completed
static void on_read_completed(bidirectional_stream *, char *, int)
Definition: cronet_transport.cc:605
grpc_core::TraceFlag::enabled
bool enabled()
Definition: debug/trace.h:82
perform_stream_op
static void perform_stream_op(grpc_transport *, grpc_stream *gs, grpc_transport_stream_op_batch *op)
Definition: cronet_transport.cc:1415
on_response_trailers_received
static void on_response_trailers_received(bidirectional_stream *, const bidirectional_stream_header_array *)
Definition: cronet_transport.cc:644
stream_obj
Definition: cronet_transport.cc:203
set_pollset_do_nothing
static void set_pollset_do_nothing(grpc_transport *, grpc_stream *, grpc_pollset *)
Definition: cronet_transport.cc:1408


grpc
Author(s):
autogenerated on Fri May 16 2025 03:01:09