diff options
author | mek <mek@chromium.org> | 2015-06-16 15:30:38 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-06-16 22:32:31 +0000 |
commit | 39ae215990f4ff081ca2a505eb2f2adfe22cb4ab (patch) | |
tree | 89abfc58ba0b0b2da848ab758396c67bdb5f13cb /extensions/shell/browser | |
parent | 7c6b20f381b88bb590772a002ff07a7e4c63baf2 (diff) | |
download | chromium_src-39ae215990f4ff081ca2a505eb2f2adfe22cb4ab.zip chromium_src-39ae215990f4ff081ca2a505eb2f2adfe22cb4ab.tar.gz chromium_src-39ae215990f4ff081ca2a505eb2f2adfe22cb4ab.tar.bz2 |
Revert of Moved logic for mapping child process FDs for ICU and V8 into child_process_launcher.cc (patchset #20 id:380001 of https://codereview.chromium.org/1182443003/)
Reason for revert:
Adds new static initializers in http://build.chromium.org/p/chromium/buildstatus?builder=Linux%20x64&number=4979
# icu_util.cc cc::VertexShaderQuadAA::VertexShaderQuadAA()
# icu_util.cc base::MemoryMappedFile::MemoryMappedFile()
# icu_util.cc base::i18n::(anonymous namespace)::g_icudtl_region
# icu_util.cc base::i18n::(anonymous namespace)::g_icudtl_mapped_file
# icu_util.cc operator new(unsigned long)
Original issue's description:
> Moved logic for mapping child process FDs for ICU and V8 into child_process_launcher.cc
>
> Used to be defined in each app's ContentBrowserClient, but since
> content/ is the one that receives the FDs, it makes sense that it should
> be the one to send them.
>
> This also removes ChildProcessLauncher::AppendMappedFileCommandLineSwitches
> as it is no longer needed.
>
> BUG=394502
>
> Committed: https://crrev.com/228414fc8870f88f11ada7512e88ea6999890f56
> Cr-Commit-Position: refs/heads/master@{#334702}
TBR=jochen@chromium.org,jam@chromium.org,jungshik@google.com,michaelbai@chromium.org,rmcilroy@chromium.org,thestig@chromium.org,agrieve@chromium.org
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=394502
Review URL: https://codereview.chromium.org/1187213002
Cr-Commit-Position: refs/heads/master@{#334719}
Diffstat (limited to 'extensions/shell/browser')
-rw-r--r-- | extensions/shell/browser/shell_content_browser_client.cc | 47 | ||||
-rw-r--r-- | extensions/shell/browser/shell_content_browser_client.h | 16 |
2 files changed, 62 insertions, 1 deletions
diff --git a/extensions/shell/browser/shell_content_browser_client.cc b/extensions/shell/browser/shell_content_browser_client.cc index c9314ad..957b830 100644 --- a/extensions/shell/browser/shell_content_browser_client.cc +++ b/extensions/shell/browser/shell_content_browser_client.cc @@ -28,6 +28,7 @@ #include "extensions/shell/browser/shell_browser_main_parts.h" #include "extensions/shell/browser/shell_extension_system.h" #include "extensions/shell/browser/shell_speech_recognition_manager_delegate.h" +#include "gin/v8_initializer.h" #include "url/gurl.h" #if !defined(DISABLE_NACL) @@ -53,7 +54,12 @@ ShellContentBrowserClient* g_instance = nullptr; ShellContentBrowserClient::ShellContentBrowserClient( ShellBrowserMainDelegate* browser_main_delegate) - : browser_main_parts_(nullptr), + : +#if defined(OS_POSIX) && !defined(OS_MACOSX) + v8_natives_fd_(-1), + v8_snapshot_fd_(-1), +#endif // OS_POSIX && !OS_MACOSX + browser_main_parts_(nullptr), browser_main_delegate_(browser_main_delegate) { DCHECK(!g_instance); g_instance = this; @@ -194,6 +200,21 @@ void ShellContentBrowserClient::SiteInstanceDeleting( site_instance->GetId())); } +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) + 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) { @@ -233,6 +254,30 @@ void ShellContentBrowserClient::GetAdditionalAllowedSchemesForFileSystem( additional_allowed_schemes->push_back(kExtensionScheme); } +#if defined(OS_POSIX) && !defined(OS_MACOSX) +void ShellContentBrowserClient::GetAdditionalMappedFilesForChildProcess( + 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 +} +#endif // OS_POSIX && !OS_MACOSX + content::DevToolsManagerDelegate* ShellContentBrowserClient::GetDevToolsManagerDelegate() { return new content::ShellDevToolsManagerDelegate(GetBrowserContext()); diff --git a/extensions/shell/browser/shell_content_browser_client.h b/extensions/shell/browser/shell_content_browser_client.h index 16e51ca..d282397 100644 --- a/extensions/shell/browser/shell_content_browser_client.h +++ b/extensions/shell/browser/shell_content_browser_client.h @@ -52,12 +52,21 @@ 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( int plugin_process_id) override; void GetAdditionalAllowedSchemesForFileSystem( std::vector<std::string>* additional_schemes) override; +#if defined(OS_POSIX) && !defined(OS_MACOSX) + void GetAdditionalMappedFilesForChildProcess( + const base::CommandLine& command_line, + int child_process_id, + content::FileDescriptorInfo* mappings) override; +#endif + content::DevToolsManagerDelegate* GetDevToolsManagerDelegate() override; protected: @@ -73,6 +82,13 @@ class ShellContentBrowserClient : public content::ContentBrowserClient { // Returns the extension or app associated with |site_instance| or NULL. const Extension* GetExtension(content::SiteInstance* site_instance); +#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. ShellBrowserMainParts* browser_main_parts_; |