summaryrefslogtreecommitdiffstats
path: root/extensions/shell
diff options
context:
space:
mode:
authorerikcorry <erikcorry@chromium.org>2015-06-08 04:29:16 -0700
committerCommit bot <commit-bot@chromium.org>2015-06-08 11:30:00 +0000
commitc94eff1e7e8b2bd5973d7211c320d9f025c980c1 (patch)
treeb74c21bb58fadc70af46c76fb43d214c494c3766 /extensions/shell
parent878d687f2f9ff7d9f6424309d216ee2459886b68 (diff)
downloadchromium_src-c94eff1e7e8b2bd5973d7211c320d9f025c980c1.zip
chromium_src-c94eff1e7e8b2bd5973d7211c320d9f025c980c1.tar.gz
chromium_src-c94eff1e7e8b2bd5973d7211c320d9f025c980c1.tar.bz2
Allow startup with missing V8 snapshot file.
We want to stop shipping the snapshot file, and instead we want to generate it on the client. This will reduce the download size. But since snapshot generation will be asynchronous in a utility process, it might not be present on the first few runs of the browser. This means we have to be able to start up without the snapshot file (just with the natives source file). This CL fixes Blink to cope with a missing snapshot file (V8 could already cope). R=rmcilroy@chromium.org, sky@chromium.org BUG= Review URL: https://codereview.chromium.org/1164483003 Cr-Commit-Position: refs/heads/master@{#333258}
Diffstat (limited to 'extensions/shell')
-rw-r--r--extensions/shell/browser/shell_content_browser_client.cc23
-rw-r--r--extensions/shell/browser/shell_content_browser_client.h4
2 files changed, 19 insertions, 8 deletions
diff --git a/extensions/shell/browser/shell_content_browser_client.cc b/extensions/shell/browser/shell_content_browser_client.cc
index 19f0547b..957b830 100644
--- a/extensions/shell/browser/shell_content_browser_client.cc
+++ b/extensions/shell/browser/shell_content_browser_client.cc
@@ -200,21 +200,26 @@ void ShellContentBrowserClient::SiteInstanceDeleting(
site_instance->GetId()));
}
-void ShellContentBrowserClient::AppendExtraCommandLineSwitches(
- base::CommandLine* command_line,
- int child_process_id) {
+void ShellContentBrowserClient::AppendMappedFileCommandLineSwitches(
+ base::CommandLine* command_line) {
std::string process_type =
command_line->GetSwitchValueASCII(::switches::kProcessType);
#if defined(OS_POSIX) && !defined(OS_MACOSX)
#if defined(V8_USE_EXTERNAL_STARTUP_DATA)
- if (process_type != ::switches::kZygoteProcess) {
- command_line->AppendSwitch(::switches::kV8NativesPassedByFD);
+ DCHECK(natives_fd_exists());
+ command_line->AppendSwitch(::switches::kV8NativesPassedByFD);
+ if (snapshot_fd_exists())
command_line->AppendSwitch(::switches::kV8SnapshotPassedByFD);
- }
#endif // V8_USE_EXTERNAL_STARTUP_DATA
#endif // OS_POSIX && !OS_MACOSX
+}
+void ShellContentBrowserClient::AppendExtraCommandLineSwitches(
+ base::CommandLine* command_line,
+ int child_process_id) {
+ std::string process_type =
+ command_line->GetSwitchValueASCII(::switches::kProcessType);
if (process_type == ::switches::kRendererProcess)
AppendRendererSwitches(command_line);
}
@@ -255,7 +260,7 @@ void ShellContentBrowserClient::GetAdditionalMappedFilesForChildProcess(
int child_process_id,
content::FileDescriptorInfo* mappings) {
#if defined(V8_USE_EXTERNAL_STARTUP_DATA)
- if (v8_natives_fd_.get() == -1 || v8_snapshot_fd_.get() == -1) {
+ if (!natives_fd_exists()) {
int v8_natives_fd = -1;
int v8_snapshot_fd = -1;
if (gin::V8Initializer::OpenV8FilesForChildProcesses(&v8_natives_fd,
@@ -264,7 +269,9 @@ void ShellContentBrowserClient::GetAdditionalMappedFilesForChildProcess(
v8_snapshot_fd_.reset(v8_snapshot_fd);
}
}
- DCHECK(v8_natives_fd_.get() != -1 && v8_snapshot_fd_.get() != -1);
+ // 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
diff --git a/extensions/shell/browser/shell_content_browser_client.h b/extensions/shell/browser/shell_content_browser_client.h
index f9d813f..d282397 100644
--- a/extensions/shell/browser/shell_content_browser_client.h
+++ b/extensions/shell/browser/shell_content_browser_client.h
@@ -52,6 +52,8 @@ class ShellContentBrowserClient : public content::ContentBrowserClient {
void SiteInstanceDeleting(content::SiteInstance* site_instance) override;
void AppendExtraCommandLineSwitches(base::CommandLine* command_line,
int child_process_id) override;
+ void AppendMappedFileCommandLineSwitches(
+ base::CommandLine* command_line) override;
content::SpeechRecognitionManagerDelegate*
CreateSpeechRecognitionManagerDelegate() override;
content::BrowserPpapiHost* GetExternalBrowserPpapiHost(
@@ -83,6 +85,8 @@ class ShellContentBrowserClient : public content::ContentBrowserClient {
#if defined(OS_POSIX) && !defined(OS_MACOSX)
base::ScopedFD v8_natives_fd_;
base::ScopedFD v8_snapshot_fd_;
+ bool natives_fd_exists() { return v8_natives_fd_ != -1; }
+ bool snapshot_fd_exists() { return v8_snapshot_fd_ != -1; }
#endif
// Owned by content::BrowserMainLoop.