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

Unified Diff: chromecast/browser/cast_content_browser_client.cc

Issue 1156873002: Load v8 snapshots directly from APK (and store them uncompressed) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@v8initializer
Patch Set: Keep extracting for components/ 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
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 124730bfdf6d9f4b022ef929077f836bffb4c079..99a8d508266d2c4c80edba48f084d37ac0d49748 100644
--- a/chromecast/browser/cast_content_browser_client.cc
+++ b/chromecast/browser/cast_content_browser_client.cc
@@ -38,7 +38,6 @@
#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"
@@ -53,9 +52,7 @@ namespace chromecast {
namespace shell {
CastContentBrowserClient::CastContentBrowserClient()
- : v8_natives_fd_(-1),
- v8_snapshot_fd_(-1),
- url_request_context_factory_(new URLRequestContextFactory()) {
+ : url_request_context_factory_(new URLRequestContextFactory()) {
}
CastContentBrowserClient::~CastContentBrowserClient() {
@@ -153,16 +150,19 @@ bool CastContentBrowserClient::IsHandledURL(const GURL& url) {
void CastContentBrowserClient::AppendMappedFileCommandLineSwitches(
base::CommandLine* command_line) {
- std::string process_type =
- command_line->GetSwitchValueNative(switches::kProcessType);
-
+#if defined(OS_POSIX) && !defined(OS_MACOSX)
#if defined(V8_USE_EXTERNAL_STARTUP_DATA)
+ std::string process_type =
+ command_line->GetSwitchValueASCII(switches::kProcessType);
if (process_type != switches::kZygoteProcess) {
- DCHECK(natives_fd_exists());
+ DCHECK(v8_files_.natives_fd.is_valid());
command_line->AppendSwitch(::switches::kV8NativesPassedByFD);
- if (snapshot_fd_exists())
+ if (v8_files_.snapshot_fd.is_valid()) {
command_line->AppendSwitch(::switches::kV8SnapshotPassedByFD);
+ }
}
+#endif // V8_USE_EXTERNAL_STARTUP_DATA
+#endif // OS_POSIX && !OS_MACOSX
}
#endif // V8_USE_EXTERNAL_STARTUP_DATA
@@ -332,20 +332,22 @@ void CastContentBrowserClient::GetAdditionalMappedFilesForChildProcess(
#endif
) {
#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);
- }
+ if (!v8_files_.natives_fd.is_valid()) {
+ gin::V8Initializer::OpenV8FilesForChildProcesses(&v8_files_);
+ }
+ DCHECK(v8_files_.natives_fd.is_valid());
+ mappings->Share(kV8NativesDataDescriptor, v8_files_.natives_fd.get());
+#if defined(OS_ANDROID)
+ regions->insert(
+ std::make_pair(kV8NativesDataDescriptor, v8_files_.natives_region));
+#endif
+ if (v8_files_.snapshot_fd.is_valid()) {
+ mappings->Share(kV8SnapshotDataDescriptor, v8_files_.snapshot_fd.get());
+#if defined(OS_ANDROID)
+ regions->insert(
+ std::make_pair(kV8SnapshotDataDescriptor, v8_files_.snapshot_region));
+#endif
}
- // 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;

Powered by Google App Engine
This is Rietveld 408576698