Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
Grpc
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
tci-gateway-module
Grpc
Commits
ad9d0c47
Commit
ad9d0c47
authored
10 years ago
by
Craig Tiller
Browse files
Options
Downloads
Patches
Plain Diff
Remove dynamic_cast
parent
42bc87c0
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
include/grpc++/credentials.h
+8
-0
8 additions, 0 deletions
include/grpc++/credentials.h
src/cpp/client/insecure_credentials.cc
+2
-0
2 additions, 0 deletions
src/cpp/client/insecure_credentials.cc
src/cpp/client/secure_credentials.cc
+7
-3
7 additions, 3 deletions
src/cpp/client/secure_credentials.cc
with
17 additions
and
3 deletions
include/grpc++/credentials.h
+
8
−
0
View file @
ad9d0c47
...
...
@@ -42,11 +42,19 @@
namespace
grpc
{
class
ChannelArguments
;
class
ChannelInterface
;
class
SecureCredentials
;
class
Credentials
{
public:
virtual
~
Credentials
();
protected:
friend
std
::
unique_ptr
<
Credentials
>
ComposeCredentials
(
const
std
::
unique_ptr
<
Credentials
>&
creds1
,
const
std
::
unique_ptr
<
Credentials
>&
creds2
);
virtual
SecureCredentials
*
AsSecureCredentials
()
=
0
;
private:
friend
std
::
shared_ptr
<
ChannelInterface
>
CreateChannel
(
const
grpc
::
string
&
target
,
const
std
::
unique_ptr
<
Credentials
>&
creds
,
...
...
This diff is collapsed.
Click to expand it.
src/cpp/client/insecure_credentials.cc
+
2
−
0
View file @
ad9d0c47
...
...
@@ -50,6 +50,8 @@ class InsecureCredentialsImpl final : public Credentials {
args
.
SetChannelArgs
(
&
channel_args
);
return
std
::
shared_ptr
<
ChannelInterface
>
(
new
Channel
(
target
,
grpc_channel_create
(
target
.
c_str
(),
&
channel_args
)));
}
SecureCredentials
*
AsSecureCredentials
()
{
return
nullptr
;
}
};
}
// namespace
...
...
This diff is collapsed.
Click to expand it.
src/cpp/client/secure_credentials.cc
+
7
−
3
View file @
ad9d0c47
...
...
@@ -42,7 +42,6 @@
namespace
grpc
{
namespace
{
class
SecureCredentials
final
:
public
Credentials
{
public:
explicit
SecureCredentials
(
grpc_credentials
*
c_creds
)
:
c_creds_
(
c_creds
)
{}
...
...
@@ -58,10 +57,15 @@ class SecureCredentials final : public Credentials {
grpc_secure_channel_create
(
c_creds_
,
target
.
c_str
(),
&
channel_args
)));
}
SecureCredentials
*
AsSecureCredentials
()
{
return
this
;
}
private
:
grpc_credentials
*
const
c_creds_
;
};
namespace
{
std
::
unique_ptr
<
Credentials
>
WrapCredentials
(
grpc_credentials
*
creds
)
{
return
creds
==
nullptr
?
nullptr
...
...
@@ -116,8 +120,8 @@ std::unique_ptr<Credentials> ComposeCredentials(
// passed in here. This is OK because the underlying C objects (i.e.,
// creds1 and creds2) into grpc_composite_credentials_create will see their
// refcounts incremented.
SecureCredentials
*
s1
=
dynamic_cast
<
SecureCredentials
*>
(
creds1
.
get
()
);
SecureCredentials
*
s2
=
dynamic_cast
<
SecureCredentials
*>
(
creds2
.
get
()
);
SecureCredentials
*
s1
=
creds1
->
As
SecureCredentials
(
);
SecureCredentials
*
s2
=
creds2
->
As
SecureCredentials
(
);
if
(
s1
&&
s2
)
{
return
WrapCredentials
(
grpc_composite_credentials_create
(
s1
->
GetRawCreds
(),
s2
->
GetRawCreds
()));
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment