Index: content/common/gpu/media/shared_memory_region.h |
diff --git a/content/common/gpu/media/shared_memory_region.h b/content/common/gpu/media/shared_memory_region.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..a06f47273cb3d55760acd72b4a6920bb7609f861 |
--- /dev/null |
+++ b/content/common/gpu/media/shared_memory_region.h |
@@ -0,0 +1,46 @@ |
+// Copyright (c) 2015 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef CONTENT_COMMON_GPU_MEDIA_SHARED_MEMORY_REGION_H_ |
+#define CONTENT_COMMON_GPU_MEDIA_SHARED_MEMORY_REGION_H_ |
+ |
+#include "base/memory/shared_memory.h" |
+#include "media/base/bitstream_buffer.h" |
+ |
+namespace content { |
+ |
+// Helper class to access a region of a SharedMemory. |
+class SharedMemoryRegion { |
+ public: |
+ SharedMemoryRegion(const base::SharedMemoryHandle& handle, |
Pawel Osciak
2015/12/31 02:05:54
We should document arguments, especially offset an
Owen Lin
2016/01/04 08:54:17
Done.
|
+ off_t offset, |
+ size_t size, |
+ bool read_only); |
+ |
+ SharedMemoryRegion(const media::BitstreamBuffer& bitstream_buffer, |
+ bool read_only); |
+ |
+ // Maps the shared memory into the caller's address space. |
+ // Return true on success, false otherwise. |
+ bool Map(); |
+ |
+ // Gets a pointer to the mapped region if it has been mapped via Map(). |
+ // Returns |nullptr| if it is not mapped. |
+ void* memory(); |
Pawel Osciak
2015/12/31 02:05:54
We should document how this relates to offset and
Owen Lin
2016/01/04 08:54:17
Done.
|
+ |
+ size_t size() const { return size_; } |
+ |
+ off_t offset() const { return offset_; } |
Pawel Osciak
2015/12/31 02:05:53
Is this used anywhere?
Owen Lin
2016/01/04 08:54:17
No, let me remove it.
|
+ |
+ private: |
+ base::SharedMemory shm_; |
+ off_t offset_; |
+ size_t size_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(SharedMemoryRegion); |
+}; |
+ |
+} // namespace content |
+ |
+#endif // CONTENT_COMMON_GPU_MEDIA_SHARED_MEMORY_REGION_H_ |