/* -*- 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/. */
// Serialize the early prefs.
nsAutoCStringN<1024> prefs;
Preferences::SerializePreferences(prefs, destIsWebContent);
mPrefsLength = prefs.Length();
RefPtr<SharedMemory> shm = MakeRefPtr<SharedMemory>(); // Set up the shared memory. if (!shm->Create(prefs.Length())) {
NS_ERROR("failed to create shared memory in the parent"); returnfalse;
} if (!shm->Map(prefs.Length())) {
NS_ERROR("failed to map shared memory in the parent"); returnfalse;
}
// Copy the serialized prefs into the shared memory.
memcpy(static_cast<char*>(shm->Memory()), prefs.get(), mPrefsLength);
// Pass the handles and lengths via command line flags.
geckoargs::sPrefsHandle.Put(std::move(prefsHandle), aExtraOpts);
geckoargs::sPrefsLen.Put((uintptr_t)(GetPrefsLength()), aExtraOpts);
geckoargs::sPrefMapHandle.Put(std::move(prefMapHandle), aExtraOpts);
geckoargs::sPrefMapSize.Put((uintptr_t)(GetPrefMapSize()), aExtraOpts);
}
// Init the shared-memory base preference mapping first, so that only changed // preferences wind up in heap memory.
Preferences::InitSnapshot(mPrefMapHandle.ref(), *mPrefMapSize);
// Set up early prefs from the shared memory. if (!mShmem->SetHandle(std::move(aPrefsHandle),
SharedMemory::RightsReadOnly)) {
NS_ERROR("failed to open shared memory in the child"); returnfalse;
} if (!mShmem->Map(*mPrefsLen)) {
NS_ERROR("failed to map shared memory in the child"); returnfalse;
}
Preferences::DeserializePreferences(static_cast<char*>(mShmem->Memory()),
*mPrefsLen);
// If the file is not found or the content is empty, then we would start the // content process without this optimization. if (!SharedMemory::IsHandleValid(handle) || !len) {
NS_ERROR("Can't use SelfHosted shared memory handle."); return;
}
bool ImportSharedJSInit(SharedMemoryHandle aJsInitHandle, uint64_t aJsInitLen) { // This is an optimization, and as such we can safely recover if the command // line argument are not provided. if (!aJsInitLen || !aJsInitHandle) { returntrue;
}
size_t len = (uintptr_t)(aJsInitLen); if (!len) { returnfalse;
}
// Initialize the shared memory with the file handle and size of the content // of the self-hosted Xdr. auto& shmem = xpc::SelfHostedShmem::GetSingleton(); if (!shmem.InitFromChild(std::move(aJsInitHandle), len)) {
NS_ERROR("failed to open shared memory in the child"); returnfalse;
}
returntrue;
}
} // namespace ipc
} // namespace mozilla
¤ Dauer der Verarbeitung: 0.14 Sekunden
(vorverarbeitet)
¤
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.