Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(133)

Unified Diff: content/browser/child_process_launcher.cc

Issue 2613803003: Simplifying ContentBrowserClient::GetAdditionalMappedFiles...() (Closed)
Patch Set: Addressed jam@'s comment Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/browser/child_process_launcher.cc
diff --git a/content/browser/child_process_launcher.cc b/content/browser/child_process_launcher.cc
index e93bb08efd4846340e6c467b0c349efee237bdb2..51f5696d31456265c29fc75933f95628aada588b 100644
--- a/content/browser/child_process_launcher.cc
+++ b/content/browser/child_process_launcher.cc
@@ -174,23 +174,15 @@ void LaunchOnLauncherThread(
#endif
#if defined(OS_POSIX) && !defined(OS_MACOSX)
- std::map<int, base::MemoryMappedFile::Region> regions;
GetContentClient()->browser()->GetAdditionalMappedFilesForChildProcess(
- *cmd_line, child_process_id, files_to_register.get()
-#if defined(OS_ANDROID)
- , &regions
-#endif
- );
+ *cmd_line, child_process_id, files_to_register.get());
#if defined(V8_USE_EXTERNAL_STARTUP_DATA)
bool snapshot_loaded = false;
-#if defined(OS_ANDROID)
base::MemoryMappedFile::Region region;
- auto maybe_register = [&region, &regions, &files_to_register](int key,
- int fd) {
- if (fd != -1) {
- files_to_register->Share(key, fd);
- regions.insert(std::make_pair(key, region));
- }
+#if defined(OS_ANDROID)
+ auto maybe_register = [&region, &files_to_register](int key, int fd) {
+ if (fd != -1)
+ files_to_register->ShareWithRegion(key, fd, region);
};
maybe_register(
kV8NativesDataDescriptor,
@@ -205,21 +197,19 @@ void LaunchOnLauncherThread(
snapshot_loaded = true;
#else
base::PlatformFile natives_pf =
- gin::V8Initializer::GetOpenNativesFileForChildProcesses(
- &regions[kV8NativesDataDescriptor]);
+ gin::V8Initializer::GetOpenNativesFileForChildProcesses(&region);
DCHECK_GE(natives_pf, 0);
- files_to_register->Share(kV8NativesDataDescriptor, natives_pf);
+ files_to_register->ShareWithRegion(
+ kV8NativesDataDescriptor, natives_pf, region);
- base::MemoryMappedFile::Region snapshot_region;
base::PlatformFile snapshot_pf =
- gin::V8Initializer::GetOpenSnapshotFileForChildProcesses(
- &snapshot_region);
+ gin::V8Initializer::GetOpenSnapshotFileForChildProcesses(&region);
// Failure to load the V8 snapshot is not necessarily an error. V8 can start
// up (slower) without the snapshot.
if (snapshot_pf != -1) {
snapshot_loaded = true;
- files_to_register->Share(kV8SnapshotDataDescriptor, snapshot_pf);
- regions.insert(std::make_pair(kV8SnapshotDataDescriptor, snapshot_region));
+ files_to_register->ShareWithRegion(
+ kV8SnapshotDataDescriptor, snapshot_pf, region);
}
#endif
@@ -234,9 +224,10 @@ void LaunchOnLauncherThread(
#if defined(OS_ANDROID)
#if ICU_UTIL_DATA_IMPL == ICU_UTIL_DATA_FILE
- files_to_register->Share(
- kAndroidICUDataDescriptor,
- base::i18n::GetIcuDataFileHandle(&regions[kAndroidICUDataDescriptor]));
+ base::MemoryMappedFile::Region icu_region;
+ base::PlatformFile icu_pf = base::i18n::GetIcuDataFileHandle(&icu_region);
+ files_to_register->ShareWithRegion(
+ kAndroidICUDataDescriptor, icu_pf, icu_region);
#endif // ICU_UTIL_DATA_IMPL == ICU_UTIL_DATA_FILE
// Android WebView runs in single process, ensure that we never get here
@@ -244,7 +235,7 @@ void LaunchOnLauncherThread(
CHECK(!cmd_line->HasSwitch(switches::kSingleProcess));
StartChildProcess(
- cmd_line->argv(), child_process_id, std::move(files_to_register), regions,
+ cmd_line->argv(), child_process_id, std::move(files_to_register),
base::Bind(&OnChildProcessStartedAndroid, callback, client_thread_id,
begin_launch_time, base::Passed(&mojo_fd)));
« no previous file with comments | « content/browser/battery_status/battery_monitor_integration_browsertest.cc ('k') | content/browser/file_descriptor_info_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698