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

Unified Diff: chromecast/browser/cast_content_browser_client.cc

Issue 1187213002: Revert of Moved logic for mapping child process FDs for ICU and V8 into child_process_launcher.cc (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 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
« no previous file with comments | « chromecast/browser/cast_content_browser_client.h ('k') | content/browser/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chromecast/browser/cast_content_browser_client.cc
diff --git a/chromecast/browser/cast_content_browser_client.cc b/chromecast/browser/cast_content_browser_client.cc
index 2d1027bb1ee90b990be16be18942f4a11d1f6c2b..85938256156d1af6154d7844ae7d5f852a07bef4 100644
--- a/chromecast/browser/cast_content_browser_client.cc
+++ b/chromecast/browser/cast_content_browser_client.cc
@@ -9,6 +9,7 @@
#include "base/base_switches.h"
#include "base/command_line.h"
#include "base/files/scoped_file.h"
+#include "base/i18n/icu_util.h"
#include "base/i18n/rtl.h"
#include "base/path_service.h"
#include "chromecast/base/cast_paths.h"
@@ -37,6 +38,7 @@
#include "content/public/common/content_switches.h"
#include "content/public/common/url_constants.h"
#include "content/public/common/web_preferences.h"
+#include "gin/v8_initializer.h"
#include "media/audio/audio_manager_factory.h"
#include "net/ssl/ssl_cert_request_info.h"
#include "net/url_request/url_request_context_getter.h"
@@ -51,7 +53,9 @@
namespace shell {
CastContentBrowserClient::CastContentBrowserClient()
- : url_request_context_factory_(new URLRequestContextFactory()) {
+ : v8_natives_fd_(-1),
+ v8_snapshot_fd_(-1),
+ url_request_context_factory_(new URLRequestContextFactory()) {
}
CastContentBrowserClient::~CastContentBrowserClient() {
@@ -171,6 +175,21 @@
return false;
}
+void CastContentBrowserClient::AppendMappedFileCommandLineSwitches(
+ base::CommandLine* command_line) {
+ std::string process_type =
+ command_line->GetSwitchValueNative(switches::kProcessType);
+
+#if defined(V8_USE_EXTERNAL_STARTUP_DATA)
+ if (process_type != switches::kZygoteProcess) {
+ DCHECK(natives_fd_exists());
+ command_line->AppendSwitch(::switches::kV8NativesPassedByFD);
+ if (snapshot_fd_exists())
+ command_line->AppendSwitch(::switches::kV8SnapshotPassedByFD);
+ }
+}
+
+#endif // V8_USE_EXTERNAL_STARTUP_DATA
void CastContentBrowserClient::AppendExtraCommandLineSwitches(
base::CommandLine* command_line,
int child_process_id) {
@@ -333,6 +352,22 @@
const base::CommandLine& command_line,
int child_process_id,
content::FileDescriptorInfo* mappings) {
+#if defined(V8_USE_EXTERNAL_STARTUP_DATA)
+ if (!natives_fd_exists()) {
+ int v8_natives_fd = -1;
+ int v8_snapshot_fd = -1;
+ if (gin::V8Initializer::OpenV8FilesForChildProcesses(&v8_natives_fd,
+ &v8_snapshot_fd)) {
+ v8_natives_fd_.reset(v8_natives_fd);
+ v8_snapshot_fd_.reset(v8_snapshot_fd);
+ }
+ }
+ // V8 can't start up without the source of the natives, but it can
+ // start up (slower) without the snapshot.
+ DCHECK(natives_fd_exists());
+ mappings->Share(kV8NativesDataDescriptor, v8_natives_fd_.get());
+ mappings->Share(kV8SnapshotDataDescriptor, v8_snapshot_fd_.get());
+#endif // V8_USE_EXTERNAL_STARTUP_DATA
#if defined(OS_ANDROID)
const int flags_open_read = base::File::FLAG_OPEN | base::File::FLAG_READ;
base::FilePath pak_file_path;
@@ -357,6 +392,16 @@
base::ScopedFD(minidump_file.TakePlatformFile()));
}
}
+
+ base::FilePath app_data_path;
+ CHECK(PathService::Get(base::DIR_ANDROID_APP_DATA, &app_data_path));
+ base::FilePath icudata_path =
+ app_data_path.AppendASCII(base::i18n::kIcuDataFileName);
+ base::File icudata_file(icudata_path, flags_open_read);
+ if (!icudata_file.IsValid())
+ NOTREACHED() << "Failed to open ICU file when creating renderer process";
+ mappings->Transfer(kAndroidICUDataDescriptor,
+ base::ScopedFD(icudata_file.TakePlatformFile()));
#else
int crash_signal_fd = GetCrashSignalFD(command_line);
if (crash_signal_fd >= 0) {
« no previous file with comments | « chromecast/browser/cast_content_browser_client.h ('k') | content/browser/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698