
...so we can use FileDescriptorStore with fds that don't refer to regular files. Right now ChildProcessLauncherFileData's files_to_preload is the only way to pass a file via FileDescriptorStore without editing child_process_launcher internals, so make it hold a variant<FilePath, int> instead of just a FilePath. NOTE: At this point on Linux there are 3 ways to "name" file descriptors passed to a child process: 1. Normal file descriptor table 2. base::GlobalDescriptors (integer keys map to fd numbers) 3. base::FileDescriptorStore (string keys map to base::GlobalDescriptors keys). #1 can be modified with ChildProcessLauncherFileData::additional_remapped_fds, #2 can be modified with ContentBrowserClient::GetAdditionalMappedFilesForChildProcess(), and #3 can be modified with ChildProcessLauncherFileData::files_to_preload. Bug: 692619 Change-Id: I1cc678887cb44830f74614ffbeb027791aeb6505 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4141862 Commit-Queue: Matthew Denton <mpdenton@chromium.org> Reviewed-by: Bo Liu <boliu@chromium.org> Cr-Commit-Position: refs/heads/main@{#1091118}
39 lines
1.4 KiB
C++
39 lines
1.4 KiB
C++
// Copyright 2019 The Chromium Authors
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
#include "content/browser/v8_snapshot_files.h"
|
|
|
|
#include "build/build_config.h"
|
|
#include "content/public/common/content_descriptor_keys.h"
|
|
#include "tools/v8_context_snapshot/buildflags.h"
|
|
|
|
namespace content {
|
|
|
|
std::map<std::string, absl::variant<base::FilePath, base::ScopedFD>>
|
|
GetV8SnapshotFilesToPreload() {
|
|
std::map<std::string, absl::variant<base::FilePath, base::ScopedFD>> files;
|
|
#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
|
|
#if BUILDFLAG(USE_V8_CONTEXT_SNAPSHOT)
|
|
files[kV8ContextSnapshotDataDescriptor] = base::FilePath(
|
|
FILE_PATH_LITERAL(BUILDFLAG(V8_CONTEXT_SNAPSHOT_FILENAME)));
|
|
#else
|
|
files[kV8SnapshotDataDescriptor] =
|
|
base::FilePath(FILE_PATH_LITERAL("snapshot_blob.bin"));
|
|
#endif
|
|
#elif BUILDFLAG(IS_ANDROID)
|
|
#if !BUILDFLAG(USE_V8_CONTEXT_SNAPSHOT)
|
|
files[kV8Snapshot64DataDescriptor] =
|
|
base::FilePath(FILE_PATH_LITERAL("assets/snapshot_blob_64.bin"));
|
|
files[kV8Snapshot32DataDescriptor] =
|
|
base::FilePath(FILE_PATH_LITERAL("assets/snapshot_blob_32.bin"));
|
|
#elif BUILDFLAG(USE_V8_CONTEXT_SNAPSHOT)
|
|
// For USE_V8_CONTEXT_SNAPSHOT, the renderer reads the files directly.
|
|
return {};
|
|
#endif
|
|
#endif // BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
|
|
return files;
|
|
}
|
|
|
|
} // namespace content
|