grpc
src
core
ext
transport
binder
client
connection_id_generator.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_CLIENT_CONNECTION_ID_GENERATOR_H
16
#define GRPC_CORE_EXT_TRANSPORT_BINDER_CLIENT_CONNECTION_ID_GENERATOR_H
17
18
#include <
grpc/support/port_platform.h
>
19
20
#include <map>
21
22
#include "absl/strings/string_view.h"
23
24
#include "
src/core/lib/gprpp/sync.h
"
25
26
namespace
grpc_binder
{
27
28
// Generates somewhat human-readable unique identifiers from package name and
29
// class name. We will generate a Id that only contains unreserved URI
30
// characters (uppercase and lowercase letters, decimal digits, hyphen, period,
31
// underscore, and tilde).
32
class
ConnectionIdGenerator
{
33
public
:
34
std::string
Generate
(
absl::string_view
package_name,
35
absl::string_view
class_name
);
36
37
private
:
38
// Our generated Id need to fit in unix socket path length limit. We use 100
39
// here to be safe.
40
const
size_t
kPathLengthLimit
= 100;
41
42
grpc_core::Mutex
m_
;
43
// Every generated identifier will followed by the value of this counter to
44
// make sure every generated id is unique.
45
int
count_
ABSL_GUARDED_BY
(
m_
);
46
};
47
48
ConnectionIdGenerator
*
GetConnectionIdGenerator
();
49
50
}
// namespace grpc_binder
51
52
#endif // GRPC_CORE_EXT_TRANSPORT_BINDER_CLIENT_CONNECTION_ID_GENERATOR_H
absl::string_view
Definition:
abseil-cpp/absl/strings/string_view.h:167
grpc_binder
Definition:
connection_id_generator.cc:45
testing::internal::string
::std::string string
Definition:
bloaty/third_party/protobuf/third_party/googletest/googletest/include/gtest/internal/gtest-port.h:881
grpc_binder::ConnectionIdGenerator::kPathLengthLimit
const size_t kPathLengthLimit
Definition:
connection_id_generator.h:40
grpc_binder::GetConnectionIdGenerator
ConnectionIdGenerator * GetConnectionIdGenerator()
Definition:
connection_id_generator.cc:64
grpc_binder::ConnectionIdGenerator::Generate
std::string Generate(absl::string_view package_name, absl::string_view class_name)
Definition:
connection_id_generator.cc:47
class_name
static const char * class_name(int dnsclass)
Definition:
adig.c:901
count_
int * count_
Definition:
connectivity_state_test.cc:65
grpc_core::Mutex
Definition:
src/core/lib/gprpp/sync.h:61
grpc_binder::ConnectionIdGenerator
Definition:
connection_id_generator.h:32
grpc_binder::ConnectionIdGenerator::ABSL_GUARDED_BY
int count_ ABSL_GUARDED_BY(m_)
grpc_binder::ConnectionIdGenerator::m_
grpc_core::Mutex m_
Definition:
connection_id_generator.h:42
sync.h
port_platform.h
grpc
Author(s):
autogenerated on Fri May 16 2025 02:58:01