flutter_flutter/mojo/edk/system/mapping_table.h
James Robinson 5bb2480bcd Update to Mojo 4e4d51ce28a8edcb32b9c7f555e38e2ae84a825e, update deps
This updates to mojo 4e4d51ce28a and mojo sdk 711a0bcfb141b4 and updates the sky
package's pubspec.yaml dependency to '>=0.1.0 <0.2.0' to be compatible with
the current mojo package. This includes an update to the Mojo Dart generator to
produce real classes for enums and the corresponding updates for users of the
KeyboardType enum in Sky as well as one scoped_ptr->std::unique_ptr in shell
corresponding to a change in the Mojo EDK.

When a new version of the sky and sky_services package are pushed this will fix
domokit/mojo#440.
2015-09-23 17:26:46 -07:00

63 lines
1.6 KiB
C++

// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef MOJO_EDK_SYSTEM_MAPPING_TABLE_H_
#define MOJO_EDK_SYSTEM_MAPPING_TABLE_H_
#include <stdint.h>
#include <memory>
#include <unordered_map>
#include <vector>
#include "mojo/public/c/system/types.h"
#include "mojo/public/cpp/system/macros.h"
namespace mojo {
namespace embedder {
class PlatformSharedBufferMapping;
}
namespace system {
class Core;
// Test-only function (defined/used in embedder/test_embedder.cc). Declared here
// so it can be friended.
namespace internal {
bool ShutdownCheckNoLeaks(Core*);
}
// This class provides the (global) table of memory mappings (owned by |Core|),
// which maps mapping base addresses to |PlatformSharedBufferMapping|s.
//
// This class is NOT thread-safe; locking is left to |Core|.
class MappingTable {
public:
MappingTable();
~MappingTable();
// Tries to add a mapping. (Takes ownership of the mapping in all cases; on
// failure, it will be destroyed.)
MojoResult AddMapping(
std::unique_ptr<embedder::PlatformSharedBufferMapping> mapping);
MojoResult RemoveMapping(uintptr_t address);
private:
friend bool internal::ShutdownCheckNoLeaks(Core*);
// TODO(vtl): Should the value type be |std::unique_ptr|?
using AddressToMappingMap =
std::unordered_map<uintptr_t, embedder::PlatformSharedBufferMapping*>;
AddressToMappingMap address_to_mapping_map_;
MOJO_DISALLOW_COPY_AND_ASSIGN(MappingTable);
};
} // namespace system
} // namespace mojo
#endif // MOJO_EDK_SYSTEM_MAPPING_TABLE_H_