linux: Pass v8 snapshot's fd to child process
This commit is contained in:
parent
a5b6ffd93c
commit
7e88fe107d
3 changed files with 49 additions and 1 deletions
|
@ -119,6 +119,8 @@
|
||||||
'defines': [
|
'defines': [
|
||||||
# We are using Release version libchromiumcontent:
|
# We are using Release version libchromiumcontent:
|
||||||
'NDEBUG',
|
'NDEBUG',
|
||||||
|
# Needed by gin:
|
||||||
|
'V8_USE_EXTERNAL_STARTUP_DATA',
|
||||||
# From skia_for_chromium_defines.gypi:
|
# From skia_for_chromium_defines.gypi:
|
||||||
'SK_SUPPORT_LEGACY_GETTOPDEVICE',
|
'SK_SUPPORT_LEGACY_GETTOPDEVICE',
|
||||||
'SK_SUPPORT_LEGACY_BITMAP_CONFIG',
|
'SK_SUPPORT_LEGACY_BITMAP_CONFIG',
|
||||||
|
|
|
@ -12,7 +12,9 @@
|
||||||
|
|
||||||
#include "base/base_paths.h"
|
#include "base/base_paths.h"
|
||||||
#include "base/path_service.h"
|
#include "base/path_service.h"
|
||||||
|
#include "content/public/common/content_descriptors.h"
|
||||||
#include "content/public/common/url_constants.h"
|
#include "content/public/common/url_constants.h"
|
||||||
|
#include "gin/public/isolate_holder.h"
|
||||||
|
|
||||||
namespace brightray {
|
namespace brightray {
|
||||||
|
|
||||||
|
@ -27,9 +29,14 @@ BrowserClient* BrowserClient::Get() {
|
||||||
}
|
}
|
||||||
|
|
||||||
BrowserClient::BrowserClient()
|
BrowserClient::BrowserClient()
|
||||||
: browser_main_parts_() {
|
: browser_main_parts_(nullptr) {
|
||||||
DCHECK(!g_browser_client);
|
DCHECK(!g_browser_client);
|
||||||
g_browser_client = this;
|
g_browser_client = this;
|
||||||
|
|
||||||
|
#if defined(OS_POSIX) && !defined(OS_MACOSX)
|
||||||
|
v8_natives_fd_.reset(-1);
|
||||||
|
v8_snapshot_fd_.reset(-1);
|
||||||
|
#endif // OS_POSIX && !OS_MACOSX
|
||||||
}
|
}
|
||||||
|
|
||||||
BrowserClient::~BrowserClient() {
|
BrowserClient::~BrowserClient() {
|
||||||
|
@ -86,4 +93,31 @@ content::DevToolsManagerDelegate* BrowserClient::GetDevToolsManagerDelegate() {
|
||||||
return new DevToolsManagerDelegate;
|
return new DevToolsManagerDelegate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(OS_POSIX) && !defined(OS_MACOSX)
|
||||||
|
void BrowserClient::GetAdditionalMappedFilesForChildProcess(
|
||||||
|
const base::CommandLine& command_line,
|
||||||
|
int child_process_id,
|
||||||
|
content::FileDescriptorInfo* mappings) {
|
||||||
|
if (v8_snapshot_fd_.get() == -1 && v8_natives_fd_.get() == -1) {
|
||||||
|
base::FilePath v8_data_path;
|
||||||
|
PathService::Get(gin::IsolateHolder::kV8SnapshotBasePathKey, &v8_data_path);
|
||||||
|
DCHECK(!v8_data_path.empty());
|
||||||
|
|
||||||
|
int file_flags = base::File::FLAG_OPEN | base::File::FLAG_READ;
|
||||||
|
base::FilePath v8_natives_data_path =
|
||||||
|
v8_data_path.AppendASCII(gin::IsolateHolder::kNativesFileName);
|
||||||
|
base::FilePath v8_snapshot_data_path =
|
||||||
|
v8_data_path.AppendASCII(gin::IsolateHolder::kSnapshotFileName);
|
||||||
|
base::File v8_natives_data_file(v8_natives_data_path, file_flags);
|
||||||
|
base::File v8_snapshot_data_file(v8_snapshot_data_path, file_flags);
|
||||||
|
DCHECK(v8_natives_data_file.IsValid());
|
||||||
|
DCHECK(v8_snapshot_data_file.IsValid());
|
||||||
|
v8_natives_fd_.reset(v8_natives_data_file.TakePlatformFile());
|
||||||
|
v8_snapshot_fd_.reset(v8_snapshot_data_file.TakePlatformFile());
|
||||||
|
}
|
||||||
|
mappings->Share(kV8NativesDataDescriptor, v8_natives_fd_.get());
|
||||||
|
mappings->Share(kV8SnapshotDataDescriptor, v8_snapshot_fd_.get());
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
} // namespace brightray
|
} // namespace brightray
|
||||||
|
|
|
@ -46,8 +46,20 @@ class BrowserClient : public content::ContentBrowserClient {
|
||||||
base::FilePath GetDefaultDownloadDirectory() override;
|
base::FilePath GetDefaultDownloadDirectory() override;
|
||||||
content::DevToolsManagerDelegate* GetDevToolsManagerDelegate() override;
|
content::DevToolsManagerDelegate* GetDevToolsManagerDelegate() override;
|
||||||
|
|
||||||
|
#if defined(OS_POSIX) && !defined(OS_MACOSX)
|
||||||
|
void GetAdditionalMappedFilesForChildProcess(
|
||||||
|
const base::CommandLine& command_line,
|
||||||
|
int child_process_id,
|
||||||
|
content::FileDescriptorInfo* mappings) override;
|
||||||
|
#endif
|
||||||
|
|
||||||
BrowserMainParts* browser_main_parts_;
|
BrowserMainParts* browser_main_parts_;
|
||||||
|
|
||||||
|
#if defined(OS_POSIX) && !defined(OS_MACOSX)
|
||||||
|
base::ScopedFD v8_natives_fd_;
|
||||||
|
base::ScopedFD v8_snapshot_fd_;
|
||||||
|
#endif // OS_POSIX && !OS_MACOSX
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(BrowserClient);
|
DISALLOW_COPY_AND_ASSIGN(BrowserClient);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue