summaryrefslogtreecommitdiffstats
path: root/extensions
diff options
context:
space:
mode:
authorrmcilroy <rmcilroy@chromium.org>2015-04-06 14:14:58 -0700
committerCommit bot <commit-bot@chromium.org>2015-04-06 21:15:46 +0000
commit54fab5e3b8f16436d3329ecbdb6c40e050278a51 (patch)
treeeb24d311c8e1ae64afbad532e027ebcc901f6628 /extensions
parent6f6eba38275695220ec63e358d83d9e3b548c7ad (diff)
downloadchromium_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 'extensions')
-rw-r--r--extensions/shell/browser/DEPS2
-rw-r--r--extensions/shell/browser/shell_content_browser_client.cc38
-rw-r--r--extensions/shell/browser/shell_content_browser_client.h12
3 files changed, 48 insertions, 4 deletions
diff --git a/extensions/shell/browser/DEPS b/extensions/shell/browser/DEPS
index 19d19e7..8b27b25 100644
--- a/extensions/shell/browser/DEPS
+++ b/extensions/shell/browser/DEPS
@@ -21,6 +21,8 @@ include_rules = [
"+device/hid",
"+device/usb",
+ "+gin",
+
"+google_apis/gaia",
"+net",
diff --git a/extensions/shell/browser/shell_content_browser_client.cc b/extensions/shell/browser/shell_content_browser_client.cc
index 905a343..3971f0c 100644
--- a/extensions/shell/browser/shell_content_browser_client.cc
+++ b/extensions/shell/browser/shell_content_browser_client.cc
@@ -8,6 +8,7 @@
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/site_instance.h"
+#include "content/public/common/content_descriptors.h"
#include "content/public/common/content_switches.h"
#include "content/public/common/url_constants.h"
#include "content/shell/browser/shell_browser_context.h"
@@ -26,6 +27,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)
@@ -45,19 +47,25 @@ using content::BrowserThread;
namespace extensions {
namespace {
-ShellContentBrowserClient* g_instance = NULL;
+ShellContentBrowserClient* g_instance = nullptr;
} // namespace
ShellContentBrowserClient::ShellContentBrowserClient(
ShellBrowserMainDelegate* browser_main_delegate)
- : browser_main_parts_(NULL), browser_main_delegate_(browser_main_delegate) {
+ :
+#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;
}
ShellContentBrowserClient::~ShellContentBrowserClient() {
- g_instance = NULL;
+ g_instance = nullptr;
}
// static
@@ -219,7 +227,7 @@ ShellContentBrowserClient::GetExternalBrowserPpapiHost(int plugin_process_id) {
++iter;
}
#endif
- return NULL;
+ return nullptr;
}
void ShellContentBrowserClient::GetAdditionalAllowedSchemesForFileSystem(
@@ -229,6 +237,28 @@ 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 (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::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..f9d813f 100644
--- a/extensions/shell/browser/shell_content_browser_client.h
+++ b/extensions/shell/browser/shell_content_browser_client.h
@@ -58,6 +58,13 @@ class ShellContentBrowserClient : public content::ContentBrowserClient {
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 +80,11 @@ 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_;
+#endif
+
// Owned by content::BrowserMainLoop.
ShellBrowserMainParts* browser_main_parts_;