| 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_SIMPLE_PLATFORM_SHARED_BUFFER_H_ | 5 #ifndef MOJO_EDK_EMBEDDER_SIMPLE_PLATFORM_SHARED_BUFFER_H_ |
| 6 #define MOJO_EDK_EMBEDDER_SIMPLE_PLATFORM_SHARED_BUFFER_H_ | 6 #define MOJO_EDK_EMBEDDER_SIMPLE_PLATFORM_SHARED_BUFFER_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include "mojo/edk/embedder/platform_shared_buffer.h" | 10 #include "mojo/edk/embedder/platform_shared_buffer.h" |
| 11 #include "mojo/edk/system/system_impl_export.h" | |
| 12 #include "mojo/public/cpp/system/macros.h" | 11 #include "mojo/public/cpp/system/macros.h" |
| 13 | 12 |
| 14 namespace mojo { | 13 namespace mojo { |
| 15 namespace embedder { | 14 namespace embedder { |
| 16 | 15 |
| 17 // A simple implementation of |PlatformSharedBuffer|. | 16 // A simple implementation of |PlatformSharedBuffer|. |
| 18 class MOJO_SYSTEM_IMPL_EXPORT SimplePlatformSharedBuffer final | 17 class SimplePlatformSharedBuffer final : public PlatformSharedBuffer { |
| 19 : public PlatformSharedBuffer { | |
| 20 public: | 18 public: |
| 21 // Creates a shared buffer of size |num_bytes| bytes (initially zero-filled). | 19 // Creates a shared buffer of size |num_bytes| bytes (initially zero-filled). |
| 22 // |num_bytes| must be nonzero. Returns null on failure. | 20 // |num_bytes| must be nonzero. Returns null on failure. |
| 23 static SimplePlatformSharedBuffer* Create(size_t num_bytes); | 21 static SimplePlatformSharedBuffer* Create(size_t num_bytes); |
| 24 | 22 |
| 25 static SimplePlatformSharedBuffer* CreateFromPlatformHandle( | 23 static SimplePlatformSharedBuffer* CreateFromPlatformHandle( |
| 26 size_t num_bytes, | 24 size_t num_bytes, |
| 27 ScopedPlatformHandle platform_handle); | 25 ScopedPlatformHandle platform_handle); |
| 28 | 26 |
| 29 // |PlatformSharedBuffer| implementation: | 27 // |PlatformSharedBuffer| implementation: |
| (...skipping 30 matching lines...) Expand all Loading... |
| 60 // This is set in |Init()|/|InitFromPlatformHandle()| and never modified | 58 // This is set in |Init()|/|InitFromPlatformHandle()| and never modified |
| 61 // (except by |PassPlatformHandle()|; see the comments above its declaration), | 59 // (except by |PassPlatformHandle()|; see the comments above its declaration), |
| 62 // hence does not need to be protected by a lock. | 60 // hence does not need to be protected by a lock. |
| 63 ScopedPlatformHandle handle_; | 61 ScopedPlatformHandle handle_; |
| 64 | 62 |
| 65 MOJO_DISALLOW_COPY_AND_ASSIGN(SimplePlatformSharedBuffer); | 63 MOJO_DISALLOW_COPY_AND_ASSIGN(SimplePlatformSharedBuffer); |
| 66 }; | 64 }; |
| 67 | 65 |
| 68 // An implementation of |PlatformSharedBufferMapping|, produced by | 66 // An implementation of |PlatformSharedBufferMapping|, produced by |
| 69 // |SimplePlatformSharedBuffer|. | 67 // |SimplePlatformSharedBuffer|. |
| 70 class MOJO_SYSTEM_IMPL_EXPORT SimplePlatformSharedBufferMapping | 68 class SimplePlatformSharedBufferMapping final |
| 71 : public PlatformSharedBufferMapping { | 69 : public PlatformSharedBufferMapping { |
| 72 public: | 70 public: |
| 73 ~SimplePlatformSharedBufferMapping() override; | 71 ~SimplePlatformSharedBufferMapping() override; |
| 74 | 72 |
| 75 void* GetBase() const override; | 73 void* GetBase() const override; |
| 76 size_t GetLength() const override; | 74 size_t GetLength() const override; |
| 77 | 75 |
| 78 private: | 76 private: |
| 79 friend class SimplePlatformSharedBuffer; | 77 friend class SimplePlatformSharedBuffer; |
| 80 | 78 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 94 void* const real_base_; | 92 void* const real_base_; |
| 95 const size_t real_length_; | 93 const size_t real_length_; |
| 96 | 94 |
| 97 MOJO_DISALLOW_COPY_AND_ASSIGN(SimplePlatformSharedBufferMapping); | 95 MOJO_DISALLOW_COPY_AND_ASSIGN(SimplePlatformSharedBufferMapping); |
| 98 }; | 96 }; |
| 99 | 97 |
| 100 } // namespace embedder | 98 } // namespace embedder |
| 101 } // namespace mojo | 99 } // namespace mojo |
| 102 | 100 |
| 103 #endif // MOJO_EDK_EMBEDDER_SIMPLE_PLATFORM_SHARED_BUFFER_H_ | 101 #endif // MOJO_EDK_EMBEDDER_SIMPLE_PLATFORM_SHARED_BUFFER_H_ |
| OLD | NEW |