2022-07-04 11:49:15 +02:00
|
|
|
// Copyright (c) 2022 The Chromium Embedded Framework Authors. All rights
|
|
|
|
// reserved. Use of this source code is governed by a BSD-style license that
|
|
|
|
// can be found in the LICENSE file.
|
|
|
|
|
|
|
|
#ifndef CEF_LIBCEF_COMMON_PROCESS_MESSAGE_SMR_IMPL_H_
|
|
|
|
#define CEF_LIBCEF_COMMON_PROCESS_MESSAGE_SMR_IMPL_H_
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "include/cef_process_message.h"
|
|
|
|
#include "include/cef_shared_process_message_builder.h"
|
|
|
|
|
2023-10-17 00:43:29 +02:00
|
|
|
#include "base/memory/writable_shared_memory_region.h"
|
2022-07-04 11:49:15 +02:00
|
|
|
|
|
|
|
class CefProcessMessageSMRImpl final : public CefProcessMessage {
|
|
|
|
public:
|
|
|
|
CefProcessMessageSMRImpl(const CefString& name,
|
2023-10-17 00:43:29 +02:00
|
|
|
base::WritableSharedMemoryRegion&& region);
|
2022-07-04 11:49:15 +02:00
|
|
|
CefProcessMessageSMRImpl(const CefProcessMessageSMRImpl&) = delete;
|
|
|
|
CefProcessMessageSMRImpl& operator=(const CefProcessMessageSMRImpl&) = delete;
|
|
|
|
~CefProcessMessageSMRImpl() override;
|
|
|
|
|
|
|
|
// CefProcessMessage methods.
|
|
|
|
bool IsValid() override;
|
|
|
|
bool IsReadOnly() override { return true; }
|
|
|
|
CefRefPtr<CefProcessMessage> Copy() override { return nullptr; }
|
|
|
|
CefString GetName() override;
|
2022-09-26 21:30:45 +02:00
|
|
|
CefRefPtr<CefListValue> GetArgumentList() override { return nullptr; }
|
2022-07-04 11:49:15 +02:00
|
|
|
CefRefPtr<CefSharedMemoryRegion> GetSharedMemoryRegion() override;
|
2023-10-17 00:43:29 +02:00
|
|
|
[[nodiscard]] base::WritableSharedMemoryRegion TakeRegion();
|
2022-07-04 11:49:15 +02:00
|
|
|
|
|
|
|
private:
|
|
|
|
const CefString name_;
|
2023-10-17 00:43:29 +02:00
|
|
|
base::WritableSharedMemoryRegion region_;
|
2022-07-04 11:49:15 +02:00
|
|
|
|
|
|
|
IMPLEMENT_REFCOUNTING(CefProcessMessageSMRImpl);
|
|
|
|
};
|
|
|
|
|
|
|
|
class CefSharedProcessMessageBuilderImpl final
|
|
|
|
: public CefSharedProcessMessageBuilder {
|
|
|
|
public:
|
|
|
|
CefSharedProcessMessageBuilderImpl(const CefString& name, size_t byte_size);
|
|
|
|
CefSharedProcessMessageBuilderImpl(const CefProcessMessageSMRImpl&) = delete;
|
|
|
|
CefSharedProcessMessageBuilderImpl& operator=(
|
|
|
|
const CefSharedProcessMessageBuilderImpl&) = delete;
|
|
|
|
|
|
|
|
bool IsValid() override;
|
|
|
|
size_t Size() override;
|
|
|
|
void* Memory() override;
|
|
|
|
CefRefPtr<CefProcessMessage> Build() override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
const CefString name_;
|
2023-10-17 00:43:29 +02:00
|
|
|
base::WritableSharedMemoryRegion region_;
|
|
|
|
base::WritableSharedMemoryMapping mapping_;
|
2022-07-04 11:49:15 +02:00
|
|
|
|
|
|
|
IMPLEMENT_REFCOUNTING(CefSharedProcessMessageBuilderImpl);
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // CEF_LIBCEF_COMMON_PROCESS_MESSAGE_SMR_IMPL_H_
|