diff --git a/internal/platform/BUILD b/internal/platform/BUILD index 7de29f48..5cfbbbb5 100644 --- a/internal/platform/BUILD +++ b/internal/platform/BUILD @@ -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__", diff --git a/internal/platform/implementation/BUILD b/internal/platform/implementation/BUILD index 66a0f5b7..f6a47890 100644 --- a/internal/platform/implementation/BUILD +++ b/internal/platform/implementation/BUILD @@ -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__", diff --git a/internal/platform/implementation/apple/platform.mm b/internal/platform/implementation/apple/platform.mm index d35d6b81..f8de03e6 100644 --- a/internal/platform/implementation/apple/platform.mm +++ b/internal/platform/implementation/apple/platform.mm @@ -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 ImplementationPlatform::CreateDeviceInf return std::make_unique(); } +// TODO(b/261503919): Add implementation. +std::unique_ptr +ImplementationPlatform::CreatePreferencesRepository(absl::string_view path) { + return std::make_unique(path); +} + } // namespace api } // namespace nearby diff --git a/internal/platform/implementation/g3/BUILD b/internal/platform/implementation/g3/BUILD index 81df8931..8dc1300b 100644 --- a/internal/platform/implementation/g3/BUILD +++ b/internal/platform/implementation/g3/BUILD @@ -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__", diff --git a/internal/platform/implementation/g3/platform.cc b/internal/platform/implementation/g3/platform.cc index e4056d14..f8fc4fbb 100644 --- a/internal/platform/implementation/g3/platform.cc +++ b/internal/platform/implementation/g3/platform.cc @@ -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(); } +std::unique_ptr +ImplementationPlatform::CreatePreferencesRepository(absl::string_view path) { + return std::make_unique(path); +} + } // namespace api } // namespace nearby diff --git a/internal/platform/implementation/platform.h b/internal/platform/implementation/platform.h index 862bae8f..30d0d3d2 100644 --- a/internal/platform/implementation/platform.h +++ b/internal/platform/implementation/platform.h @@ -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 SendRequest(const WebRequest& request); + + static std::unique_ptr + CreatePreferencesRepository(absl::string_view path); }; } // namespace api diff --git a/internal/platform/implementation/windows/platform.cc b/internal/platform/implementation/windows/platform.cc index 70047776..b7956fe8 100644 --- a/internal/platform/implementation/windows/platform.cc +++ b/internal/platform/implementation/windows/platform.cc @@ -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 ImplementationPlatform::CreateDeviceInfo() { return std::make_unique(); } +std::unique_ptr +ImplementationPlatform::CreatePreferencesRepository(absl::string_view path) { + return std::make_unique(path); +} + } // namespace api } // namespace nearby diff --git a/internal/platform/listeners.h b/internal/platform/listeners.h index e4ef54bd..f1143a13 100644 --- a/internal/platform/listeners.h +++ b/internal/platform/listeners.h @@ -27,6 +27,11 @@ constexpr absl::AnyInvocable DefaultCallback() { return absl::AnyInvocable{[](Args...) {}}; } +template +constexpr std::function DefaultFuncCallback() { + return [](Args...) {}; +} + } // namespace nearby #endif // PLATFORM_BASE_LISTENERS_H_