blob: 0bbe49e1b36d9bda6c7bd9c1d31f42c0dd404cb0 [file] [log] [blame]
// Copyright 2018 The Chromium OS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include <base/memory/read_only_shared_memory_region.h>
#include <base/strings/string_piece.h>
#include <mojo/public/cpp/system/handle.h>
namespace diagnostics {
// Allows to get access to the buffer in read only shared memory. It converts
// mojo::Handle to base::ReadOnlySharedMemoryRegion.
// |handle| must be a valid mojo handle of the non-empty buffer in the shared
// memory.
// Returns invalid |base::ReadOnlySharedMemoryMapping| if error.
base::ReadOnlySharedMemoryMapping GetReadOnlySharedMemoryMappingFromMojoHandle(
mojo::ScopedHandle handle);
// Allocates buffer in shared memory, copies |content| to the buffer and
// converts shared buffer handle into |mojo::ScopedHandle|.
// Allocated shared memory is read only for another process.
// Returns invalid |mojo::ScopedHandle| if error happened or |content| is empty.
mojo::ScopedHandle CreateReadOnlySharedMemoryRegionMojoHandle(
base::StringPiece content);
} // namespace diagnostics