Index: gin/isolate_holder.cc |
diff --git a/gin/isolate_holder.cc b/gin/isolate_holder.cc |
index 334c0e0ee5130c6e1c081cb40c9f0541b06a2da9..fae20519fa631706b5bb22e80d5282a64fe5e8da 100644 |
--- a/gin/isolate_holder.cc |
+++ b/gin/isolate_holder.cc |
@@ -44,9 +44,14 @@ bool MapV8Files(base::FilePath* natives_path, base::FilePath* snapshot_path, |
g_mapped_natives = new base::MemoryMappedFile; |
if (!g_mapped_natives->IsValid()) { |
+#ifdef OS_ANDROID |
rmcilroy
2014/11/07 23:46:00
Why does MapV8Files need changing here? Doesn't th
baixo1
2014/11/10 15:59:48
Yes, it does work. I undid the changes.
|
if (natives_fd == -1 |
? !g_mapped_natives->Initialize(base::File(*natives_path, flags)) |
- : !g_mapped_natives->Initialize(base::File(natives_fd))) { |
+ : !g_mapped_natives->Initialize(base::File(natives_fd)) |
+#else |
+ if (!g_mapped_natives->Initialize(base::File(*natives_path, flags)) |
+#endif |
+ ) { |
delete g_mapped_natives; |
g_mapped_natives = NULL; |
LOG(FATAL) << "Couldn't mmap v8 natives data file"; |
@@ -56,9 +61,14 @@ bool MapV8Files(base::FilePath* natives_path, base::FilePath* snapshot_path, |
g_mapped_snapshot = new base::MemoryMappedFile; |
if (!g_mapped_snapshot->IsValid()) { |
+#ifdef OS_ANDROID |
if (snapshot_fd == -1 |
? !g_mapped_snapshot->Initialize(base::File(*snapshot_path, flags)) |
- : !g_mapped_snapshot->Initialize(base::File(snapshot_fd))) { |
+ : !g_mapped_snapshot->Initialize(base::File(snapshot_fd)) |
+#else |
+ if (!g_mapped_snapshot->Initialize(base::File(*snapshot_path, flags)) |
+#endif |
+ ) { |
delete g_mapped_snapshot; |
g_mapped_snapshot = NULL; |
LOG(ERROR) << "Couldn't mmap v8 snapshot data file"; |
@@ -80,7 +90,13 @@ bool IsolateHolder::LoadV8Snapshot() { |
return true; |
base::FilePath data_path; |
- PathService::Get(base::DIR_ANDROID_APP_DATA, &data_path); |
+ PathService::Get( |
+#if defined(OS_ANDROID) |
+ base::DIR_ANDROID_APP_DATA, |
+#elif defined(OS_POSIX) |
+ base::DIR_EXE, |
+#endif |
+ &data_path); |
DCHECK(!data_path.empty()); |
base::FilePath natives_path = data_path.AppendASCII("natives_blob.bin"); |
@@ -89,6 +105,7 @@ bool IsolateHolder::LoadV8Snapshot() { |
return MapV8Files(&natives_path, &snapshot_path); |
} |
+#ifdef OS_ANDROID |
rmcilroy
2014/11/07 23:46:01
Why ifdef OS_ANDROID here? Ideally we should keep
baixo1
2014/11/10 15:59:48
Done.
|
//static |
bool IsolateHolder::LoadV8SnapshotFD(int natives_fd, int snapshot_fd) { |
if (g_mapped_natives && g_mapped_snapshot) |
@@ -96,6 +113,26 @@ bool IsolateHolder::LoadV8SnapshotFD(int natives_fd, int snapshot_fd) { |
return MapV8Files(NULL, NULL, natives_fd, snapshot_fd); |
} |
+#endif // OS_ANDROID |
+ |
+#ifndef OS_ANDROID |
rmcilroy
2014/11/07 23:46:01
why ifndef OS_ANDROID here? I know we aren't call
baixo1
2014/11/10 15:59:48
Done.
|
+//static |
+void IsolateHolder::GetV8ExternalSnapshotData(const char** natives_data_out, |
+ int* natives_size_out, |
+ const char** snapshot_data_out, |
+ int* snapshot_size_out) { |
+ if (!g_mapped_natives || !g_mapped_snapshot) { |
+ *natives_data_out = *snapshot_data_out = NULL; |
+ *natives_size_out = *snapshot_size_out = 0; |
+ return; |
+ } |
+ *natives_data_out = reinterpret_cast<const char*>(g_mapped_natives->data()); |
+ *snapshot_data_out = reinterpret_cast<const char*>(g_mapped_snapshot->data()); |
+ *natives_size_out = g_mapped_natives->length(); |
+ *snapshot_size_out = g_mapped_snapshot->length(); |
+} |
+#endif // OS_ANDROID |
+ |
#endif // V8_USE_EXTERNAL_STARTUP_DATA |
IsolateHolder::IsolateHolder() { |