mirror of
https://github.com/kidfromjupiter/nearby.git
synced 2026-09-16 15:36:12 -04:00
Remove rpc client from sharing platform.
PiperOrigin-RevId: 878135348
This commit is contained in:
committed by
Copybara-Service
parent
115fa39dd3
commit
f79846c431
@@ -28,7 +28,6 @@ cc_library(
|
||||
"private_certificate_data.h",
|
||||
"public_certificate_database.h",
|
||||
"sharing_platform.h",
|
||||
"sharing_rpc_client.h",
|
||||
"system_info.h",
|
||||
],
|
||||
visibility = [
|
||||
@@ -39,8 +38,6 @@ cc_library(
|
||||
"//sharing:__subpackages__",
|
||||
],
|
||||
deps = [
|
||||
"//google/nearby/identity/v1:binding_cc_proto",
|
||||
"//google/nearby/identity/v1:rpcs_cc_proto",
|
||||
"//internal/base:file_path",
|
||||
"//internal/platform:mac_address",
|
||||
"//internal/platform:types",
|
||||
@@ -59,11 +56,7 @@ cc_library(
|
||||
cc_library(
|
||||
name = "mock_sharing_platform",
|
||||
testonly = True,
|
||||
srcs = [
|
||||
"fake_nearby_share_client.cc",
|
||||
],
|
||||
hdrs = [
|
||||
"fake_nearby_share_client.h",
|
||||
"mock_app_info.h",
|
||||
"mock_bluetooth_adapter.h",
|
||||
"mock_fast_init_ble_beacon.h",
|
||||
@@ -76,7 +69,6 @@ cc_library(
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
":platform",
|
||||
"//google/nearby/identity/v1:binding_cc_proto",
|
||||
"//internal/base:file_path",
|
||||
"//internal/platform:mac_address",
|
||||
"//internal/platform:types",
|
||||
|
||||
@@ -1,203 +0,0 @@
|
||||
// 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.
|
||||
|
||||
#include "sharing/internal/api/fake_nearby_share_client.h"
|
||||
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
|
||||
#include "google/nearby/identity/v1/binding.pb.h"
|
||||
#include "absl/functional/any_invocable.h"
|
||||
#include "absl/status/status.h"
|
||||
#include "absl/status/statusor.h"
|
||||
#include "absl/synchronization/mutex.h"
|
||||
#include "sharing/internal/api/sharing_rpc_client.h"
|
||||
#include "sharing/internal/public/logging.h"
|
||||
#include "sharing/proto/certificate_rpc.pb.h"
|
||||
#include "sharing/proto/contact_rpc.pb.h"
|
||||
#include "sharing/proto/device_rpc.pb.h"
|
||||
|
||||
namespace nearby {
|
||||
namespace sharing {
|
||||
|
||||
using ::google::nearby::identity::v1::GetAccountInfoRequest;
|
||||
using ::google::nearby::identity::v1::GetAccountInfoResponse;
|
||||
using ::google::nearby::identity::v1::PublishDeviceRequest;
|
||||
using ::google::nearby::identity::v1::PublishDeviceResponse;
|
||||
using ::google::nearby::identity::v1::QuerySharedCredentialsRequest;
|
||||
using ::google::nearby::identity::v1::QuerySharedCredentialsResponse;
|
||||
using ::google::nearby::identity::v1::
|
||||
QuerySharedCredentialsWithBindingIdsRequest;
|
||||
using ::google::nearby::identity::v1::
|
||||
QuerySharedCredentialsWithBindingIdsResponse;
|
||||
using ::google::nearby::identity::v1::InitiateBindingRequest;
|
||||
using ::google::nearby::identity::v1::InitiateBindingResponse;
|
||||
using ::google::nearby::identity::v1::JoinBindingRequest;
|
||||
using ::google::nearby::identity::v1::JoinBindingResponse;
|
||||
using ::google::nearby::identity::v1::DeleteBindingRequest;
|
||||
using ::google::nearby::identity::v1::DeleteBindingResponse;
|
||||
|
||||
void FakeNearbyShareClient::ListContactPeople(
|
||||
proto::ListContactPeopleRequest request,
|
||||
absl::AnyInvocable<void(
|
||||
const absl::StatusOr<proto::ListContactPeopleResponse>& response) &&>
|
||||
callback) {
|
||||
absl::MutexLock lock(mutex_);
|
||||
list_contact_people_requests_.emplace_back(request);
|
||||
if (list_contact_people_responses_.empty()) {
|
||||
std::move(callback)(absl::NotFoundError(""));
|
||||
return;
|
||||
}
|
||||
auto response = list_contact_people_responses_[0];
|
||||
list_contact_people_responses_.erase(list_contact_people_responses_.begin());
|
||||
std::move(callback)(response);
|
||||
}
|
||||
|
||||
void FakeNearbyShareClient::InitiateBinding(
|
||||
InitiateBindingRequest request,
|
||||
absl::AnyInvocable<
|
||||
void(const absl::StatusOr<InitiateBindingResponse>& response) &&>
|
||||
callback) {
|
||||
absl::StatusOr<InitiateBindingResponse> response = absl::NotFoundError("");
|
||||
{
|
||||
absl::MutexLock lock(mutex_);
|
||||
initiate_binding_requests_.emplace_back(request);
|
||||
if (!initiate_binding_responses_.empty()) {
|
||||
response = initiate_binding_responses_[0];
|
||||
initiate_binding_responses_.erase(initiate_binding_responses_.begin());
|
||||
}
|
||||
}
|
||||
std::move(callback)(response);
|
||||
}
|
||||
|
||||
void FakeNearbyShareClient::JoinBinding(
|
||||
JoinBindingRequest request,
|
||||
absl::AnyInvocable<
|
||||
void(const absl::StatusOr<JoinBindingResponse>& response) &&>
|
||||
callback) {
|
||||
absl::StatusOr<JoinBindingResponse> response = absl::NotFoundError("");
|
||||
{
|
||||
absl::MutexLock lock(mutex_);
|
||||
join_binding_requests_.emplace_back(request);
|
||||
if (!join_binding_responses_.empty()) {
|
||||
response = join_binding_responses_[0];
|
||||
join_binding_responses_.erase(join_binding_responses_.begin());
|
||||
}
|
||||
}
|
||||
std::move(callback)(response);
|
||||
}
|
||||
|
||||
void FakeNearbyShareClient::DeleteBinding(
|
||||
DeleteBindingRequest request,
|
||||
absl::AnyInvocable<
|
||||
void(const absl::StatusOr<DeleteBindingResponse>& response) &&>
|
||||
callback) {
|
||||
absl::StatusOr<DeleteBindingResponse> response = absl::NotFoundError("");
|
||||
{
|
||||
absl::MutexLock lock(mutex_);
|
||||
delete_binding_requests_.emplace_back(request);
|
||||
if (!delete_binding_responses_.empty()) {
|
||||
response = delete_binding_responses_[0];
|
||||
delete_binding_responses_.erase(delete_binding_responses_.begin());
|
||||
}
|
||||
}
|
||||
std::move(callback)(response);
|
||||
}
|
||||
|
||||
void FakeNearbyIdentityClient::QuerySharedCredentials(
|
||||
QuerySharedCredentialsRequest request,
|
||||
absl::AnyInvocable<
|
||||
void(const absl::StatusOr<QuerySharedCredentialsResponse>& response) &&>
|
||||
callback) {
|
||||
absl::StatusOr<QuerySharedCredentialsResponse> response =
|
||||
absl::NotFoundError("");
|
||||
{
|
||||
absl::MutexLock lock(mutex_);
|
||||
query_shared_credentials_requests_.emplace_back(request);
|
||||
if (!query_shared_credentials_responses_.empty()) {
|
||||
response = query_shared_credentials_responses_[0];
|
||||
query_shared_credentials_responses_.erase(
|
||||
query_shared_credentials_responses_.begin());
|
||||
}
|
||||
}
|
||||
std::move(callback)(response);
|
||||
}
|
||||
|
||||
void FakeNearbyIdentityClient::PublishDevice(
|
||||
PublishDeviceRequest request,
|
||||
absl::AnyInvocable<
|
||||
void(const absl::StatusOr<PublishDeviceResponse>& response) &&>
|
||||
callback) {
|
||||
absl::StatusOr<PublishDeviceResponse> response = absl::NotFoundError("");
|
||||
{
|
||||
absl::MutexLock lock(mutex_);
|
||||
publish_device_requests_.emplace_back(request);
|
||||
if (!publish_device_responses_.empty()) {
|
||||
response = publish_device_responses_[0];
|
||||
publish_device_responses_.erase(publish_device_responses_.begin());
|
||||
}
|
||||
}
|
||||
std::move(callback)(response);
|
||||
}
|
||||
|
||||
void FakeNearbyIdentityClient::GetAccountInfo(
|
||||
GetAccountInfoRequest request,
|
||||
absl::AnyInvocable<
|
||||
void(const absl::StatusOr<GetAccountInfoResponse>& response) &&>
|
||||
callback) {
|
||||
absl::StatusOr<GetAccountInfoResponse> response = absl::NotFoundError("");
|
||||
{
|
||||
absl::MutexLock lock(mutex_);
|
||||
get_account_info_requests_.emplace_back(request);
|
||||
response = get_account_info_response_;
|
||||
}
|
||||
std::move(callback)(response);
|
||||
}
|
||||
|
||||
void FakeNearbyIdentityClient::QuerySharedCredentialsWithBindingIds(
|
||||
QuerySharedCredentialsWithBindingIdsRequest request,
|
||||
absl::AnyInvocable<
|
||||
void(const absl::StatusOr<QuerySharedCredentialsWithBindingIdsResponse>&
|
||||
response) &&>
|
||||
callback) {
|
||||
absl::StatusOr<QuerySharedCredentialsWithBindingIdsResponse> response =
|
||||
absl::NotFoundError("");
|
||||
{
|
||||
absl::MutexLock lock(mutex_);
|
||||
query_shared_credentials_with_binding_ids_requests_.emplace_back(request);
|
||||
if (!query_shared_credentials_with_binding_ids_responses_.empty()) {
|
||||
response = query_shared_credentials_with_binding_ids_responses_[0];
|
||||
query_shared_credentials_with_binding_ids_responses_.erase(
|
||||
query_shared_credentials_with_binding_ids_responses_.begin());
|
||||
}
|
||||
}
|
||||
std::move(callback)(response);
|
||||
}
|
||||
|
||||
std::unique_ptr<nearby::sharing::api::SharingRpcClient>
|
||||
FakeNearbyShareClientFactory::CreateInstance() {
|
||||
auto instance = std::make_unique<FakeNearbyShareClient>();
|
||||
instances_.push_back(instance.get());
|
||||
return instance;
|
||||
}
|
||||
|
||||
std::unique_ptr<nearby::sharing::api::IdentityRpcClient>
|
||||
FakeNearbyShareClientFactory::CreateIdentityInstance() {
|
||||
auto instance = std::make_unique<FakeNearbyIdentityClient>();
|
||||
identity_instances_.push_back(instance.get());
|
||||
return instance;
|
||||
}
|
||||
|
||||
} // namespace sharing
|
||||
} // namespace nearby
|
||||
@@ -1,297 +0,0 @@
|
||||
// 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_FAKE_NEARBY_SHARE_CLIENT_H_
|
||||
#define THIRD_PARTY_NEARBY_SHARING_INTERNAL_API_FAKE_NEARBY_SHARE_CLIENT_H_
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include "absl/base/thread_annotations.h"
|
||||
#include "absl/functional/any_invocable.h"
|
||||
#include "absl/status/statusor.h"
|
||||
#include "absl/synchronization/mutex.h"
|
||||
#include "sharing/internal/api/sharing_rpc_client.h"
|
||||
#include "sharing/proto/certificate_rpc.pb.h"
|
||||
#include "sharing/proto/contact_rpc.pb.h"
|
||||
#include "sharing/proto/device_rpc.pb.h"
|
||||
|
||||
namespace nearby {
|
||||
namespace sharing {
|
||||
|
||||
// A fake implementation of the Nearby Share HTTP client that stores all request
|
||||
// data. Only use in unit tests.
|
||||
class FakeNearbyShareClient : public nearby::sharing::api::SharingRpcClient {
|
||||
public:
|
||||
FakeNearbyShareClient() = default;
|
||||
~FakeNearbyShareClient() override = default;
|
||||
|
||||
std::vector<nearby::sharing::proto::ListContactPeopleRequest>
|
||||
list_contact_people_requests() {
|
||||
absl::MutexLock lock(mutex_);
|
||||
return list_contact_people_requests_;
|
||||
}
|
||||
|
||||
void SetListContactPeopleResponses(
|
||||
std::vector<absl::StatusOr<proto::ListContactPeopleResponse>> responses) {
|
||||
absl::MutexLock lock(mutex_);
|
||||
list_contact_people_responses_ = responses;
|
||||
}
|
||||
|
||||
void ListContactPeople(
|
||||
proto::ListContactPeopleRequest request,
|
||||
absl::AnyInvocable<void(
|
||||
const absl::StatusOr<proto::ListContactPeopleResponse>& response) &&>
|
||||
callback) override;
|
||||
|
||||
std::vector<google::nearby::identity::v1::InitiateBindingRequest>
|
||||
initiate_binding_requests() {
|
||||
absl::MutexLock lock(mutex_);
|
||||
return initiate_binding_requests_;
|
||||
}
|
||||
|
||||
void SetInitiateBindingResponses(
|
||||
std::vector<absl::StatusOr<google::nearby::identity::v1::
|
||||
InitiateBindingResponse>>
|
||||
responses) {
|
||||
absl::MutexLock lock(mutex_);
|
||||
initiate_binding_responses_ = responses;
|
||||
}
|
||||
|
||||
void InitiateBinding(
|
||||
google::nearby::identity::v1::InitiateBindingRequest request,
|
||||
absl::AnyInvocable<
|
||||
void(const absl::StatusOr<google::nearby::identity::v1::
|
||||
InitiateBindingResponse>& response) &&>
|
||||
callback) override;
|
||||
|
||||
std::vector<google::nearby::identity::v1::JoinBindingRequest>
|
||||
join_binding_requests() {
|
||||
absl::MutexLock lock(mutex_);
|
||||
return join_binding_requests_;
|
||||
}
|
||||
|
||||
void SetJoinBindingResponses(
|
||||
std::vector<absl::StatusOr<google::nearby::identity::v1::
|
||||
JoinBindingResponse>>
|
||||
responses) {
|
||||
absl::MutexLock lock(mutex_);
|
||||
join_binding_responses_ = responses;
|
||||
}
|
||||
|
||||
void JoinBinding(
|
||||
google::nearby::identity::v1::JoinBindingRequest request,
|
||||
absl::AnyInvocable<
|
||||
void(const absl::StatusOr<google::nearby::identity::v1::
|
||||
JoinBindingResponse>& response) &&>
|
||||
callback) override;
|
||||
|
||||
std::vector<google::nearby::identity::v1::DeleteBindingRequest>
|
||||
delete_binding_requests() {
|
||||
absl::MutexLock lock(mutex_);
|
||||
return delete_binding_requests_;
|
||||
}
|
||||
|
||||
void SetDeleteBindingResponses(
|
||||
std::vector<absl::StatusOr<google::nearby::identity::v1::
|
||||
DeleteBindingResponse>>
|
||||
responses) {
|
||||
absl::MutexLock lock(mutex_);
|
||||
delete_binding_responses_ = responses;
|
||||
}
|
||||
|
||||
void DeleteBinding(
|
||||
google::nearby::identity::v1::DeleteBindingRequest request,
|
||||
absl::AnyInvocable<
|
||||
void(const absl::StatusOr<google::nearby::identity::v1::
|
||||
DeleteBindingResponse>& response) &&>
|
||||
callback) override;
|
||||
|
||||
private:
|
||||
absl::Mutex mutex_;
|
||||
std::vector<nearby::sharing::proto::ListContactPeopleRequest>
|
||||
list_contact_people_requests_ ABSL_GUARDED_BY(mutex_);
|
||||
std::vector<absl::StatusOr<proto::ListContactPeopleResponse>>
|
||||
list_contact_people_responses_ ABSL_GUARDED_BY(mutex_);
|
||||
std::vector<google::nearby::identity::v1::InitiateBindingRequest>
|
||||
initiate_binding_requests_ ABSL_GUARDED_BY(mutex_);
|
||||
std::vector<
|
||||
absl::StatusOr<google::nearby::identity::v1::InitiateBindingResponse>>
|
||||
initiate_binding_responses_ ABSL_GUARDED_BY(mutex_);
|
||||
std::vector<google::nearby::identity::v1::JoinBindingRequest>
|
||||
join_binding_requests_ ABSL_GUARDED_BY(mutex_);
|
||||
std::vector<absl::StatusOr<google::nearby::identity::v1::JoinBindingResponse>>
|
||||
join_binding_responses_ ABSL_GUARDED_BY(mutex_);
|
||||
std::vector<google::nearby::identity::v1::DeleteBindingRequest>
|
||||
delete_binding_requests_ ABSL_GUARDED_BY(mutex_);
|
||||
std::vector<
|
||||
absl::StatusOr<google::nearby::identity::v1::DeleteBindingResponse>>
|
||||
delete_binding_responses_ ABSL_GUARDED_BY(mutex_);
|
||||
};
|
||||
|
||||
// A fake implementation of the Nearby Identity RPC client that stores all
|
||||
// request data. Only use in unit tests.
|
||||
class FakeNearbyIdentityClient
|
||||
: public nearby::sharing::api::IdentityRpcClient {
|
||||
public:
|
||||
FakeNearbyIdentityClient() = default;
|
||||
~FakeNearbyIdentityClient() override = default;
|
||||
|
||||
std::vector<google::nearby::identity::v1::PublishDeviceRequest>
|
||||
publish_device_requests() ABSL_LOCKS_EXCLUDED(mutex_) {
|
||||
absl::MutexLock lock(mutex_);
|
||||
return publish_device_requests_;
|
||||
}
|
||||
|
||||
std::vector<google::nearby::identity::v1::QuerySharedCredentialsRequest>
|
||||
query_shared_credentials_requests() ABSL_LOCKS_EXCLUDED(mutex_) {
|
||||
absl::MutexLock lock(mutex_);
|
||||
return query_shared_credentials_requests_;
|
||||
}
|
||||
|
||||
void PublishDevice(
|
||||
google::nearby::identity::v1::PublishDeviceRequest request,
|
||||
absl::AnyInvocable<
|
||||
void(const absl::StatusOr<google::nearby::identity::v1::
|
||||
PublishDeviceResponse>& response) &&>
|
||||
callback) ABSL_LOCKS_EXCLUDED(mutex_) override;
|
||||
|
||||
void SetPublishDeviceResponses(
|
||||
std::vector<
|
||||
absl::StatusOr<google::nearby::identity::v1::PublishDeviceResponse>>
|
||||
responses) ABSL_LOCKS_EXCLUDED(mutex_) {
|
||||
absl::MutexLock lock(mutex_);
|
||||
publish_device_responses_ = responses;
|
||||
}
|
||||
|
||||
void QuerySharedCredentials(
|
||||
google::nearby::identity::v1::QuerySharedCredentialsRequest request,
|
||||
absl::AnyInvocable<
|
||||
void(const absl::StatusOr<
|
||||
google::nearby::identity::v1::QuerySharedCredentialsResponse>&
|
||||
response) &&>
|
||||
callback) ABSL_LOCKS_EXCLUDED(mutex_) override;
|
||||
|
||||
void SetQuerySharedCredentialsResponses(
|
||||
std::vector<absl::StatusOr<
|
||||
google::nearby::identity::v1::QuerySharedCredentialsResponse>>
|
||||
responses) ABSL_LOCKS_EXCLUDED(mutex_) {
|
||||
absl::MutexLock lock(mutex_);
|
||||
query_shared_credentials_responses_ = responses;
|
||||
}
|
||||
|
||||
std::vector<google::nearby::identity::v1::GetAccountInfoRequest>
|
||||
get_account_info_requests() ABSL_LOCKS_EXCLUDED(mutex_) {
|
||||
absl::MutexLock lock(mutex_);
|
||||
return get_account_info_requests_;
|
||||
}
|
||||
|
||||
void GetAccountInfo(
|
||||
google::nearby::identity::v1::GetAccountInfoRequest request,
|
||||
absl::AnyInvocable<
|
||||
void(const absl::StatusOr<google::nearby::identity::v1::
|
||||
GetAccountInfoResponse>& response) &&>
|
||||
callback) ABSL_LOCKS_EXCLUDED(mutex_) override;
|
||||
|
||||
void SetGetAccountInfoResponse(
|
||||
absl::StatusOr<google::nearby::identity::v1::GetAccountInfoResponse>
|
||||
response) ABSL_LOCKS_EXCLUDED(mutex_) {
|
||||
absl::MutexLock lock(mutex_);
|
||||
get_account_info_response_ = response;
|
||||
}
|
||||
|
||||
std::vector<google::nearby::identity::v1::
|
||||
QuerySharedCredentialsWithBindingIdsRequest>
|
||||
query_shared_credentials_with_binding_ids_requests()
|
||||
ABSL_LOCKS_EXCLUDED(mutex_) {
|
||||
absl::MutexLock lock(mutex_);
|
||||
return query_shared_credentials_with_binding_ids_requests_;
|
||||
}
|
||||
|
||||
void QuerySharedCredentialsWithBindingIds(
|
||||
google::nearby::identity::v1::QuerySharedCredentialsWithBindingIdsRequest
|
||||
request,
|
||||
absl::AnyInvocable<
|
||||
void(const absl::StatusOr<
|
||||
google::nearby::identity::v1::
|
||||
QuerySharedCredentialsWithBindingIdsResponse>& response) &&>
|
||||
callback) ABSL_LOCKS_EXCLUDED(mutex_) override;
|
||||
|
||||
void SetQuerySharedCredentialsWithBindingIdsResponse(
|
||||
std::vector<absl::StatusOr<
|
||||
google::nearby::identity::v1::
|
||||
QuerySharedCredentialsWithBindingIdsResponse>>
|
||||
responses) ABSL_LOCKS_EXCLUDED(mutex_) {
|
||||
absl::MutexLock lock(mutex_);
|
||||
query_shared_credentials_with_binding_ids_responses_ = responses;
|
||||
}
|
||||
|
||||
private:
|
||||
absl::Mutex mutex_;
|
||||
std::vector<google::nearby::identity::v1::PublishDeviceRequest>
|
||||
publish_device_requests_ ABSL_GUARDED_BY(mutex_);
|
||||
std::vector<
|
||||
absl::StatusOr<google::nearby::identity::v1::PublishDeviceResponse>>
|
||||
publish_device_responses_ ABSL_GUARDED_BY(mutex_);
|
||||
|
||||
std::vector<google::nearby::identity::v1::QuerySharedCredentialsRequest>
|
||||
query_shared_credentials_requests_ ABSL_GUARDED_BY(mutex_);
|
||||
std::vector<absl::StatusOr<
|
||||
google::nearby::identity::v1::QuerySharedCredentialsResponse>>
|
||||
query_shared_credentials_responses_ ABSL_GUARDED_BY(mutex_);
|
||||
|
||||
std::vector<google::nearby::identity::v1::GetAccountInfoRequest>
|
||||
get_account_info_requests_ ABSL_GUARDED_BY(mutex_);
|
||||
absl::StatusOr<google::nearby::identity::v1::GetAccountInfoResponse>
|
||||
get_account_info_response_ ABSL_GUARDED_BY(mutex_);
|
||||
|
||||
std::vector<
|
||||
google::nearby::identity::v1::QuerySharedCredentialsWithBindingIdsRequest>
|
||||
query_shared_credentials_with_binding_ids_requests_
|
||||
ABSL_GUARDED_BY(mutex_);
|
||||
std::vector<absl::StatusOr<google::nearby::identity::v1::
|
||||
QuerySharedCredentialsWithBindingIdsResponse>>
|
||||
query_shared_credentials_with_binding_ids_responses_
|
||||
ABSL_GUARDED_BY(mutex_);
|
||||
};
|
||||
|
||||
class FakeNearbyShareClientFactory
|
||||
: public nearby::sharing::api::SharingRpcClientFactory {
|
||||
public:
|
||||
FakeNearbyShareClientFactory() = default;
|
||||
~FakeNearbyShareClientFactory() override = default;
|
||||
|
||||
public:
|
||||
// Returns all FakeNearbyShareClient instances created by CreateInstance().
|
||||
std::vector<FakeNearbyShareClient*>& instances() { return instances_; }
|
||||
std::vector<FakeNearbyIdentityClient*>& identity_instances() {
|
||||
return identity_instances_;
|
||||
}
|
||||
|
||||
private:
|
||||
// SharingRpcClientFactory:
|
||||
std::unique_ptr<nearby::sharing::api::SharingRpcClient> CreateInstance()
|
||||
override;
|
||||
|
||||
std::unique_ptr<nearby::sharing::api::IdentityRpcClient>
|
||||
CreateIdentityInstance() override;
|
||||
|
||||
std::vector<FakeNearbyShareClient*> instances_;
|
||||
std::vector<FakeNearbyIdentityClient*> identity_instances_;
|
||||
};
|
||||
|
||||
} // namespace sharing
|
||||
} // namespace nearby
|
||||
|
||||
#endif // THIRD_PARTY_NEARBY_SHARING_INTERNAL_API_FAKE_NEARBY_SHARE_CLIENT_H_
|
||||
@@ -22,11 +22,9 @@
|
||||
#include "gmock/gmock.h"
|
||||
#include "absl/strings/string_view.h"
|
||||
#include "internal/base/file_path.h"
|
||||
#include "internal/platform/clock.h"
|
||||
#include "internal/platform/device_info.h"
|
||||
#include "internal/platform/implementation/account_manager.h"
|
||||
#include "internal/platform/task_runner.h"
|
||||
#include "sharing/analytics/analytics_recorder.h"
|
||||
#include "sharing/internal/api/app_info.h"
|
||||
#include "sharing/internal/api/bluetooth_adapter.h"
|
||||
#include "sharing/internal/api/fast_init_ble_beacon.h"
|
||||
@@ -35,7 +33,6 @@
|
||||
#include "sharing/internal/api/preference_manager.h"
|
||||
#include "sharing/internal/api/public_certificate_database.h"
|
||||
#include "sharing/internal/api/sharing_platform.h"
|
||||
#include "sharing/internal/api/sharing_rpc_client.h"
|
||||
#include "sharing/internal/api/system_info.h"
|
||||
|
||||
namespace nearby::sharing::api {
|
||||
@@ -79,11 +76,6 @@ class MockSharingPlatform : public SharingPlatform {
|
||||
MOCK_METHOD(std::unique_ptr<PublicCertificateDatabase>,
|
||||
CreatePublicCertificateDatabase, (const FilePath& database_path),
|
||||
(override));
|
||||
MOCK_METHOD(
|
||||
std::unique_ptr<SharingRpcClientFactory>, CreateSharingRpcClientFactory,
|
||||
(Clock * clock,
|
||||
nearby::sharing::analytics::AnalyticsRecorder* analytics_recorder),
|
||||
(override));
|
||||
MOCK_METHOD(bool, UpdateFileOriginMetadata,
|
||||
(std::vector<FilePath> & file_paths), (override));
|
||||
};
|
||||
|
||||
@@ -21,11 +21,9 @@
|
||||
|
||||
#include "absl/strings/string_view.h"
|
||||
#include "internal/base/file_path.h"
|
||||
#include "internal/platform/clock.h"
|
||||
#include "internal/platform/device_info.h"
|
||||
#include "internal/platform/implementation/account_manager.h"
|
||||
#include "internal/platform/task_runner.h"
|
||||
#include "sharing/analytics/analytics_recorder.h"
|
||||
#include "sharing/internal/api/app_info.h"
|
||||
#include "sharing/internal/api/bluetooth_adapter.h"
|
||||
#include "sharing/internal/api/fast_init_ble_beacon.h"
|
||||
@@ -33,7 +31,6 @@
|
||||
#include "sharing/internal/api/network_monitor.h"
|
||||
#include "sharing/internal/api/preference_manager.h"
|
||||
#include "sharing/internal/api/public_certificate_database.h"
|
||||
#include "sharing/internal/api/sharing_rpc_client.h"
|
||||
#include "sharing/internal/api/system_info.h"
|
||||
|
||||
namespace nearby::sharing::api {
|
||||
@@ -72,11 +69,6 @@ class SharingPlatform {
|
||||
virtual std::unique_ptr<PublicCertificateDatabase>
|
||||
CreatePublicCertificateDatabase(const FilePath& database_path) = 0;
|
||||
|
||||
virtual std::unique_ptr<SharingRpcClientFactory>
|
||||
CreateSharingRpcClientFactory(
|
||||
Clock* clock,
|
||||
nearby::sharing::analytics::AnalyticsRecorder* analytics_recorder) = 0;
|
||||
|
||||
// On platforms where it is supported, tag the transferred files as
|
||||
// originating from an untrusted source.
|
||||
// Returns true on success.
|
||||
|
||||
@@ -1,117 +0,0 @@
|
||||
// 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_SHARING_RPC_CLIENT_H_
|
||||
#define THIRD_PARTY_NEARBY_SHARING_INTERNAL_API_SHARING_RPC_CLIENT_H_
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "google/nearby/identity/v1/binding.pb.h"
|
||||
#include "google/nearby/identity/v1/rpcs.pb.h"
|
||||
#include "absl/functional/any_invocable.h"
|
||||
#include "absl/status/statusor.h"
|
||||
#include "sharing/proto/certificate_rpc.pb.h"
|
||||
#include "sharing/proto/contact_rpc.pb.h"
|
||||
#include "sharing/proto/device_rpc.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(
|
||||
google::nearby::identity::v1::QuerySharedCredentialsRequest request,
|
||||
absl::AnyInvocable<
|
||||
void(const absl::StatusOr<
|
||||
google::nearby::identity::v1::QuerySharedCredentialsResponse>&
|
||||
response) &&>
|
||||
callback) = 0;
|
||||
|
||||
virtual void PublishDevice(
|
||||
google::nearby::identity::v1::PublishDeviceRequest request,
|
||||
absl::AnyInvocable<
|
||||
void(const absl::StatusOr<google::nearby::identity::v1::
|
||||
PublishDeviceResponse>& response) &&>
|
||||
callback) = 0;
|
||||
|
||||
virtual void GetAccountInfo(
|
||||
google::nearby::identity::v1::GetAccountInfoRequest request,
|
||||
absl::AnyInvocable<
|
||||
void(const absl::StatusOr<google::nearby::identity::v1::
|
||||
GetAccountInfoResponse>& response) &&>
|
||||
callback) = 0;
|
||||
|
||||
virtual void QuerySharedCredentialsWithBindingIds(
|
||||
google::nearby::identity::v1::QuerySharedCredentialsWithBindingIdsRequest
|
||||
request,
|
||||
absl::AnyInvocable<
|
||||
void(const absl::StatusOr<
|
||||
google::nearby::identity::v1::
|
||||
QuerySharedCredentialsWithBindingIdsResponse>& response) &&>
|
||||
callback) = 0;
|
||||
};
|
||||
|
||||
// SharingRpcClient is used to access Nearby Share backend APIs.
|
||||
class SharingRpcClient {
|
||||
public:
|
||||
SharingRpcClient() = default;
|
||||
virtual ~SharingRpcClient() = default;
|
||||
|
||||
// NearbyShareService v1: ListContactPeople
|
||||
virtual void ListContactPeople(
|
||||
proto::ListContactPeopleRequest request,
|
||||
absl::AnyInvocable<void(
|
||||
const absl::StatusOr<proto::ListContactPeopleResponse>& response) &&>
|
||||
callback) = 0;
|
||||
|
||||
virtual void InitiateBinding(
|
||||
google::nearby::identity::v1::InitiateBindingRequest request,
|
||||
absl::AnyInvocable<
|
||||
void(const absl::StatusOr<google::nearby::identity::v1::
|
||||
InitiateBindingResponse>& response) &&>
|
||||
callback) = 0;
|
||||
|
||||
virtual void JoinBinding(
|
||||
google::nearby::identity::v1::JoinBindingRequest request,
|
||||
absl::AnyInvocable<
|
||||
void(const absl::StatusOr<google::nearby::identity::v1::
|
||||
JoinBindingResponse>& response) &&>
|
||||
callback) = 0;
|
||||
|
||||
virtual void DeleteBinding(
|
||||
google::nearby::identity::v1::DeleteBindingRequest request,
|
||||
absl::AnyInvocable<
|
||||
void(const absl::StatusOr<google::nearby::identity::v1::
|
||||
DeleteBindingResponse>& response) &&>
|
||||
callback) = 0;
|
||||
};
|
||||
|
||||
// Interface for creating SharingRpcClient instances. Because each
|
||||
// SharingRpcClient instance can only be used for one API call, a factory
|
||||
// makes it easier to make multiple requests in sequence or in parallel.
|
||||
class SharingRpcClientFactory {
|
||||
public:
|
||||
SharingRpcClientFactory() = default;
|
||||
virtual ~SharingRpcClientFactory() = default;
|
||||
|
||||
virtual std::unique_ptr<SharingRpcClient> CreateInstance() = 0;
|
||||
virtual std::unique_ptr<IdentityRpcClient> CreateIdentityInstance() = 0;
|
||||
};
|
||||
|
||||
} // namespace nearby::sharing::api
|
||||
|
||||
#endif // THIRD_PARTY_NEARBY_SHARING_INTERNAL_API_SHARING_RPC_CLIENT_H_
|
||||
Reference in New Issue
Block a user