Commit 2e0857a0 authored by François Doray's avatar François Doray Committed by Commit Bot

Revert "Make base::ScopedZxHandle a zx::handle."

This reverts commit e17dbaf1.

Reason for revert: Compile failure https://crbug.com/852958

Original change's description:
> Make base::ScopedZxHandle a zx::handle.
> 
> - Add the ScopedZxHandle APIs to the base zx::handle.
> - Add missing includes.
> 
> This allows ScopedZxHandle to be removed incrementally from call-sites.
> 
> Bug: 852541
> Change-Id: Idc452a450ce2bbe1266e9e0ee266115e2ea38f97
> Reviewed-on: https://chromium-review.googlesource.com/1100132
> Commit-Queue: Wez <wez@chromium.org>
> Reviewed-by: Kevin Marshall <kmarshall@chromium.org>
> Reviewed-by: Ken Rockot <rockot@chromium.org>
> Reviewed-by: Gabriel Charette <gab@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#567382}

TBR=wez@chromium.org,gab@chromium.org,rockot@chromium.org,kmarshall@chromium.org

Change-Id: I44b3be92d12a29a972ca3c59d3356f97b21292f2
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 852541
Reviewed-on: https://chromium-review.googlesource.com/1101777Reviewed-by: default avatarFrançois Doray <fdoray@chromium.org>
Commit-Queue: François Doray <fdoray@chromium.org>
Cr-Commit-Position: refs/heads/master@{#567416}
parent 58983630
......@@ -1410,13 +1410,13 @@ jumbo_component("base") {
public_deps += [
"//third_party/fuchsia-sdk:async",
"//third_party/fuchsia-sdk:fdio",
"//third_party/fuchsia-sdk:zx",
]
deps += [
"//third_party/fuchsia-sdk:async_default",
"//third_party/fuchsia-sdk:fidl",
"//third_party/fuchsia-sdk:svc",
"//third_party/fuchsia-sdk:zx",
]
}
......
......@@ -5,29 +5,41 @@
#ifndef BASE_FUCHSIA_SCOPED_ZX_HANDLE_H_
#define BASE_FUCHSIA_SCOPED_ZX_HANDLE_H_
#include <lib/zx/handle.h>
#include <zircon/types.h>
#include <zircon/status.h>
#include <zircon/syscalls.h>
#include "base/base_export.h"
#include "base/fuchsia/fuchsia_logging.h"
#include "base/scoped_generic.h"
namespace zx {
class channel;
}
namespace base {
// TODO(852541): Temporary shim to implement the old ScopedGeneric based
// container as a native zx::handle. Remove this once all callers have been
// migrated to use the libzx containers.
class BASE_EXPORT ScopedZxHandle : public zx::handle {
namespace internal {
struct ScopedZxHandleTraits {
static zx_handle_t InvalidValue() { return ZX_HANDLE_INVALID; }
static void Free(zx_handle_t object) {
zx_status_t status = zx_handle_close(object);
ZX_CHECK(status == ZX_OK, status) << "zx_handle_close: " << object;
}
};
} // namespace internal
class BASE_EXPORT ScopedZxHandle
: public ScopedGeneric<zx_handle_t, internal::ScopedZxHandleTraits> {
public:
ScopedZxHandle() = default;
explicit ScopedZxHandle(zx_handle_t h) : zx::handle(h) {}
explicit ScopedZxHandle(zx_handle_t value) : ScopedGeneric(value) {}
explicit operator bool() const { return get() != ZX_HANDLE_INVALID; }
// Helper to converts zx::channel to ScopedZxHandle.
static ScopedZxHandle FromZxChannel(zx::channel channel);
// Helper to adapt between the libzx and ScopedGeneric APIs for receiving
// handles directly into the container via an out-parameter.
zx_handle_t* receive() { return reset_and_get_address(); }
};
} // namespace base
......
......@@ -11,8 +11,8 @@
#include <zircon/syscalls.h>
#include "base/bits.h"
#include "base/fuchsia/fuchsia_logging.h"
#include "base/fuchsia/scoped_zx_handle.h"
#include "base/logging.h"
#include "base/memory/shared_memory_tracker.h"
#include "base/process/process_metrics.h"
......@@ -66,7 +66,8 @@ bool SharedMemory::Create(const SharedMemoryCreateOptions& options) {
ScopedZxHandle old_vmo(std::move(vmo));
status = zx_handle_replace(old_vmo.get(), kNoExecFlags, vmo.receive());
if (status != ZX_OK) {
ZX_DLOG(ERROR, status) << "zx_handle_replace()";
DLOG(ERROR) << "zx_handle_replace() failed: "
<< zx_status_get_string(status);
return false;
}
ignore_result(old_vmo.release());
......@@ -94,7 +95,7 @@ bool SharedMemory::MapAt(off_t offset, size_t bytes) {
zx_status_t status = zx_vmar_map(zx_vmar_root_self(), 0, shm_.GetHandle(),
offset, bytes, flags, &addr);
if (status != ZX_OK) {
ZX_DLOG(ERROR, status) << "zx_vmar_map failed";
DLOG(ERROR) << "zx_vmar_map failed, status=" << status;
return false;
}
memory_ = reinterpret_cast<void*>(addr);
......@@ -114,7 +115,7 @@ bool SharedMemory::Unmap() {
uintptr_t addr = reinterpret_cast<uintptr_t>(memory_);
zx_status_t status = zx_vmar_unmap(zx_vmar_root_self(), addr, mapped_size_);
if (status != ZX_OK) {
ZX_DLOG(ERROR, status) << "zx_vmar_unmap";
DLOG(ERROR) << "zx_vmar_unmap failed, status=" << status;
return false;
}
......
......@@ -70,7 +70,6 @@
#include <zircon/syscalls.h>
#include <zircon/syscalls/object.h>
#include "base/fuchsia/default_job.h"
#include "base/fuchsia/fuchsia_logging.h"
#endif
namespace base {
......@@ -323,7 +322,7 @@ int LaunchChildTestProcessWithOptions(const CommandLine& command_line,
ScopedZxHandle job_handle;
zx_status_t result = zx_job_create(GetDefaultJob(), 0, job_handle.receive());
ZX_CHECK(ZX_OK == result, result) << "zx_job_create";
CHECK_EQ(ZX_OK, result) << "zx_job_create: " << zx_status_get_string(result);
new_options.job_handle = job_handle.get();
#endif // defined(OS_FUCHSIA)
......
......@@ -206,7 +206,6 @@
#include <zircon/syscalls.h>
#include "base/fuchsia/default_job.h"
#include "base/fuchsia/fuchsia_logging.h"
#endif // defined(OS_FUCHSIA)
#if defined(OS_POSIX) && !defined(OS_MACOSX)
......@@ -397,7 +396,8 @@ constexpr base::TimeDelta kSwapMetricsInterval =
void InitDefaultJob() {
base::ScopedZxHandle handle;
zx_status_t result = zx_job_create(zx_job_default(), 0, handle.receive());
ZX_CHECK(ZX_OK == result, result) << "zx_job_create";
CHECK_EQ(ZX_OK, result) << "zx_job_create(job): "
<< zx_status_get_string(result);
base::SetDefaultJob(std::move(handle));
}
#endif // defined(OS_FUCHSIA)
......
......@@ -7,15 +7,14 @@
#include <zircon/syscalls.h>
#include <zircon/types.h>
#include "base/fuchsia/fuchsia_logging.h"
namespace IPC {
namespace internal {
HandleAttachmentFuchsia::HandleAttachmentFuchsia(const zx_handle_t& handle) {
zx_status_t result =
zx_handle_duplicate(handle, ZX_RIGHT_SAME_RIGHTS, handle_.receive());
ZX_DLOG_IF(ERROR, result != ZX_OK, result) << "zx_handle_duplicate";
DLOG_IF(ERROR, result != ZX_OK)
<< "zx_handle_duplicate: " << zx_status_get_string(result);
}
HandleAttachmentFuchsia::HandleAttachmentFuchsia(base::ScopedZxHandle handle)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment