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"
15 # include "SharedMemoryFuzzer.h"
19 // This is a low-level wrapper around platform shared memory. Don't
20 // use it directly; use Shmem allocated through IPDL interfaces.
26 class SharedMemoryBasic final
27 : public SharedMemoryCommon
<base::FileDescriptor
> {
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
{
43 return SharedMemoryFuzzer::MutateSharedMemory(mMemory
, mAllocSize
);
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
;
65 // The /dev/ashmem fd we allocate.
67 // Pointer to mapped region, null if unmapped.
69 // Access rights to map an existing region with.
70 OpenRights mOpenRights
;
74 } // namespace mozilla
76 #endif // ifndef mozilla_ipc_SharedMemoryBasic_android_h