0
Files
src/content/browser/v8_snapshot_files.h
Matthew Denton c46d14cb0c Allow use of files_to_preload with existing file descriptors.
...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).

 can be modified with
ChildProcessLauncherFileData::additional_remapped_fds,  can be
modified with
ContentBrowserClient::GetAdditionalMappedFilesForChildProcess(), and
 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}
2023-01-11 00:59:21 +00:00

29 lines
896 B
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.
#ifndef CONTENT_BROWSER_V8_SNAPSHOT_FILES_H_
#define CONTENT_BROWSER_V8_SNAPSHOT_FILES_H_
#include <map>
#include <string>
#include "base/files/file_path.h"
#include "base/files/scoped_file.h"
#include "third_party/abseil-cpp/absl/types/variant.h"
namespace content {
// Returns a mapping of V8 snapshot files to be preloaded for child processes
// that use V8. Note that this is defined on all platforms even though it may
// be empty or unused on some.
//
// This mapping can be used in `content::ChildProcessLauncherFileData` when
// constructing a ChildProcessLauncher.
std::map<std::string, absl::variant<base::FilePath, base::ScopedFD>>
GetV8SnapshotFilesToPreload();
} // namespace content
#endif // CONTENT_BROWSER_V8_SNAPSHOT_FILES_H_