| 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_SERVER_BINDER_SERVER_H |
| 16 |
#define GRPC_CORE_EXT_TRANSPORT_BINDER_SERVER_BINDER_SERVER_H |
| 17 |
|
| 18 |
#include <grpc/support/port_platform.h> |
| 19 |
|
| 20 |
#include <string> |
| 21 |
|
| 22 |
#include "absl/container/flat_hash_map.h" |
| 23 |
#include "absl/status/status.h" |
| 24 |
|
| 25 |
#include <grpcpp/security/binder_security_policy.h> |
| 26 |
|
| 27 |
#include "src/core/ext/transport/binder/transport/binder_transport.h" |
| 28 |
#include "src/core/ext/transport/binder/wire_format/binder.h" |
| 29 |
#include "src/core/lib/iomgr/exec_ctx.h" |
| 30 |
#include "src/core/lib/surface/server.h" |
| 31 |
#include "src/core/lib/transport/error_utils.h" |
| 32 |
|
| 33 |
// TODO(waynetu): This is part of the public API and should be moved to the |
| 34 |
// include/ folder. |
| 35 |
namespace grpc { |
| 36 |
namespace experimental { |
| 37 |
namespace binder { |
| 38 |
|
| 39 |
void* GetEndpointBinder(const std::string& service); |
| 40 |
void AddEndpointBinder(const std::string& service, void* endpoint_binder); |
| 41 |
void RemoveEndpointBinder(const std::string& service); |
| 42 |
|
| 43 |
} // namespace binder |
| 44 |
} // namespace experimental |
| 45 |
} // namespace grpc |
| 46 |
|
| 47 |
void grpc_add_endpoint_binder(const std::string& service, |
| 48 |
void* endpoint_binder); |
| 49 |
void grpc_remove_endpoint_binder(const std::string& service); |
| 50 |
void* grpc_get_endpoint_binder(const std::string& service); |
| 51 |
|
| 52 |
namespace grpc_core { |
| 53 |
|
| 54 |
// Consume a callback, produce a transaction listener. This is used to perform |
| 55 |
// testing in non-Android environments where the actual binder is not available. |
| 56 |
using BinderTxReceiverFactory = |
| 57 |
std::function<std::unique_ptr<grpc_binder::TransactionReceiver>( |
| 58 |
grpc_binder::TransactionReceiver::OnTransactCb)>; |
| 59 |
|
| 60 |
bool AddBinderPort(const std::string& addr, grpc_server* server, |
| 61 |
BinderTxReceiverFactory factory, |
| 62 |
std::shared_ptr<grpc::experimental::binder::SecurityPolicy> |
| 63 |
security_policy); |
| 64 |
|
| 65 |
} // namespace grpc_core |
| 66 |
|
| 67 |
#endif // GRPC_CORE_EXT_TRANSPORT_BINDER_SERVER_BINDER_SERVER_H |