#ifndef SRC_TRACING_IPC_SHARED_MEMORY_WINDOWS_H_
#define SRC_TRACING_IPC_SHARED_MEMORY_WINDOWS_H_
#include "perfetto/base/build_config.h"
#if PERFETTO_BUILDFLAG(PERFETTO_OS_WIN)
#include <string>
#include "perfetto/base/build_config.h"
#include "perfetto/ext/base/scoped_file.h"
#include "perfetto/ext/tracing/core/shared_memory.h"
namespace perfetto {
class SharedMemoryWindows : public SharedMemory {
public:
class Factory : public SharedMemory::Factory {
public:
~Factory() override;
std::unique_ptr<SharedMemory> CreateSharedMemory(size_t) override;
};
enum Flags { kNone = 0, kInheritableHandles };
static std::unique_ptr<SharedMemoryWindows> Create(
size_t size, Flags flags=Flags::kNone);
static std::unique_ptr<SharedMemoryWindows> Attach(const std::string& key);
static std::unique_ptr<SharedMemoryWindows> AttachToHandleWithKey(
base::ScopedPlatformHandle fd, const std::string& key);
~SharedMemoryWindows() override;
const std::string& key() const { return key_; }
const base::ScopedPlatformHandle& handle() const { return handle_; }
void* start() const override { return start_; }
size_t size() const override { return size_; }
private:
SharedMemoryWindows(void* start,
size_t size,
std::string,
base::ScopedPlatformHandle);
SharedMemoryWindows(const SharedMemoryWindows&) = delete;
SharedMemoryWindows& operator=(const SharedMemoryWindows&) = delete;
void* const start_;
const size_t size_;
std::string key_;
base::ScopedPlatformHandle handle_;
};
}
#endif
#endif