Bug 1700051: part 31.4) Move `mSoftTextValid` to `SoftText`. r=smaug
[gecko.git] / ipc / glue / SharedMemoryBasic_android.h
blob7376a2a7865304ecfc164f2cff3cd0952a025360
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef mozilla_ipc_SharedMemoryBasic_android_h
8 #define mozilla_ipc_SharedMemoryBasic_android_h
10 #include "base/file_descriptor_posix.h"
12 #include "SharedMemory.h"
14 #ifdef FUZZING
15 # include "SharedMemoryFuzzer.h"
16 #endif
19 // This is a low-level wrapper around platform shared memory. Don't
20 // use it directly; use Shmem allocated through IPDL interfaces.
23 namespace mozilla {
24 namespace ipc {
26 class SharedMemoryBasic final
27 : public SharedMemoryCommon<base::FileDescriptor> {
28 public:
29 SharedMemoryBasic();
31 virtual bool SetHandle(const Handle& aHandle, OpenRights aRights) override;
33 virtual bool Create(size_t aNbytes) override;
35 virtual bool Map(size_t nBytes, void* fixed_address = nullptr) override;
37 virtual void Unmap() override;
39 virtual void CloseHandle() override;
41 virtual void* memory() const override {
42 #ifdef FUZZING
43 return SharedMemoryFuzzer::MutateSharedMemory(mMemory, mAllocSize);
44 #else
45 return mMemory;
46 #endif
49 virtual SharedMemoryType Type() const override { return TYPE_BASIC; }
51 static Handle NULLHandle() { return Handle(); }
53 static void* FindFreeAddressSpace(size_t aSize);
55 virtual bool IsHandleValid(const Handle& aHandle) const override {
56 return aHandle.fd >= 0;
59 virtual bool ShareToProcess(base::ProcessId aProcessId,
60 Handle* aNewHandle) override;
62 private:
63 ~SharedMemoryBasic();
65 // The /dev/ashmem fd we allocate.
66 int mShmFd;
67 // Pointer to mapped region, null if unmapped.
68 void* mMemory;
69 // Access rights to map an existing region with.
70 OpenRights mOpenRights;
73 } // namespace ipc
74 } // namespace mozilla
76 #endif // ifndef mozilla_ipc_SharedMemoryBasic_android_h