Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
grpc_binder::WireReaderImpl Class Referenceabstract

#include <wire_reader_impl.h>

Inheritance diagram for grpc_binder::WireReaderImpl:
Inheritance graph
[legend]

Public Member Functions

void Orphan () override
 
absl::Status ProcessTransaction (transaction_code_t code, ReadableParcel *parcel, int uid)
 
std::unique_ptr< BinderRecvSetupTransport ()
 
void SendSetupTransport (Binder *binder)
 
std::shared_ptr< WireWriterSetupTransport (std::unique_ptr< Binder > binder) override
 
 WireReaderImpl (std::shared_ptr< TransportStreamReceiver > transport_stream_receiver, bool is_client, std::shared_ptr< grpc::experimental::binder::SecurityPolicy > security_policy, std::function< void()> on_destruct_callback=nullptr)
 
 ~WireReaderImpl () override
 
- Public Member Functions inherited from grpc_binder::WireReader
 ~WireReader () override=default
 
- Public Member Functions inherited from grpc_core::InternallyRefCounted< WireReader >
 InternallyRefCounted (const InternallyRefCounted &)=delete
 
InternallyRefCountedoperator= (const InternallyRefCounted &)=delete
 
- Public Member Functions inherited from grpc_core::Orphanable
Orphanableoperator= (const Orphanable &)=delete
 
 Orphanable (const Orphanable &)=delete
 

Private Member Functions

bool connected_ ABSL_GUARDED_BY (mu_)
 
bool recvd_setup_transport_ ABSL_GUARDED_BY (mu_)
 
absl::flat_hash_map< transaction_code_t, int32_t > expected_seq_num_ ABSL_GUARDED_BY (mu_)
 
absl::flat_hash_map< transaction_code_t, std::string > message_buffer_ ABSL_GUARDED_BY (mu_)
 
int64_t num_incoming_bytes_ ABSL_GUARDED_BY (mu_)=0
 
int64_t num_acknowledged_bytes_ ABSL_GUARDED_BY (mu_)=0
 
absl::Status ProcessStreamingTransaction (transaction_code_t code, ReadableParcel *parcel)
 
absl::Status ProcessStreamingTransactionImpl (transaction_code_t code, ReadableParcel *parcel, int *cancellation_flags) ABSL_EXCLUSIVE_LOCKS_REQUIRED(mu_)
 

Private Attributes

absl::Notification connection_noti_
 
bool is_client_
 
grpc_core::Mutex mu_
 
std::function< void()> on_destruct_callback_
 
std::unique_ptr< Binderother_end_binder_
 
std::shared_ptr< grpc::experimental::binder::SecurityPolicysecurity_policy_
 
std::shared_ptr< TransportStreamReceivertransport_stream_receiver_
 
std::unique_ptr< TransactionReceivertx_receiver_
 
std::shared_ptr< WireWriterwire_writer_
 

Static Private Attributes

static constexpr int64_t kFlowControlAckBytes = 16 * 1024
 

Additional Inherited Members

- Protected Member Functions inherited from grpc_core::InternallyRefCounted< WireReader >
 InternallyRefCounted (const char *trace=nullptr, intptr_t initial_refcount=1)
 
RefCountedPtr< WireReader > Ref () GRPC_MUST_USE_RESULT
 
RefCountedPtr< WireReader > Ref (const DebugLocation &location, const char *reason) GRPC_MUST_USE_RESULT
 
void Unref ()
 
void Unref (const DebugLocation &location, const char *reason)
 
 ~InternallyRefCounted () override=default
 
- Protected Member Functions inherited from grpc_core::Orphanable
 Orphanable ()
 
virtual ~Orphanable ()
 

Detailed Description

Definition at line 35 of file wire_reader_impl.h.

Constructor & Destructor Documentation

◆ WireReaderImpl()

grpc_binder::WireReaderImpl::WireReaderImpl ( std::shared_ptr< TransportStreamReceiver transport_stream_receiver,
bool  is_client,
std::shared_ptr< grpc::experimental::binder::SecurityPolicy security_policy,
std::function< void()>  on_destruct_callback = nullptr 
)

Definition at line 75 of file wire_reader_impl.cc.

◆ ~WireReaderImpl()

grpc_binder::WireReaderImpl::~WireReaderImpl ( )
override

Definition at line 87 of file wire_reader_impl.cc.

Member Function Documentation

◆ ABSL_GUARDED_BY() [1/6]

bool connected_ grpc_binder::WireReaderImpl::ABSL_GUARDED_BY ( mu_  )
private

◆ ABSL_GUARDED_BY() [2/6]

bool recvd_setup_transport_ grpc_binder::WireReaderImpl::ABSL_GUARDED_BY ( mu_  )
private

◆ ABSL_GUARDED_BY() [3/6]

absl::flat_hash_map<transaction_code_t, int32_t> expected_seq_num_ grpc_binder::WireReaderImpl::ABSL_GUARDED_BY ( mu_  )
private

◆ ABSL_GUARDED_BY() [4/6]

absl::flat_hash_map<transaction_code_t, std::string> message_buffer_ grpc_binder::WireReaderImpl::ABSL_GUARDED_BY ( mu_  )
private

◆ ABSL_GUARDED_BY() [5/6]

int64_t num_incoming_bytes_ grpc_binder::WireReaderImpl::ABSL_GUARDED_BY ( mu_  )
privatepure virtual

◆ ABSL_GUARDED_BY() [6/6]

int64_t num_acknowledged_bytes_ grpc_binder::WireReaderImpl::ABSL_GUARDED_BY ( mu_  )
privatepure virtual

◆ Orphan()

void grpc_binder::WireReaderImpl::Orphan ( )
inlineoverridevirtual

Implements grpc_core::Orphanable.

Definition at line 45 of file wire_reader_impl.h.

◆ ProcessStreamingTransaction()

absl::Status grpc_binder::WireReaderImpl::ProcessStreamingTransaction ( transaction_code_t  code,
ReadableParcel parcel 
)
private

Definition at line 254 of file wire_reader_impl.cc.

◆ ProcessStreamingTransactionImpl()

absl::Status grpc_binder::WireReaderImpl::ProcessStreamingTransactionImpl ( transaction_code_t  code,
ReadableParcel parcel,
int cancellation_flags 
)
private

Definition at line 315 of file wire_reader_impl.cc.

◆ ProcessTransaction()

absl::Status grpc_binder::WireReaderImpl::ProcessTransaction ( transaction_code_t  code,
ReadableParcel parcel,
int  uid 
)

Definition at line 153 of file wire_reader_impl.cc.

◆ RecvSetupTransport()

std::unique_ptr< Binder > grpc_binder::WireReaderImpl::RecvSetupTransport ( )

Recv SETUP_TRANSPORT request.

This is the other half of the SETUP_TRANSPORT process. We wait for in-coming SETUP_TRANSPORT request with the "sending" part of a binder from the other end. For client, the message is coming from the trasnaction receiver we just constructed in SendSetupTransport(). For server, we assume that this step is already completed.

Definition at line 144 of file wire_reader_impl.cc.

◆ SendSetupTransport()

void grpc_binder::WireReaderImpl::SendSetupTransport ( Binder binder)

Send SETUP_TRANSPORT request through binder.

This is the one half (for client it's the first half, and for server it's the second) of the SETUP_TRANSPORT negotiation process. First, a new binder is created. We take its "receiving" part and construct the transaction receiver with it, and sends the "sending" part along with the SETUP_TRANSPORT message through binder.

Definition at line 117 of file wire_reader_impl.cc.

◆ SetupTransport()

std::shared_ptr< WireWriter > grpc_binder::WireReaderImpl::SetupTransport ( std::unique_ptr< Binder binder)
overridevirtual

Setup the transport between endpoint binders.

The client and the server both call SetupTransport() when constructing transport.

High-level overview of transaction setup: 0. Client obtains an |endpoint_binder| from the server (in the Android setting, this can be achieved by "binding" to the server APK).

  1. Client creates a binder |client_binder| and hook its on-transaction callback to client's ProcessTransaction(). Client then sends |client_binder| through |endpoint_binder| to server.
  2. Server receives |client_binder| via |endpoint_binder|.
  3. Server creates a binder |server_binder| and hook its on-transaction callback to server's ProcessTransaction(). Server then sends |server_binder| through |client_binder| back to the client.
  4. Client receives |server_binder| via |client_binder|'s on-transaction callback.

The parameter binder here means different things for client nad server. For client, binder refers to |endpoint_binder|, and for server, binder refers to |client_binder|. That is, for server-side transport setup, we assume that the first half of SETUP_TRANSPORT (up to step 2) is already done somewhere else (see test/end2end/binder_transport_test.cc for how it's handled in the testing environment).

Implements grpc_binder::WireReader.

Definition at line 93 of file wire_reader_impl.cc.

Member Data Documentation

◆ connection_noti_

absl::Notification grpc_binder::WireReaderImpl::connection_noti_
private

Definition at line 108 of file wire_reader_impl.h.

◆ is_client_

bool grpc_binder::WireReaderImpl::is_client_
private

Definition at line 120 of file wire_reader_impl.h.

◆ kFlowControlAckBytes

constexpr int64_t grpc_binder::WireReaderImpl::kFlowControlAckBytes = 16 * 1024
staticconstexprprivate

Definition at line 127 of file wire_reader_impl.h.

◆ mu_

grpc_core::Mutex grpc_binder::WireReaderImpl::mu_
private

Definition at line 109 of file wire_reader_impl.h.

◆ on_destruct_callback_

std::function<void()> grpc_binder::WireReaderImpl::on_destruct_callback_
private

Definition at line 124 of file wire_reader_impl.h.

◆ other_end_binder_

std::unique_ptr<Binder> grpc_binder::WireReaderImpl::other_end_binder_
private

Definition at line 114 of file wire_reader_impl.h.

◆ security_policy_

std::shared_ptr<grpc::experimental::binder::SecurityPolicy> grpc_binder::WireReaderImpl::security_policy_
private

Definition at line 121 of file wire_reader_impl.h.

◆ transport_stream_receiver_

std::shared_ptr<TransportStreamReceiver> grpc_binder::WireReaderImpl::transport_stream_receiver_
private

Definition at line 107 of file wire_reader_impl.h.

◆ tx_receiver_

std::unique_ptr<TransactionReceiver> grpc_binder::WireReaderImpl::tx_receiver_
private

Definition at line 119 of file wire_reader_impl.h.

◆ wire_writer_

std::shared_ptr<WireWriter> grpc_binder::WireReaderImpl::wire_writer_
private

Definition at line 132 of file wire_reader_impl.h.


The documentation for this class was generated from the following files:


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