Bumping manifests a=b2g-bump
[gecko.git] / ipc / glue / SharedMemoryBasic_android.h
blobf0dfaa1ff8d3351adb10964b8f4971a96e510118
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 * vim: sw=2 ts=8 et :
3 */
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.
20 namespace mozilla {
21 namespace ipc {
23 class SharedMemoryBasic MOZ_FINAL : public SharedMemory
25 public:
26 typedef base::FileDescriptor Handle;
28 SharedMemoryBasic();
30 SharedMemoryBasic(const Handle& aHandle);
32 virtual bool Create(size_t aNbytes) MOZ_OVERRIDE;
34 virtual bool Map(size_t nBytes) MOZ_OVERRIDE;
36 virtual void* memory() const MOZ_OVERRIDE
38 return mMemory;
41 virtual SharedMemoryType Type() const MOZ_OVERRIDE
43 return TYPE_BASIC;
46 static Handle NULLHandle()
48 return Handle();
51 static bool IsHandleValid(const Handle &aHandle)
53 return aHandle.fd >= 0;
56 bool ShareToProcess(base::ProcessHandle aProcess,
57 Handle* aNewHandle);
59 private:
60 ~SharedMemoryBasic();
62 void Unmap();
63 void Destroy();
65 // The /dev/ashmem fd we allocate.
66 int mShmFd;
67 // Pointer to mapped region, null if unmapped.
68 void *mMemory;
71 } // namespace ipc
72 } // namespace mozilla
74 #endif // ifndef mozilla_ipc_SharedMemoryBasic_android_h