binder_transport.h
Go to the documentation of this file.
1 // Copyright 2021 gRPC authors.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #ifndef GRPC_CORE_EXT_TRANSPORT_BINDER_TRANSPORT_BINDER_TRANSPORT_H
16 #define GRPC_CORE_EXT_TRANSPORT_BINDER_TRANSPORT_BINDER_TRANSPORT_H
17 
19 
20 #include <atomic>
21 #include <memory>
22 #include <string>
23 #include <utility>
24 #include <vector>
25 
26 #include "absl/container/flat_hash_map.h"
27 
28 #include <grpc/support/log.h>
30 
38 
39 struct grpc_binder_stream;
40 
41 // TODO(mingcl): Consider putting the struct in a namespace (Eventually this
42 // depends on what style we want to follow)
43 // TODO(mingcl): Decide casing for this class name. Should we use C-style class
44 // name here or just go with C++ style?
46  explicit grpc_binder_transport(
47  std::unique_ptr<grpc_binder::Binder> binder, bool is_client,
48  std::shared_ptr<grpc::experimental::binder::SecurityPolicy>
49  security_policy);
51 
53  // TODO(mingcl): Wrap around when all tx codes are used. "If we do detect a
54  // collision however, we will fail the new call with UNAVAILABLE, and shut
55  // down the transport gracefully."
57  return next_free_tx_code++;
58  }
59 
60  grpc_transport base; /* must be first */
61 
62  std::shared_ptr<grpc_binder::TransportStreamReceiver>
65  std::shared_ptr<grpc_binder::WireWriter> wire_writer;
66 
67  bool is_client;
68  // A set of currently registered streams (the key is the stream ID).
71 
72  // The callback and the data for the callback when the stream is connected
73  // between client and server.
74  void (*accept_stream_fn)(void* user_data, grpc_transport* transport,
75  const void* server_data) = nullptr;
76  void* accept_stream_user_data = nullptr;
77 
80 
81  private:
83 };
84 
86  std::unique_ptr<grpc_binder::Binder> endpoint_binder,
87  std::shared_ptr<grpc::experimental::binder::SecurityPolicy>
88  security_policy);
90  std::unique_ptr<grpc_binder::Binder> client_binder,
91  std::shared_ptr<grpc::experimental::binder::SecurityPolicy>
92  security_policy);
93 
94 #endif // GRPC_CORE_EXT_TRANSPORT_BINDER_TRANSPORT_BINDER_TRANSPORT_H
grpc_binder_transport::~grpc_binder_transport
~grpc_binder_transport()
Definition: binder_transport.cc:733
log.h
grpc_binder_transport::base
grpc_transport base
Definition: binder_transport.h:60
grpc_binder_transport::state_tracker
grpc_core::ConnectivityStateTracker state_tracker
Definition: binder_transport.h:78
binder.h
grpc_binder_transport::NewStreamTxCode
int NewStreamTxCode()
Definition: binder_transport.h:52
wire_reader.h
grpc_binder_transport::transport_stream_receiver
std::shared_ptr< grpc_binder::TransportStreamReceiver > transport_stream_receiver
Definition: binder_transport.h:63
grpc_binder_stream
Definition: binder_stream.h:50
binder_security_policy.h
GPR_ASSERT
#define GPR_ASSERT(x)
Definition: include/grpc/impl/codegen/log.h:94
grpc_binder_transport::registered_stream
absl::flat_hash_map< int, grpc_binder_stream * > registered_stream
Definition: binder_transport.h:69
transport
grpc_transport transport
Definition: filter_fuzzer.cc:146
grpc_binder_transport::is_client
bool is_client
Definition: binder_transport.h:67
grpc_binder_transport
Definition: binder_transport.h:45
grpc_binder_transport::grpc_binder_transport
grpc_binder_transport(std::unique_ptr< grpc_binder::Binder > binder, bool is_client, std::shared_ptr< grpc::experimental::binder::SecurityPolicy > security_policy)
Definition: binder_transport.cc:702
grpc_create_binder_transport_client
grpc_transport * grpc_create_binder_transport_client(std::unique_ptr< grpc_binder::Binder > endpoint_binder, std::shared_ptr< grpc::experimental::binder::SecurityPolicy > security_policy)
Definition: binder_transport.cc:737
grpc_create_binder_transport_server
grpc_transport * grpc_create_binder_transport_server(std::unique_ptr< grpc_binder::Binder > client_binder, std::shared_ptr< grpc::experimental::binder::SecurityPolicy > security_policy)
Definition: binder_transport.cc:752
grpc_binder_transport::wire_writer
std::shared_ptr< grpc_binder::WireWriter > wire_writer
Definition: binder_transport.h:65
grpc_binder_transport::combiner
grpc_core::Combiner * combiner
Definition: binder_transport.h:70
grpc_binder_transport::accept_stream_fn
void(* accept_stream_fn)(void *user_data, grpc_transport *transport, const void *server_data)
Definition: binder_transport.h:74
LAST_CALL_TRANSACTION
const int LAST_CALL_TRANSACTION
Definition: binder_constants.cc:22
grpc_core::OrphanablePtr
std::unique_ptr< T, Deleter > OrphanablePtr
Definition: orphanable.h:64
absl::flat_hash_map< int, grpc_binder_stream * >
wire_writer.h
combiner.h
transport_stream_receiver.h
grpc_core::Combiner
Definition: combiner.h:34
grpc_transport
Definition: transport_impl.h:89
transport.h
transport_impl.h
grpc_binder::kFirstCallId
const int kFirstCallId
Definition: binder_constants.cc:26
grpc_binder_transport::next_free_tx_code
std::atomic< int > next_free_tx_code
Definition: binder_transport.h:82
grpc_core::ConnectivityStateTracker
Definition: src/core/lib/transport/connectivity_state.h:97
grpc_core::RefCount
Definition: ref_counted.h:44
grpc_binder_transport::wire_reader
grpc_core::OrphanablePtr< grpc_binder::WireReader > wire_reader
Definition: binder_transport.h:64
grpc_binder_transport::accept_stream_user_data
void * accept_stream_user_data
Definition: binder_transport.h:76
grpc_binder_transport::refs
grpc_core::RefCount refs
Definition: binder_transport.h:79
port_platform.h


grpc
Author(s):
autogenerated on Fri May 16 2025 02:57:48