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
3 // found in the LICENSE file.
5 #ifndef MOJO_SYSTEM_MAPPING_TABLE_H_
6 #define MOJO_SYSTEM_MAPPING_TABLE_H_
12 #include "base/containers/hash_tables.h"
13 #include "base/macros.h"
14 #include "base/memory/scoped_ptr.h"
15 #include "mojo/public/c/system/core.h"
16 #include "mojo/system/system_impl_export.h"
22 class RawSharedBufferMapping
;
24 // Test-only function (defined/used in embedder/test_embedder.cc). Declared here
25 // so it can be friended.
27 bool ShutdownCheckNoLeaks(Core
*);
30 // This class provides the (global) table of memory mappings (owned by |Core|),
31 // which maps mapping base addresses to |RawSharedBuffer::Mapping|s.
33 // This class is NOT thread-safe; locking is left to |Core|.
34 class MOJO_SYSTEM_IMPL_EXPORT MappingTable
{
39 // Tries to add a mapping. (Takes ownership of the mapping in all cases; on
40 // failure, it will be destroyed.)
41 MojoResult
AddMapping(scoped_ptr
<RawSharedBufferMapping
> mapping
);
42 MojoResult
RemoveMapping(void* address
);
45 friend bool internal::ShutdownCheckNoLeaks(Core
*);
47 typedef base::hash_map
<uintptr_t, RawSharedBufferMapping
*>
49 AddressToMappingMap address_to_mapping_map_
;
51 DISALLOW_COPY_AND_ASSIGN(MappingTable
);
57 #endif // MOJO_SYSTEM_MAPPING_TABLE_H_