Skip to content

Commit

Permalink
Create gRPC clients for Nearby Identity APIs.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 695626622
  • Loading branch information
suetfei authored and copybara-github committed Nov 14, 2024
1 parent 01a4c79 commit 7f8787f
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 1 deletion.
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_

0 comments on commit 7f8787f

Please sign in to comment.