/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/* This source code was derived from Chromium code, and as such is also subject
* to the [Chromium license](ipc/chromium/src/LICENSE). */
class ShmemReporter final : public nsIMemoryReporter {
~ShmemReporter() = default;
public:
NS_DECL_THREADSAFE_ISUPPORTS
NS_IMETHOD
CollectReports(nsIHandleReportCallback* aHandleReport, nsISupports* aData, bool aAnonymize) override {
MOZ_COLLECT_REPORT( "shmem-allocated", KIND_OTHER, UNITS_BYTES, gShmemAllocated, "Memory shared with other processes that is accessible (but not " "necessarily mapped).");
MOZ_COLLECT_REPORT( "shmem-mapped", KIND_OTHER, UNITS_BYTES, gShmemMapped, "Memory shared with other processes that is mapped into the address " "space.");
Span<uint8_t> SharedMemory::TakeMapping() { // NOTE: this doesn't reduce gShmemMapped since it _is_ still mapped memory // (and will be until the process terminates). return {static_cast<uint8_t*>(mMemory.release()),
std::exchange(mMappedSize, 0)};
}
void SharedMemory::Protect(char* aAddr, size_t aSize, int aRights) { // Don't allow altering of rights on freezable shared memory handles.
MOZ_ASSERT(!mFreezable);
char* memStart = reinterpret_cast<char*>(Memory()); if (!memStart) MOZ_CRASH("SharedMemory region points at NULL!"); char* memEnd = memStart + Size();
char* protStart = aAddr; if (!protStart) MOZ_CRASH("trying to Protect() a NULL region!"); char* protEnd = protStart + aSize;
if (!(memStart <= protStart && protEnd <= memEnd)) {
MOZ_CRASH("attempt to Protect() a region outside this SharedMemory");
}
// checks alignment etc.
SystemProtect(aAddr, aSize, aRights);
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.