Bug 932076 - Add check for MediaExtractor creation failure. r=doublec
[gecko.git] / ipc / glue / SharedMemoryBasic_android.h
blob681a2cb538223b173c345f1a59cd2410f27df9e0
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 : public SharedMemory
25 public:
26 typedef base::FileDescriptor Handle;
28 SharedMemoryBasic();
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
40 return mMemory;
43 virtual SharedMemoryType Type() const MOZ_OVERRIDE
45 return TYPE_BASIC;
48 static Handle NULLHandle()
50 return Handle();
53 static bool IsHandleValid(const Handle &aHandle)
55 return aHandle.fd >= 0;
58 bool ShareToProcess(base::ProcessHandle aProcess,
59 Handle* aNewHandle);
61 private:
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