| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef MOJO_EDK_EMBEDDER_PLATFORM_SHARED_BUFFER_H_ | 5 #ifndef MOJO_EDK_EMBEDDER_PLATFORM_SHARED_BUFFER_H_ |
| 6 #define MOJO_EDK_EMBEDDER_PLATFORM_SHARED_BUFFER_H_ | 6 #define MOJO_EDK_EMBEDDER_PLATFORM_SHARED_BUFFER_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| 11 | 11 |
| 12 #include "mojo/edk/embedder/scoped_platform_handle.h" | 12 #include "mojo/edk/platform/scoped_platform_handle.h" |
| 13 #include "mojo/edk/util/ref_counted.h" | 13 #include "mojo/edk/util/ref_counted.h" |
| 14 #include "mojo/public/cpp/system/macros.h" | 14 #include "mojo/public/cpp/system/macros.h" |
| 15 | 15 |
| 16 namespace mojo { | 16 namespace mojo { |
| 17 namespace embedder { | 17 namespace embedder { |
| 18 | 18 |
| 19 class PlatformSharedBufferMapping; | 19 class PlatformSharedBufferMapping; |
| 20 | 20 |
| 21 // |PlatformSharedBuffer| is an interface for a thread-safe, ref-counted wrapper | 21 // |PlatformSharedBuffer| is an interface for a thread-safe, ref-counted wrapper |
| 22 // around OS-specific shared memory. It has the following features: | 22 // around OS-specific shared memory. It has the following features: |
| (...skipping 26 matching lines...) Expand all Loading... |
| 49 virtual bool IsValidMap(size_t offset, size_t length) = 0; | 49 virtual bool IsValidMap(size_t offset, size_t length) = 0; |
| 50 | 50 |
| 51 // Like |Map()|, but doesn't check its arguments (which should have been | 51 // Like |Map()|, but doesn't check its arguments (which should have been |
| 52 // preflighted using |IsValidMap()|). | 52 // preflighted using |IsValidMap()|). |
| 53 virtual std::unique_ptr<PlatformSharedBufferMapping> MapNoCheck( | 53 virtual std::unique_ptr<PlatformSharedBufferMapping> MapNoCheck( |
| 54 size_t offset, | 54 size_t offset, |
| 55 size_t length) = 0; | 55 size_t length) = 0; |
| 56 | 56 |
| 57 // Duplicates the underlying platform handle and passes it to the caller. | 57 // Duplicates the underlying platform handle and passes it to the caller. |
| 58 // TODO(vtl): On POSIX, we'll need two FDs to support sharing read-only. | 58 // TODO(vtl): On POSIX, we'll need two FDs to support sharing read-only. |
| 59 virtual ScopedPlatformHandle DuplicatePlatformHandle() = 0; | 59 virtual platform::ScopedPlatformHandle DuplicatePlatformHandle() = 0; |
| 60 | 60 |
| 61 // Passes the underlying platform handle to the caller. This should only be | 61 // Passes the underlying platform handle to the caller. This should only be |
| 62 // called if there's a unique reference to this object (owned by the caller). | 62 // called if there's a unique reference to this object (owned by the caller). |
| 63 // After calling this, this object should no longer be used, but should only | 63 // After calling this, this object should no longer be used, but should only |
| 64 // be disposed of. | 64 // be disposed of. |
| 65 virtual ScopedPlatformHandle PassPlatformHandle() = 0; | 65 virtual platform::ScopedPlatformHandle PassPlatformHandle() = 0; |
| 66 | 66 |
| 67 protected: | 67 protected: |
| 68 friend class util::RefCountedThreadSafe<PlatformSharedBuffer>; | 68 friend class util::RefCountedThreadSafe<PlatformSharedBuffer>; |
| 69 | 69 |
| 70 PlatformSharedBuffer() {} | 70 PlatformSharedBuffer() {} |
| 71 virtual ~PlatformSharedBuffer() {} | 71 virtual ~PlatformSharedBuffer() {} |
| 72 | 72 |
| 73 private: | 73 private: |
| 74 MOJO_DISALLOW_COPY_AND_ASSIGN(PlatformSharedBuffer); | 74 MOJO_DISALLOW_COPY_AND_ASSIGN(PlatformSharedBuffer); |
| 75 }; | 75 }; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 94 PlatformSharedBufferMapping() {} | 94 PlatformSharedBufferMapping() {} |
| 95 | 95 |
| 96 private: | 96 private: |
| 97 MOJO_DISALLOW_COPY_AND_ASSIGN(PlatformSharedBufferMapping); | 97 MOJO_DISALLOW_COPY_AND_ASSIGN(PlatformSharedBufferMapping); |
| 98 }; | 98 }; |
| 99 | 99 |
| 100 } // namespace embedder | 100 } // namespace embedder |
| 101 } // namespace mojo | 101 } // namespace mojo |
| 102 | 102 |
| 103 #endif // MOJO_EDK_EMBEDDER_PLATFORM_SHARED_BUFFER_H_ | 103 #endif // MOJO_EDK_EMBEDDER_PLATFORM_SHARED_BUFFER_H_ |
| OLD | NEW |