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_chromium_h
9 #define mozilla_ipc_SharedMemoryBasic_chromium_h
11 #include "base/shared_memory.h"
12 #include "SharedMemory.h"
17 // This is a low-level wrapper around platform shared memory. Don't
18 // use it directly; use Shmem allocated through IPDL interfaces.
24 class SharedMemoryBasic
: public SharedMemory
27 typedef base::SharedMemoryHandle Handle
;
33 SharedMemoryBasic(const Handle
& aHandle
)
34 : mSharedMemory(aHandle
, false)
38 virtual bool Create(size_t aNbytes
) MOZ_OVERRIDE
40 bool ok
= mSharedMemory
.Create("", false, false, aNbytes
);
47 virtual bool Map(size_t nBytes
) MOZ_OVERRIDE
49 bool ok
= mSharedMemory
.Map(nBytes
);
56 virtual void* memory() const MOZ_OVERRIDE
58 return mSharedMemory
.memory();
61 virtual SharedMemoryType
Type() const MOZ_OVERRIDE
66 static Handle
NULLHandle()
68 return base::SharedMemory::NULLHandle();
71 static bool IsHandleValid(const Handle
&aHandle
)
73 return base::SharedMemory::IsHandleValid(aHandle
);
76 bool ShareToProcess(base::ProcessHandle process
,
79 base::SharedMemoryHandle handle
;
80 bool ret
= mSharedMemory
.ShareToProcess(process
, &handle
);
87 base::SharedMemory mSharedMemory
;
91 } // namespace mozilla
94 #endif // ifndef mozilla_ipc_SharedMemoryBasic_chromium_h