Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create gRPC clients for Nearby Identity APIs. #3034

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion sharing/flags/generated/nearby_sharing_feature_flags.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ constexpr auto kUpdateTrack =
// Enable the info banner to display duplicate Quick Share apps.
constexpr auto kEnableConflictBanner =
flags::Flag<bool>(kConfigPackage, "45661130", false);
// Enable a persistent BETA label.
// Enable a persistent BETA label across the Quick Share macOS app.
constexpr auto kEnableMacosBetaLabel =
flags::Flag<bool>(kConfigPackage, "45662570", true);

Expand Down
2 changes: 2 additions & 0 deletions sharing/internal/api/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ cc_library(
"bluetooth_adapter.h",
"fast_init_ble_beacon.h",
"fast_initiation_manager.h",
"identity_rpc_client.h",
"network_monitor.h",
"preference_manager.h",
"private_certificate_data.h",
Expand All @@ -40,6 +41,7 @@ cc_library(
deps = [
"//internal/platform:types",
"//internal/platform/implementation:account_manager",
"//proto/identity/v1:rpcs_cc_proto",
"//sharing/analytics",
"//sharing/proto:share_cc_proto",
"@com_google_absl//absl/functional:any_invocable",
Expand Down
61 changes: 61 additions & 0 deletions sharing/internal/api/identity_rpc_client.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
// Copyright 2023 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#ifndef THIRD_PARTY_NEARBY_SHARING_INTERNAL_API_IDENTITY_RPC_CLIENT_H_
#define THIRD_PARTY_NEARBY_SHARING_INTERNAL_API_IDENTITY_RPC_CLIENT_H_

#include <memory>

#include "absl/functional/any_invocable.h"
#include "absl/status/statusor.h"
#include "proto/identity/v1/rpcs.pb.h"

namespace nearby::sharing::api {

// IdentityRpcClient is used to access Nearby Identity backend APIs.
class IdentityRpcClient {
public:
IdentityRpcClient() = default;
virtual ~IdentityRpcClient() = default;

virtual void QuerySharedCredentials(
const google::nearby::identity::v1::QuerySharedCredentialsRequest&
request,
absl::AnyInvocable<
void(const absl::StatusOr<
google::nearby::identity::v1::QuerySharedCredentialsResponse>&
response) &&>
callback) = 0;

virtual void PublishDevice(
const google::nearby::identity::v1::PublishDeviceRequest& request,
absl::AnyInvocable<
void(const absl::StatusOr<google::nearby::identity::v1::
PublishDeviceResponse>& response) &&>
callback) = 0;
};

// Interface for creating IdentityRpcClient instances. Because each
// IdentityRpcClient instance can only be used for one API call, a factory
// makes it easier to make multiple requests in sequence or in parallel.
class IdentityRpcClientFactory {
public:
IdentityRpcClientFactory() = default;
virtual ~IdentityRpcClientFactory() = default;
virtual std::unique_ptr<IdentityRpcClient> CreateInstance() = 0;
};

} // namespace nearby::sharing::api

#endif // THIRD_PARTY_NEARBY_SHARING_INTERNAL_API_IDENTITY_RPC_CLIENT_H_
Loading