feat: allow custom v8 snapshots to be used in the main process and the default snapshot in the renderer process (#35266)

* Updates to allow for using a custom v8 snapshot file name

* Allow using a custom v8 snapshot file name

* Fix up patch due to merge

* Use fuse to set up custom v8 snapshot file in browser process

* Refactor to use delegate instead of command line parameter

* Refactoring

* Update due to merge

* PR comments

* Rename patch

* Rename patch
This commit is contained in:
Ryan Manuel 2022-09-15 15:21:16 -05:00 committed by GitHub
parent 5cf15cdab7
commit f25c87dc70
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 183 additions and 1 deletions

View file

@ -23,6 +23,7 @@
#include "components/content_settings/core/common/content_settings_pattern.h"
#include "content/public/common/content_switches.h"
#include "electron/buildflags/buildflags.h"
#include "electron/fuses.h"
#include "extensions/common/constants.h"
#include "ipc/ipc_buildflags.h"
#include "sandbox/policy/switches.h"
@ -422,6 +423,20 @@ absl::optional<int> ElectronMainDelegate::PreBrowserMain() {
return absl::nullopt;
}
base::StringPiece ElectronMainDelegate::GetBrowserV8SnapshotFilename() {
const base::CommandLine* command_line =
base::CommandLine::ForCurrentProcess();
std::string process_type =
command_line->GetSwitchValueASCII(::switches::kProcessType);
bool load_browser_process_specific_v8_snapshot =
process_type.empty() &&
electron::fuses::IsLoadBrowserProcessSpecificV8SnapshotEnabled();
if (load_browser_process_specific_v8_snapshot) {
return "browser_v8_context_snapshot.bin";
}
return ContentMainDelegate::GetBrowserV8SnapshotFilename();
}
content::ContentBrowserClient*
ElectronMainDelegate::CreateContentBrowserClient() {
browser_client_ = std::make_unique<ElectronBrowserClient>();