mirror of
https://github.com/kidfromjupiter/nearby.git
synced 2026-09-14 22:56:12 -04:00
Merge branch 'master' into release.
Change-Id: Id627ceca5ef60281e024ff80fc1848b3ccb6c14d
This commit is contained in:
+1
-5
@@ -17,7 +17,6 @@ cc_library(
|
||||
srcs = [
|
||||
"base64_utils.cc",
|
||||
"cancelable_alarm.cc",
|
||||
"file_impl.cc",
|
||||
"pipe.cc",
|
||||
"prng.cc",
|
||||
"reliability_utils.cc",
|
||||
@@ -25,7 +24,6 @@ cc_library(
|
||||
hdrs = [
|
||||
"base64_utils.h",
|
||||
"cancelable_alarm.h",
|
||||
"file_impl.h",
|
||||
"pipe.h",
|
||||
"prng.h",
|
||||
"reliability_utils.h",
|
||||
@@ -77,7 +75,7 @@ cc_library(
|
||||
visibility = [
|
||||
"//googlemac/iPhone/Shared/Nearby/Connections:__subpackages__",
|
||||
"//core:__subpackages__",
|
||||
"//platform_v2/public:__pkg__",
|
||||
"//platform_v2/base:__pkg__",
|
||||
],
|
||||
deps = [
|
||||
"//absl/base",
|
||||
@@ -92,7 +90,6 @@ cc_test(
|
||||
"atomic_reference_test.cc",
|
||||
"byte_array_test.cc",
|
||||
"container_of_test.cc",
|
||||
"file_impl_test.cc",
|
||||
"pipe_test.cc",
|
||||
"prng_test.cc",
|
||||
"ptr_test.cc",
|
||||
@@ -100,7 +97,6 @@ cc_test(
|
||||
],
|
||||
deps = [
|
||||
":utils",
|
||||
"//file/util:temp_path",
|
||||
"//platform:types",
|
||||
"//platform/api",
|
||||
"//platform/impl/g3",
|
||||
|
||||
@@ -19,14 +19,12 @@ target_sources(platform_utils
|
||||
PRIVATE
|
||||
base64_utils.cc
|
||||
cancelable_alarm.cc
|
||||
file_impl.cc
|
||||
pipe.cc
|
||||
prng.cc
|
||||
reliability_utils.cc
|
||||
PUBLIC
|
||||
base64_utils.h
|
||||
cancelable_alarm.h
|
||||
file_impl.h
|
||||
pipe.h
|
||||
prng.h
|
||||
reliability_utils.h
|
||||
@@ -67,7 +65,6 @@ add_executable(platform_test
|
||||
byte_array_test.cc
|
||||
container_of_test.cc
|
||||
exception_test.cc
|
||||
file_impl_test.cc
|
||||
pipe_test.cc
|
||||
prng_test.cc
|
||||
ptr_test.cc
|
||||
|
||||
@@ -26,7 +26,9 @@
|
||||
#include "platform/api/condition_variable.h"
|
||||
#include "platform/api/count_down_latch.h"
|
||||
#include "platform/api/hash_utils.h"
|
||||
#include "platform/api/input_file.h"
|
||||
#include "platform/api/lock.h"
|
||||
#include "platform/api/output_file.h"
|
||||
#include "platform/api/scheduled_executor.h"
|
||||
#include "platform/api/server_sync.h"
|
||||
#include "platform/api/settable_future_def.h"
|
||||
@@ -85,6 +87,9 @@ class ImplementationPlatform {
|
||||
static Ptr<HashUtils> createHashUtils();
|
||||
static Ptr<ThreadUtils> createThreadUtils();
|
||||
static Ptr<SystemClock> createSystemClock();
|
||||
static Ptr<InputFile> createInputFile(std::int64_t payload_id,
|
||||
std::int64_t total_size);
|
||||
static Ptr<OutputFile> createOutputFile(std::int64_t payload_id);
|
||||
|
||||
// Java-like Executors
|
||||
// Type aliases used to API 1.0 compatibility.
|
||||
@@ -110,7 +115,6 @@ class ImplementationPlatform {
|
||||
// static Ptr<WebRtcSignalingMessenger> createWebRtcSignalingMessenger(
|
||||
// const std::string& self_id);
|
||||
static std::string getDeviceId();
|
||||
static std::string getPayloadPath(int64_t payload_id);
|
||||
};
|
||||
|
||||
} // namespace platform
|
||||
|
||||
@@ -29,6 +29,7 @@ cc_library(
|
||||
"//platform:types",
|
||||
"//platform/api",
|
||||
"//platform/impl/shared:atomic_boolean",
|
||||
"//platform/impl/shared:file",
|
||||
"//platform/impl/shared:posix_condition_variable",
|
||||
"//platform/impl/shared:posix_lock",
|
||||
"//platform/port:string",
|
||||
|
||||
@@ -32,6 +32,7 @@ target_link_libraries(platform_impl_g3
|
||||
"platform_types"
|
||||
"platform_api"
|
||||
"platform_impl_shared_atomic_boolean"
|
||||
"platform_impl_shared_file"
|
||||
"platform_impl_shared_posix_condition_variable"
|
||||
"platform_impl_shared_posix_lock"
|
||||
"platform_port_string"
|
||||
|
||||
@@ -39,6 +39,7 @@
|
||||
#include "platform/impl/g3/settable_future_impl.h"
|
||||
#include "platform/impl/g3/system_clock_impl.h"
|
||||
#include "platform/impl/shared/atomic_boolean_impl.h"
|
||||
#include "platform/impl/shared/file_impl.h"
|
||||
#include "platform/impl/shared/posix_condition_variable.h"
|
||||
#include "platform/impl/shared/posix_lock.h"
|
||||
#include "platform/port/string.h"
|
||||
@@ -50,6 +51,12 @@ namespace location {
|
||||
namespace nearby {
|
||||
namespace platform {
|
||||
|
||||
namespace {
|
||||
std::string getPayloadPath(std::int64_t payload_id) {
|
||||
return "/tmp/" + std::to_string(payload_id);
|
||||
}
|
||||
} // namespace
|
||||
|
||||
Ptr<SubmittableExecutor> ImplementationPlatform::createSingleThreadExecutor() {
|
||||
return Ptr<SubmittableExecutor>(/*new SingleThreadExecutorImpl()*/);
|
||||
}
|
||||
@@ -100,6 +107,16 @@ Ptr<AtomicBoolean> ImplementationPlatform::createAtomicBoolean(
|
||||
return Ptr<AtomicBoolean>(new AtomicBooleanImpl(initial_value));
|
||||
}
|
||||
|
||||
Ptr<InputFile> ImplementationPlatform::createInputFile(
|
||||
std::int64_t payload_id, std::int64_t total_size) {
|
||||
return MakePtr(new InputFileImpl(getPayloadPath(payload_id), total_size));
|
||||
}
|
||||
|
||||
Ptr<OutputFile> ImplementationPlatform::createOutputFile(
|
||||
std::int64_t payload_id) {
|
||||
return MakePtr(new OutputFileImpl(getPayloadPath(payload_id)));
|
||||
}
|
||||
|
||||
Ptr<BluetoothClassicMedium>
|
||||
ImplementationPlatform::createBluetoothClassicMedium() {
|
||||
return Ptr<BluetoothClassicMedium>();
|
||||
@@ -145,10 +162,6 @@ std::string ImplementationPlatform::getDeviceId() {
|
||||
return "google3";
|
||||
}
|
||||
|
||||
std::string ImplementationPlatform::getPayloadPath(int64_t payload_id) {
|
||||
return "/tmp/" + std::to_string(payload_id);
|
||||
}
|
||||
|
||||
} // namespace platform
|
||||
} // namespace nearby
|
||||
} // namespace location
|
||||
|
||||
@@ -28,6 +28,7 @@ cc_library(
|
||||
"//platform:types",
|
||||
"//platform:utils",
|
||||
"//platform/api",
|
||||
"//platform/impl/shared:file",
|
||||
"//platform/impl/shared/sample:sample_wifi_medium",
|
||||
"//platform/port:string",
|
||||
"//absl/time",
|
||||
|
||||
@@ -26,6 +26,7 @@ target_link_libraries(platform_impl_sample
|
||||
PUBLIC
|
||||
absl::time
|
||||
platform_api
|
||||
platform_impl_shared_file
|
||||
platform_port_string
|
||||
platform_types
|
||||
platform_utils
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
#include "platform/cancelable.h"
|
||||
#include "platform/impl/sample/atomic_reference_impl.h"
|
||||
#include "platform/impl/sample/settable_future_impl.h"
|
||||
#include "platform/impl/shared/file_impl.h"
|
||||
#include "platform/impl/shared/sample/sample_wifi_medium.h"
|
||||
#include "platform/port/string.h"
|
||||
#include "platform/ptr.h"
|
||||
@@ -44,6 +45,12 @@ namespace location {
|
||||
namespace nearby {
|
||||
namespace platform {
|
||||
|
||||
namespace {
|
||||
std::string getPayloadPath(std::int64_t payload_id) {
|
||||
return "/tmp/sample-" + std::to_string(payload_id);
|
||||
}
|
||||
} // namespace
|
||||
|
||||
Ptr<ScheduledExecutor> ImplementationPlatform::createScheduledExecutor() {
|
||||
return Ptr<ScheduledExecutor>{};
|
||||
}
|
||||
@@ -94,6 +101,16 @@ Ptr<AtomicBoolean> ImplementationPlatform::createAtomicBoolean(
|
||||
return Ptr<AtomicBoolean>{};
|
||||
}
|
||||
|
||||
Ptr<InputFile> ImplementationPlatform::createInputFile(
|
||||
std::int64_t payload_id, std::int64_t total_size) {
|
||||
return MakePtr(new InputFileImpl(getPayloadPath(payload_id), total_size));
|
||||
}
|
||||
|
||||
Ptr<OutputFile> ImplementationPlatform::createOutputFile(
|
||||
std::int64_t payload_id) {
|
||||
return MakePtr(new OutputFileImpl(getPayloadPath(payload_id)));
|
||||
}
|
||||
|
||||
Ptr<BluetoothClassicMedium>
|
||||
ImplementationPlatform::createBluetoothClassicMedium() {
|
||||
return Ptr<BluetoothClassicMedium>();
|
||||
@@ -130,10 +147,6 @@ Ptr<HashUtils> ImplementationPlatform::createHashUtils() {
|
||||
|
||||
std::string ImplementationPlatform::getDeviceId() { return "sample"; }
|
||||
|
||||
std::string ImplementationPlatform::getPayloadPath(int64_t payload_id) {
|
||||
return "/tmp/sample-" + std::to_string(payload_id);
|
||||
}
|
||||
|
||||
} // namespace platform
|
||||
} // namespace nearby
|
||||
} // namespace location
|
||||
|
||||
@@ -57,3 +57,31 @@ cc_library(
|
||||
],
|
||||
deps = ["//platform/api"],
|
||||
)
|
||||
|
||||
cc_library(
|
||||
name = "file",
|
||||
srcs = ["file_impl.cc"],
|
||||
hdrs = ["file_impl.h"],
|
||||
visibility = [
|
||||
"//googlemac/iPhone/Shared/Nearby/Connections:__subpackages__",
|
||||
"//core:__subpackages__",
|
||||
"//platform/impl:__subpackages__",
|
||||
],
|
||||
deps = [
|
||||
"//platform:types",
|
||||
"//platform/api",
|
||||
],
|
||||
)
|
||||
|
||||
cc_test(
|
||||
name = "file_test",
|
||||
timeout = "short",
|
||||
srcs = [
|
||||
"file_impl_test.cc",
|
||||
],
|
||||
deps = [
|
||||
":file",
|
||||
"//file/util:temp_path",
|
||||
"//testing/base/public:gunit_main",
|
||||
],
|
||||
)
|
||||
|
||||
@@ -55,6 +55,26 @@ target_link_libraries(platform_impl_shared_posix_condition_variable
|
||||
absl::raw_logging_internal
|
||||
)
|
||||
|
||||
add_library(platform_impl_shared_file STATIC)
|
||||
|
||||
target_sources(platform_impl_shared_file
|
||||
PRIVATE
|
||||
"file_impl.cc"
|
||||
PUBLIC
|
||||
"file_impl.h"
|
||||
)
|
||||
|
||||
target_include_directories(platform_impl_shared_file
|
||||
PUBLIC
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
)
|
||||
|
||||
target_link_libraries(platform_impl_shared_file
|
||||
PUBLIC
|
||||
platform_api
|
||||
platform_types
|
||||
)
|
||||
|
||||
add_library(platform_impl_shared_atomic_boolean STATIC)
|
||||
|
||||
target_sources(platform_impl_shared_atomic_boolean
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include "platform/file_impl.h"
|
||||
#include "platform/impl/shared/file_impl.h"
|
||||
|
||||
#include <cstddef>
|
||||
#include <memory>
|
||||
@@ -12,8 +12,8 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#ifndef PLATFORM_FILE_IMPL_H_
|
||||
#define PLATFORM_FILE_IMPL_H_
|
||||
#ifndef PLATFORM_IMPL_SHARED_FILE_IMPL_H_
|
||||
#define PLATFORM_IMPL_SHARED_FILE_IMPL_H_
|
||||
|
||||
#include <cstdint>
|
||||
#include <fstream>
|
||||
@@ -57,4 +57,4 @@ class OutputFileImpl final : public OutputFile {
|
||||
} // namespace nearby
|
||||
} // namespace location
|
||||
|
||||
#endif // PLATFORM_FILE_IMPL_H_
|
||||
#endif // PLATFORM_IMPL_SHARED_FILE_IMPL_H_
|
||||
@@ -12,7 +12,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include "platform/file_impl.h"
|
||||
#include "platform/impl/shared/file_impl.h"
|
||||
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
Reference in New Issue
Block a user