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 THIRD_PARTY_MOJO_SRC_MOJO_EDK_SYSTEM_MAPPING_TABLE_H_ | 5 #ifndef MOJO_EDK_SYSTEM_MAPPING_TABLE_H_ |
6 #define THIRD_PARTY_MOJO_SRC_MOJO_EDK_SYSTEM_MAPPING_TABLE_H_ | 6 #define MOJO_EDK_SYSTEM_MAPPING_TABLE_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/containers/hash_tables.h" | 12 #include "base/containers/hash_tables.h" |
13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 14 #include "mojo/edk/system/system_impl_export.h" |
14 #include "mojo/public/c/system/types.h" | 15 #include "mojo/public/c/system/types.h" |
15 #include "mojo/public/cpp/system/macros.h" | 16 #include "mojo/public/cpp/system/macros.h" |
16 #include "third_party/mojo/src/mojo/edk/system/system_impl_export.h" | |
17 | 17 |
18 namespace mojo { | 18 namespace mojo { |
19 | 19 |
20 namespace embedder { | 20 namespace edk { |
| 21 class Core; |
21 class PlatformSharedBufferMapping; | 22 class PlatformSharedBufferMapping; |
22 } | |
23 | |
24 namespace system { | |
25 | |
26 class Core; | |
27 | 23 |
28 // Test-only function (defined/used in embedder/test_embedder.cc). Declared here | 24 // Test-only function (defined/used in embedder/test_embedder.cc). Declared here |
29 // so it can be friended. | 25 // so it can be friended. |
30 namespace internal { | 26 namespace internal { |
31 bool ShutdownCheckNoLeaks(Core*); | 27 bool ShutdownCheckNoLeaks(Core*); |
32 } | 28 } |
33 | 29 |
34 // This class provides the (global) table of memory mappings (owned by |Core|), | 30 // This class provides the (global) table of memory mappings (owned by |Core|), |
35 // which maps mapping base addresses to |PlatformSharedBufferMapping|s. | 31 // which maps mapping base addresses to |PlatformSharedBufferMapping|s. |
36 // | 32 // |
37 // This class is NOT thread-safe; locking is left to |Core|. | 33 // This class is NOT thread-safe; locking is left to |Core|. |
38 class MOJO_SYSTEM_IMPL_EXPORT MappingTable { | 34 class MOJO_SYSTEM_IMPL_EXPORT MappingTable { |
39 public: | 35 public: |
40 MappingTable(); | 36 MappingTable(); |
41 ~MappingTable(); | 37 ~MappingTable(); |
42 | 38 |
43 // Tries to add a mapping. (Takes ownership of the mapping in all cases; on | 39 // Tries to add a mapping. (Takes ownership of the mapping in all cases; on |
44 // failure, it will be destroyed.) | 40 // failure, it will be destroyed.) |
45 MojoResult AddMapping( | 41 MojoResult AddMapping(scoped_ptr<PlatformSharedBufferMapping> mapping); |
46 scoped_ptr<embedder::PlatformSharedBufferMapping> mapping); | 42 MojoResult RemoveMapping(void* address); |
47 MojoResult RemoveMapping(uintptr_t address); | |
48 | 43 |
49 private: | 44 private: |
50 friend bool internal::ShutdownCheckNoLeaks(Core*); | 45 friend bool internal::ShutdownCheckNoLeaks(Core*); |
51 | 46 |
52 using AddressToMappingMap = | 47 using AddressToMappingMap = |
53 base::hash_map<uintptr_t, embedder::PlatformSharedBufferMapping*>; | 48 base::hash_map<void*, PlatformSharedBufferMapping*>; |
54 AddressToMappingMap address_to_mapping_map_; | 49 AddressToMappingMap address_to_mapping_map_; |
55 | 50 |
56 MOJO_DISALLOW_COPY_AND_ASSIGN(MappingTable); | 51 MOJO_DISALLOW_COPY_AND_ASSIGN(MappingTable); |
57 }; | 52 }; |
58 | 53 |
59 } // namespace system | 54 } // namespace edk |
60 } // namespace mojo | 55 } // namespace mojo |
61 | 56 |
62 #endif // THIRD_PARTY_MOJO_SRC_MOJO_EDK_SYSTEM_MAPPING_TABLE_H_ | 57 #endif // MOJO_EDK_SYSTEM_MAPPING_TABLE_H_ |
OLD | NEW |