1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
4 /* This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
8 #ifndef mozilla_ipc_SharedMemoryBasic_android_h
9 #define mozilla_ipc_SharedMemoryBasic_android_h
11 #include "base/file_descriptor_posix.h"
13 #include "SharedMemory.h"
16 // This is a low-level wrapper around platform shared memory. Don't
17 // use it directly; use Shmem allocated through IPDL interfaces.
23 class SharedMemoryBasic
: public SharedMemory
26 typedef base::FileDescriptor Handle
;
30 SharedMemoryBasic(const Handle
& aHandle
);
32 virtual ~SharedMemoryBasic();
34 virtual bool Create(size_t aNbytes
) MOZ_OVERRIDE
;
36 virtual bool Map(size_t nBytes
) MOZ_OVERRIDE
;
38 virtual void* memory() const MOZ_OVERRIDE
43 virtual SharedMemoryType
Type() const MOZ_OVERRIDE
48 static Handle
NULLHandle()
53 static bool IsHandleValid(const Handle
&aHandle
)
55 return aHandle
.fd
>= 0;
58 bool ShareToProcess(base::ProcessHandle aProcess
,
65 // The /dev/ashmem fd we allocate.
67 // Pointer to mapped region, null if unmapped.
72 } // namespace mozilla
74 #endif // ifndef mozilla_ipc_SharedMemoryBasic_android_h