mirror of
https://github.com/kidfromjupiter/nearby.git
synced 2026-09-16 15:36:12 -04:00
Initial header files showing class dependency and ownership.
No detailed function signatures nor impl included yet. PiperOrigin-RevId: 460300058
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
# Copyright 2020 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.
|
||||
licenses(["notice"])
|
||||
|
||||
cc_library(
|
||||
name = "internal",
|
||||
srcs = [],
|
||||
hdrs = [
|
||||
"broadcast_manager.h",
|
||||
"credential_manager.h",
|
||||
"mock_service_controller.h",
|
||||
"scan_manager.h",
|
||||
"service_controller.h",
|
||||
"service_controller_impl.h",
|
||||
],
|
||||
visibility = [
|
||||
"//third_party/nearby/presence:__subpackages__",
|
||||
],
|
||||
deps = [
|
||||
"//internal/platform:base",
|
||||
"//internal/platform:comm",
|
||||
"//third_party/nearby/presence/implementation/mediums",
|
||||
],
|
||||
)
|
||||
@@ -0,0 +1,43 @@
|
||||
// Copyright 2020 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_PRESENCE_IMPLEMENTATION_BROADCAST_MANAGER_H_
|
||||
#define THIRD_PARTY_NEARBY_PRESENCE_IMPLEMENTATION_BROADCAST_MANAGER_H_
|
||||
|
||||
#include "third_party/nearby/presence/implementation/credential_manager.h"
|
||||
#include "third_party/nearby/presence/implementation/mediums/mediums.h"
|
||||
|
||||
namespace nearby {
|
||||
namespace presence {
|
||||
|
||||
/*
|
||||
* The instance of BroadcastManager is owned by {@code ServiceControllerImpl}.
|
||||
* Helping service controller to manage broadcast requests and callbacks.
|
||||
*/
|
||||
class BroadcastManager {
|
||||
public:
|
||||
BroadcastManager(Mediums& mediums, CredentialManager& credential_manager) {
|
||||
mediums_ = &mediums, credential_manager_ = &credential_manager;
|
||||
}
|
||||
~BroadcastManager() = default;
|
||||
|
||||
private:
|
||||
Mediums* mediums_;
|
||||
CredentialManager* credential_manager_;
|
||||
};
|
||||
|
||||
} // namespace presence
|
||||
} // namespace nearby
|
||||
|
||||
#endif // THIRD_PARTY_NEARBY_PRESENCE_IMPLEMENTATION_BROADCAST_MANAGER_H_
|
||||
@@ -0,0 +1,82 @@
|
||||
// Copyright 2020 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_PRESENCE_IMPLEMENTATION_CREDENTIAL_MANAGER_H_
|
||||
#define THIRD_PARTY_NEARBY_PRESENCE_IMPLEMENTATION_CREDENTIAL_MANAGER_H_
|
||||
|
||||
#include <functional>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "internal/platform/credential.h"
|
||||
#include "internal/platform/credential_storage.h"
|
||||
|
||||
namespace nearby {
|
||||
namespace presence {
|
||||
|
||||
struct GenerateCredentialsCallback {
|
||||
std::function<void(std::vector<location::nearby::PublicCredential>)>
|
||||
credentials_generated_cb;
|
||||
};
|
||||
|
||||
struct UpdateRemotePublicCredentialsCallback {
|
||||
std::function<void(location::nearby::api::CredentialOperationStatus)>
|
||||
credentials_updated_cb;
|
||||
};
|
||||
|
||||
/*
|
||||
* The instance of CredentialManager is owned by {@code ServiceControllerImpl}.
|
||||
* Helping service controller to manage local credentials and coordinate with
|
||||
* downloaded remote credentials.
|
||||
*/
|
||||
class CredentialManager {
|
||||
public:
|
||||
CredentialManager() = default;
|
||||
~CredentialManager() = default;
|
||||
|
||||
// Used to (re)generate user’s private and public credentials.
|
||||
// The generated private credentials will be saved to creds storage.
|
||||
// The generated public credentials will be returned inside the
|
||||
// credentials_generated_cb for manager app to upload to web.
|
||||
// The user’s own public credentials won’t be saved on local credential
|
||||
// storage.
|
||||
void GenerateCredentials(
|
||||
location::nearby::DeviceMetadata device_metadata,
|
||||
std::vector<location::nearby::TrustType> trust_types,
|
||||
GenerateCredentialsCallback credentials_generated_cb);
|
||||
|
||||
// Update remote public credentials.
|
||||
void UpdateRemotePublicCredentials(
|
||||
std::string account_name,
|
||||
std::vector<location::nearby::PublicCredential> remote_public_creds,
|
||||
UpdateRemotePublicCredentialsCallback credentials_updated_cb);
|
||||
|
||||
// Used to fetch private creds when broadcasting.
|
||||
void GetPrivateCredentials(
|
||||
location::nearby::api::CredentialSelector credential_selector,
|
||||
location::nearby::api::GetPrivateCredentialCallback callback);
|
||||
|
||||
// Used to fetch remote public creds when scanning.
|
||||
void GetPublicCredentials(
|
||||
location::nearby::api::CredentialSelector credential_selector,
|
||||
location::nearby::api::GetPublicCredentialCallback callback);
|
||||
|
||||
private:
|
||||
location::nearby::CredentialStorage* credential_storage_;
|
||||
};
|
||||
|
||||
} // namespace presence
|
||||
} // namespace nearby
|
||||
|
||||
#endif // THIRD_PARTY_NEARBY_PRESENCE_IMPLEMENTATION_CREDENTIAL_MANAGER_H_
|
||||
@@ -0,0 +1,30 @@
|
||||
# Copyright 2020 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.
|
||||
licenses(["notice"])
|
||||
|
||||
cc_library(
|
||||
name = "mediums",
|
||||
srcs = [],
|
||||
hdrs = [
|
||||
"ble.h",
|
||||
"mediums.h",
|
||||
],
|
||||
visibility = [
|
||||
"//third_party/nearby/presence/implementation:__subpackages__",
|
||||
],
|
||||
deps = [
|
||||
"//internal/platform:base",
|
||||
"//internal/platform:comm",
|
||||
],
|
||||
)
|
||||
@@ -0,0 +1,41 @@
|
||||
// Copyright 2020 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_PRESENCE_IMPLEMENTATION_MEDIUMS_BLE_H_
|
||||
#define THIRD_PARTY_NEARBY_PRESENCE_IMPLEMENTATION_MEDIUMS_BLE_H_
|
||||
|
||||
#include "internal/platform/ble_v2.h"
|
||||
|
||||
namespace nearby {
|
||||
namespace presence {
|
||||
|
||||
/*
|
||||
* This Ble class utilizes platform/ble_v2 BleV2Medium, provides ble functions
|
||||
* for presence logic layer to invoke.
|
||||
* This class would have states like if ble is available or not, if it's doing
|
||||
* broadcast/scan.
|
||||
*/
|
||||
class Ble {
|
||||
public:
|
||||
Ble() = default;
|
||||
~Ble() = default;
|
||||
// TODO(hais): add expected function set.
|
||||
private:
|
||||
location::nearby::BleV2Medium medium_;
|
||||
};
|
||||
|
||||
} // namespace presence
|
||||
} // namespace nearby
|
||||
|
||||
#endif // THIRD_PARTY_NEARBY_PRESENCE_IMPLEMENTATION_MEDIUMS_BLE_H_
|
||||
@@ -0,0 +1,42 @@
|
||||
// Copyright 2020 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_PRESENCE_IMPLEMENTATION_MEDIUMS_MEDIUMS_H_
|
||||
#define THIRD_PARTY_NEARBY_PRESENCE_IMPLEMENTATION_MEDIUMS_MEDIUMS_H_
|
||||
|
||||
#include "third_party/nearby/presence/implementation/mediums/ble.h"
|
||||
|
||||
namespace nearby {
|
||||
namespace presence {
|
||||
|
||||
/*
|
||||
* This class owns medium instance like Ble and etc. And the instance of
|
||||
* this class will be owned in {@code ServiceControllerImpl}.
|
||||
*/
|
||||
class Mediums {
|
||||
public:
|
||||
Mediums() = default;
|
||||
~Mediums() = default;
|
||||
|
||||
// Returns a handle to the Ble medium.
|
||||
Ble& GetBle();
|
||||
|
||||
private:
|
||||
Ble ble_;
|
||||
};
|
||||
|
||||
} // namespace presence
|
||||
} // namespace nearby
|
||||
|
||||
#endif // THIRD_PARTY_NEARBY_PRESENCE_IMPLEMENTATION_MEDIUMS_MEDIUMS_H_
|
||||
@@ -0,0 +1,37 @@
|
||||
// Copyright 2020 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_PRESENCE_IMPLEMENTATION_MOCK_SERVICE_CONTROLLER_H_
|
||||
#define THIRD_PARTY_NEARBY_PRESENCE_IMPLEMENTATION_MOCK_SERVICE_CONTROLLER_H_
|
||||
|
||||
#include "third_party/nearby/presence/implementation/service_controller.h"
|
||||
|
||||
namespace nearby {
|
||||
namespace presence {
|
||||
|
||||
/*
|
||||
* This class is for unit test, mocking {@code ServiceController} functions.
|
||||
*/
|
||||
class MockServiceController : public ServiceController {
|
||||
public:
|
||||
MockServiceController() = default;
|
||||
~MockServiceController() override = default;
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
} // namespace presence
|
||||
} // namespace nearby
|
||||
|
||||
#endif // THIRD_PARTY_NEARBY_PRESENCE_IMPLEMENTATION_MOCK_SERVICE_CONTROLLER_H_
|
||||
@@ -0,0 +1,43 @@
|
||||
// Copyright 2020 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_PRESENCE_IMPLEMENTATION_SCAN_MANAGER_H_
|
||||
#define THIRD_PARTY_NEARBY_PRESENCE_IMPLEMENTATION_SCAN_MANAGER_H_
|
||||
|
||||
#include "third_party/nearby/presence/implementation/credential_manager.h"
|
||||
#include "third_party/nearby/presence/implementation/mediums/mediums.h"
|
||||
|
||||
namespace nearby {
|
||||
namespace presence {
|
||||
|
||||
/*
|
||||
* The instance of ScanManager is owned by {@code ServiceControllerImpl}.
|
||||
* Helping service controller to manage scan requests and callbacks.
|
||||
*/
|
||||
class ScanManager {
|
||||
public:
|
||||
ScanManager(Mediums& mediums, CredentialManager& credential_manager) {
|
||||
mediums_ = &mediums, credential_manager_ = &credential_manager;
|
||||
}
|
||||
~ScanManager() = default;
|
||||
|
||||
private:
|
||||
Mediums* mediums_;
|
||||
CredentialManager* credential_manager_;
|
||||
};
|
||||
|
||||
} // namespace presence
|
||||
} // namespace nearby
|
||||
|
||||
#endif // THIRD_PARTY_NEARBY_PRESENCE_IMPLEMENTATION_SCAN_MANAGER_H_
|
||||
@@ -0,0 +1,34 @@
|
||||
// Copyright 2020 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_PRESENCE_IMPLEMENTATION_SERVICE_CONTROLLER_H_
|
||||
#define THIRD_PARTY_NEARBY_PRESENCE_IMPLEMENTATION_SERVICE_CONTROLLER_H_
|
||||
|
||||
namespace nearby {
|
||||
namespace presence {
|
||||
|
||||
/*
|
||||
* This class is owned in {@code PresenceService}. It specifies the function
|
||||
* signatures. {@code ServiceControllerImpl} and {@code MockServiceController}
|
||||
* inherit this class and provides real implementation and mock impl for tests.
|
||||
*/
|
||||
class ServiceController {
|
||||
public:
|
||||
virtual ~ServiceController() = default;
|
||||
};
|
||||
|
||||
} // namespace presence
|
||||
} // namespace nearby
|
||||
|
||||
#endif // THIRD_PARTY_NEARBY_PRESENCE_IMPLEMENTATION_SERVICE_CONTROLLER_H_
|
||||
@@ -0,0 +1,42 @@
|
||||
// Copyright 2020 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_PRESENCE_IMPLEMENTATION_SERVICE_CONTROLLER_IMPL_H_
|
||||
#define THIRD_PARTY_NEARBY_PRESENCE_IMPLEMENTATION_SERVICE_CONTROLLER_IMPL_H_
|
||||
|
||||
#include "third_party/nearby/presence/implementation/credential_manager.h"
|
||||
#include "third_party/nearby/presence/implementation/mediums/mediums.h"
|
||||
#include "third_party/nearby/presence/implementation/service_controller.h"
|
||||
|
||||
/*
|
||||
* This class implements {@code ServiceController} functions. Owns mediums and
|
||||
* other managers instances.
|
||||
*/
|
||||
namespace nearby {
|
||||
namespace presence {
|
||||
|
||||
class ServiceControllerImpl : public ServiceController {
|
||||
public:
|
||||
ServiceControllerImpl() = default;
|
||||
~ServiceControllerImpl() override = default;
|
||||
|
||||
private:
|
||||
Mediums mediums_; // NOLINT: further impl will use it.
|
||||
CredentialManager credential_manager_; // NOLINT: further impl will use it.
|
||||
};
|
||||
|
||||
} // namespace presence
|
||||
} // namespace nearby
|
||||
|
||||
#endif // THIRD_PARTY_NEARBY_PRESENCE_IMPLEMENTATION_SERVICE_CONTROLLER_IMPL_H_
|
||||
Reference in New Issue
Block a user