OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2008 The Native Client Authors. All rights reserved. | 2 * Copyright 2008 The Native Client Authors. All rights reserved. |
3 * Use of this source code is governed by a BSD-style license that can | 3 * Use of this source code is governed by a BSD-style license that can |
4 * be found in the LICENSE file. | 4 * be found in the LICENSE file. |
5 */ | 5 */ |
6 | 6 |
7 // A portable representation of a scriptable shared memory object. | 7 // A portable representation of a scriptable shared memory object. |
8 | 8 |
9 #ifndef NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_SRPC_SHARED_MEMORY_H_ | 9 #ifndef NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_SHARED_MEMORY_H_ |
10 #define NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_SRPC_SHARED_MEMORY_H_ | 10 #define NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_SHARED_MEMORY_H_ |
11 | 11 |
12 #include <setjmp.h> | 12 #include <setjmp.h> |
13 #include <stdio.h> | 13 #include <stdio.h> |
14 | 14 |
15 #include "native_client/src/include/nacl_macros.h" | 15 #include "native_client/src/include/nacl_macros.h" |
16 #include "native_client/src/trusted/desc/nacl_desc_imc_shm.h" | 16 #include "native_client/src/trusted/desc/nacl_desc_imc_shm.h" |
17 #include "native_client/src/trusted/desc/nacl_desc_wrapper.h" | 17 #include "native_client/src/trusted/desc/nacl_desc_wrapper.h" |
18 #include "native_client/src/trusted/plugin/srpc/desc_based_handle.h" | 18 #include "native_client/src/trusted/plugin/desc_based_handle.h" |
19 #include "native_client/src/trusted/plugin/srpc/utility.h" | 19 #include "native_client/src/trusted/plugin/utility.h" |
20 | 20 |
21 namespace plugin { | 21 namespace plugin { |
22 | 22 |
23 class Plugin; | 23 class Plugin; |
24 | 24 |
25 // SharedMemory is used to represent shared memory descriptors. | 25 // SharedMemory is used to represent shared memory descriptors. |
26 class SharedMemory : public DescBasedHandle { | 26 class SharedMemory : public DescBasedHandle { |
27 public: | 27 public: |
28 static SharedMemory* New(Plugin* plugin, nacl::DescWrapper* wrapper); | 28 static SharedMemory* New(Plugin* plugin, nacl::DescWrapper* wrapper); |
29 static SharedMemory* New(Plugin* plugin, off_t length); | 29 static SharedMemory* New(Plugin* plugin, off_t length); |
30 | 30 |
31 virtual void* shm_addr() const { return addr_; } | 31 virtual void* shm_addr() const { return addr_; } |
32 virtual size_t shm_size() const { return size_; } | 32 virtual size_t shm_size() const { return size_; } |
33 | 33 |
34 private: | 34 private: |
35 NACL_DISALLOW_COPY_AND_ASSIGN(SharedMemory); | 35 NACL_DISALLOW_COPY_AND_ASSIGN(SharedMemory); |
36 // These are private because there are no derived classes from | 36 // These are private because there are no derived classes from |
37 // SharedMemory. | 37 // SharedMemory. |
38 SharedMemory(); | 38 SharedMemory(); |
39 ~SharedMemory(); | 39 ~SharedMemory(); |
40 bool Init(Plugin* plugin, nacl::DescWrapper* wrapper, off_t length); | 40 bool Init(Plugin* plugin, nacl::DescWrapper* wrapper, off_t length); |
41 void LoadMethods(); | 41 void LoadMethods(); |
42 NaClHandle handle_; | 42 NaClHandle handle_; |
43 void* addr_; | 43 void* addr_; |
44 size_t size_; | 44 size_t size_; |
45 }; | 45 }; |
46 | 46 |
47 } // namespace plugin | 47 } // namespace plugin |
48 | 48 |
49 #endif // NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_SRPC_SHARED_MEMORY_H_ | 49 #endif // NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_SHARED_MEMORY_H_ |
OLD | NEW |