mmap V8 snapshot and ICU data file in the android_webview
This makes it possible to mmap the V8 snapshot and ICU data file
directly from the WebView APK.
Doing so makes it possible to remove the android_webview_telemetry_build
flag which in turns means we can build the WebView with the same
set of flags that Chrome on Android uses.
BUG=442338
Review URL: https://codereview.chromium.org/812393002
Cr-Commit-Position: refs/heads/master@{#310765}
diff --git a/content/app/content_main_runner.cc b/content/app/content_main_runner.cc
index 2da7dc1..87950670 100644
--- a/content/app/content_main_runner.cc
+++ b/content/app/content_main_runner.cc
@@ -716,10 +716,14 @@
#if defined(OS_ANDROID)
int icudata_fd = base::GlobalDescriptors::GetInstance()->MaybeGet(
kAndroidICUDataDescriptor);
- if (icudata_fd != -1)
- CHECK(base::i18n::InitializeICUWithFileDescriptor(icudata_fd));
- else
+ if (icudata_fd != -1) {
+ auto icudata_region = base::GlobalDescriptors::GetInstance()->GetRegion(
+ kAndroidICUDataDescriptor);
+ CHECK(base::i18n::InitializeICUWithFileDescriptor(icudata_fd,
+ icudata_region));
+ } else {
CHECK(base::i18n::InitializeICU());
+ }
#if defined(V8_USE_EXTERNAL_STARTUP_DATA)
int v8_natives_fd = base::GlobalDescriptors::GetInstance()->MaybeGet(
@@ -727,8 +731,15 @@
int v8_snapshot_fd = base::GlobalDescriptors::GetInstance()->MaybeGet(
kV8SnapshotDataDescriptor);
if (v8_natives_fd != -1 && v8_snapshot_fd != -1) {
- CHECK(gin::IsolateHolder::LoadV8SnapshotFD(v8_natives_fd,
- v8_snapshot_fd));
+ auto v8_natives_region =
+ base::GlobalDescriptors::GetInstance()->GetRegion(
+ kV8NativesDataDescriptor);
+ auto v8_snapshot_region =
+ base::GlobalDescriptors::GetInstance()->GetRegion(
+ kV8SnapshotDataDescriptor);
+ CHECK(gin::IsolateHolder::LoadV8SnapshotFd(
+ v8_natives_fd, v8_natives_region.offset, v8_natives_region.size,
+ v8_snapshot_fd, v8_snapshot_region.offset, v8_snapshot_region.size));
} else {
CHECK(gin::IsolateHolder::LoadV8Snapshot());
}