diff options
author | rmcilroy <rmcilroy@chromium.org> | 2015-04-06 14:14:58 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-04-06 21:15:46 +0000 |
commit | 54fab5e3b8f16436d3329ecbdb6c40e050278a51 (patch) | |
tree | eb24d311c8e1ae64afbad532e027ebcc901f6628 /ash/shell | |
parent | 6f6eba38275695220ec63e358d83d9e3b548c7ad (diff) | |
download | chromium_src-54fab5e3b8f16436d3329ecbdb6c40e050278a51.zip chromium_src-54fab5e3b8f16436d3329ecbdb6c40e050278a51.tar.gz chromium_src-54fab5e3b8f16436d3329ecbdb6c40e050278a51.tar.bz2 |
Add support to extension_shell and ash_shell to use external V8 snapshot files.
Adds support to extension_shell and ash_shell to use external V8 snapshot files
in preparation for moving ChromeOS and ChromeCast to use this.
Re-factors the chrome_content_browser_client and
content/shell_content_browser_client to allow more reuse
of the code which opens the V8 external snapshot for child processes
by adding IsolateHolder::OpenV8FilesForChildProcesses.
This does not yet switch ChromeOS to use external V8 snapshot files -
this will be done in follow up CL https://codereview.chromium.org/1019123002.
BUG=421063
Review URL: https://codereview.chromium.org/1019483002
Cr-Commit-Position: refs/heads/master@{#323953}
Diffstat (limited to 'ash/shell')
-rw-r--r-- | ash/shell/DEPS | 1 | ||||
-rw-r--r-- | ash/shell/content_client/shell_content_browser_client.cc | 31 | ||||
-rw-r--r-- | ash/shell/content_client/shell_content_browser_client.h | 11 |
3 files changed, 42 insertions, 1 deletions
diff --git a/ash/shell/DEPS b/ash/shell/DEPS index 1108a45..2e87ae5 100644 --- a/ash/shell/DEPS +++ b/ash/shell/DEPS @@ -1,5 +1,6 @@ include_rules = [ "+content/public", "+content/shell", + "+gin", "+sandbox", ] diff --git a/ash/shell/content_client/shell_content_browser_client.cc b/ash/shell/content_client/shell_content_browser_client.cc index f778787..7f956ec 100644 --- a/ash/shell/content_client/shell_content_browser_client.cc +++ b/ash/shell/content_client/shell_content_browser_client.cc @@ -5,14 +5,21 @@ #include "ash/shell/content_client/shell_content_browser_client.h" #include "ash/shell/content_client/shell_browser_main_parts.h" +#include "content/public/common/content_descriptors.h" #include "content/shell/browser/shell_browser_context.h" +#include "gin/v8_initializer.h" #include "third_party/skia/include/core/SkBitmap.h" namespace ash { namespace shell { ShellContentBrowserClient::ShellContentBrowserClient() - : shell_browser_main_parts_(NULL) { + : +#if defined(OS_POSIX) && !defined(OS_MACOSX) + v8_natives_fd_(-1), + v8_snapshot_fd_(-1), +#endif // OS_POSIX && !OS_MACOSX + shell_browser_main_parts_(nullptr) { } ShellContentBrowserClient::~ShellContentBrowserClient() { @@ -34,6 +41,28 @@ net::URLRequestContextGetter* ShellContentBrowserClient::CreateRequestContext( request_interceptors.Pass()); } +#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 (v8_natives_fd_.get() == -1 || v8_snapshot_fd_.get() == -1) { + 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); + } + } + DCHECK(v8_natives_fd_.get() != -1 && v8_snapshot_fd_.get() != -1); + 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::ShellBrowserContext* ShellContentBrowserClient::browser_context() { return shell_browser_main_parts_->browser_context(); } diff --git a/ash/shell/content_client/shell_content_browser_client.h b/ash/shell/content_client/shell_content_browser_client.h index 1a5eb44..df62338 100644 --- a/ash/shell/content_client/shell_content_browser_client.h +++ b/ash/shell/content_client/shell_content_browser_client.h @@ -33,10 +33,21 @@ class ShellContentBrowserClient : public content::ContentBrowserClient { content::BrowserContext* browser_context, content::ProtocolHandlerMap* protocol_handlers, content::URLRequestInterceptorScopedVector request_interceptors) 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::ShellBrowserContext* browser_context(); private: +#if defined(OS_POSIX) && !defined(OS_MACOSX) + base::ScopedFD v8_natives_fd_; + base::ScopedFD v8_snapshot_fd_; +#endif + ShellBrowserMainParts* shell_browser_main_parts_; DISALLOW_COPY_AND_ASSIGN(ShellContentBrowserClient); |