mirror of
https://github.com/kidfromjupiter/nearby.git
synced 2026-09-14 14:46:12 -04:00
Migrate PreferencesManager from location/nearby to third_party/nearby
PiperOrigin-RevId: 524900136
This commit is contained in:
committed by
Copybara-Service
parent
b68431e6a8
commit
2e7f7a7d90
@@ -47,8 +47,10 @@ cc_library(
|
||||
"//connections:__subpackages__",
|
||||
"//fastpair:__subpackages__",
|
||||
"//internal:__pkg__",
|
||||
"//internal/auth:__subpackages__",
|
||||
"//internal/platform:__subpackages__",
|
||||
"//internal/platform/implementation:__subpackages__",
|
||||
"//internal/preferences:__subpackages__",
|
||||
"//internal/weave:__pkg__",
|
||||
"//location/nearby/cpp:__subpackages__",
|
||||
"//presence:__subpackages__",
|
||||
@@ -348,6 +350,7 @@ cc_library(
|
||||
"//internal/flags:__subpackages__",
|
||||
"//internal/network:__subpackages__",
|
||||
"//internal/platform/implementation/windows:__subpackages__",
|
||||
"//internal/preferences:__subpackages__",
|
||||
"//internal/test:__subpackages__",
|
||||
"//internal/weave:__pkg__",
|
||||
"//location/nearby/cpp:__subpackages__",
|
||||
|
||||
@@ -43,6 +43,7 @@ cc_library(
|
||||
"//internal/crypto:__pkg__",
|
||||
"//internal/platform:__pkg__",
|
||||
"//internal/platform/implementation:__subpackages__",
|
||||
"//internal/preferences:__subpackages__",
|
||||
"//internal/test:__subpackages__",
|
||||
"//location/nearby/analytics/cpp:__subpackages__",
|
||||
"//location/nearby/cpp/common:__subpackages__",
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#import "internal/platform/implementation/apple/log_message.h"
|
||||
#import "internal/platform/implementation/apple/multi_thread_executor.h"
|
||||
#include "internal/platform/implementation/apple/mutex.h"
|
||||
#include "internal/platform/implementation/apple/preferences_repository.h"
|
||||
#import "internal/platform/implementation/apple/scheduled_executor.h"
|
||||
#import "internal/platform/implementation/apple/single_thread_executor.h"
|
||||
#include "internal/platform/implementation/apple/timer.h"
|
||||
@@ -246,5 +247,11 @@ std::unique_ptr<nearby::api::DeviceInfo> ImplementationPlatform::CreateDeviceInf
|
||||
return std::make_unique<apple::DeviceInfo>();
|
||||
}
|
||||
|
||||
// TODO(b/261503919): Add implementation.
|
||||
std::unique_ptr<nearby::api::PreferencesRepository>
|
||||
ImplementationPlatform::CreatePreferencesRepository(absl::string_view path) {
|
||||
return std::make_unique<apple::PreferencesRepository>(path);
|
||||
}
|
||||
|
||||
} // namespace api
|
||||
} // namespace nearby
|
||||
|
||||
@@ -139,6 +139,7 @@ cc_library(
|
||||
"//internal/flags:__subpackages__",
|
||||
"//internal/network:__subpackages__",
|
||||
"//internal/platform:__subpackages__",
|
||||
"//internal/preferences:__subpackages__",
|
||||
"//internal/proto/analytics:__subpackages__",
|
||||
"//internal/test:__subpackages__",
|
||||
"//internal/weave:__subpackages__",
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
#include "internal/platform/implementation/condition_variable.h"
|
||||
#include "internal/platform/implementation/log_message.h"
|
||||
#include "internal/platform/implementation/mutex.h"
|
||||
#include "internal/platform/implementation/preferences_repository.h"
|
||||
#include "internal/platform/implementation/scheduled_executor.h"
|
||||
#include "internal/platform/implementation/server_sync.h"
|
||||
#include "internal/platform/implementation/shared/count_down_latch.h"
|
||||
@@ -52,6 +53,7 @@
|
||||
#include "internal/platform/implementation/g3/log_message.h"
|
||||
#include "internal/platform/implementation/g3/multi_thread_executor.h"
|
||||
#include "internal/platform/implementation/g3/mutex.h"
|
||||
#include "internal/platform/implementation/g3/preferences_repository.h"
|
||||
#include "internal/platform/implementation/g3/scheduled_executor.h"
|
||||
#include "internal/platform/implementation/g3/single_thread_executor.h"
|
||||
#include "internal/platform/implementation/g3/timer.h"
|
||||
@@ -235,5 +237,10 @@ ImplementationPlatform::CreateDeviceInfo() {
|
||||
return std::make_unique<g3::DeviceInfo>();
|
||||
}
|
||||
|
||||
std::unique_ptr<nearby::api::PreferencesRepository>
|
||||
ImplementationPlatform::CreatePreferencesRepository(absl::string_view path) {
|
||||
return std::make_unique<g3::PreferencesRepository>(path);
|
||||
}
|
||||
|
||||
} // namespace api
|
||||
} // namespace nearby
|
||||
|
||||
@@ -46,6 +46,7 @@
|
||||
#ifndef NO_WEBRTC
|
||||
#include "internal/platform/implementation/webrtc.h"
|
||||
#endif
|
||||
#include "internal/platform/implementation/preferences_repository.h"
|
||||
#include "internal/platform/implementation/wifi.h"
|
||||
#include "internal/platform/implementation/wifi_direct.h"
|
||||
#include "internal/platform/implementation/wifi_hotspot.h"
|
||||
@@ -148,6 +149,9 @@ class ImplementationPlatform {
|
||||
// return WebResponse if HTTP status code between 200 and 300.
|
||||
// other cases will return absl Status in error.
|
||||
static absl::StatusOr<WebResponse> SendRequest(const WebRequest& request);
|
||||
|
||||
static std::unique_ptr<nearby::api::PreferencesRepository>
|
||||
CreatePreferencesRepository(absl::string_view path);
|
||||
};
|
||||
|
||||
} // namespace api
|
||||
|
||||
@@ -53,6 +53,7 @@
|
||||
#include "internal/platform/implementation/windows/listenable_future.h"
|
||||
#include "internal/platform/implementation/windows/log_message.h"
|
||||
#include "internal/platform/implementation/windows/mutex.h"
|
||||
#include "internal/platform/implementation/windows/preferences_repository.h"
|
||||
#include "internal/platform/implementation/windows/scheduled_executor.h"
|
||||
#include "internal/platform/implementation/windows/server_sync.h"
|
||||
#include "internal/platform/implementation/windows/settable_future.h"
|
||||
@@ -141,7 +142,7 @@ std::string ImplementationPlatform::GetAppDataPath(
|
||||
FOLDERID_LocalAppData, // rfid: A reference to the KNOWNFOLDERID that
|
||||
// identifies the folder.
|
||||
0, // dwFlags: Flags that specify special retrieval options.
|
||||
NULL, // hToken: An access token that represents a particular user.
|
||||
nullptr, // hToken: An access token that represents a particular user.
|
||||
&basePath); // ppszPath: When this method returns, contains the address
|
||||
// of a pointer to a null-terminated Unicode string that
|
||||
// specifies the path of the known folder. The calling
|
||||
@@ -149,7 +150,7 @@ std::string ImplementationPlatform::GetAppDataPath(
|
||||
// is no longer needed by calling CoTaskMemFree, whether
|
||||
// SHGetKnownFolderPath succeeds or not.
|
||||
size_t bufferSize;
|
||||
wcstombs_s(&bufferSize, NULL, 0, basePath, 0);
|
||||
wcstombs_s(&bufferSize, nullptr, 0, basePath, 0);
|
||||
std::string fullpathUTF8(bufferSize - 1, '\0');
|
||||
wcstombs_s(&bufferSize, fullpathUTF8.data(), bufferSize, basePath, _TRUNCATE);
|
||||
CoTaskMemFree(basePath);
|
||||
@@ -320,5 +321,10 @@ std::unique_ptr<DeviceInfo> ImplementationPlatform::CreateDeviceInfo() {
|
||||
return std::make_unique<windows::DeviceInfo>();
|
||||
}
|
||||
|
||||
std::unique_ptr<nearby::api::PreferencesRepository>
|
||||
ImplementationPlatform::CreatePreferencesRepository(absl::string_view path) {
|
||||
return std::make_unique<windows::PreferencesRepository>(path);
|
||||
}
|
||||
|
||||
} // namespace api
|
||||
} // namespace nearby
|
||||
|
||||
@@ -27,6 +27,11 @@ constexpr absl::AnyInvocable<void(Args...)> DefaultCallback() {
|
||||
return absl::AnyInvocable<void(Args...)>{[](Args...) {}};
|
||||
}
|
||||
|
||||
template <typename... Args>
|
||||
constexpr std::function<void(Args...)> DefaultFuncCallback() {
|
||||
return [](Args...) {};
|
||||
}
|
||||
|
||||
} // namespace nearby
|
||||
|
||||
#endif // PLATFORM_BASE_LISTENERS_H_
|
||||
|
||||
Reference in New Issue
Block a user